This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes how can get just name@javaranch.com without tags in email application?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how can get just name@javaranch.com without tags in email application??" Watch "how can get just name@javaranch.com without tags in email application??" New topic
Author

how can get just name@javaranch.com without tags in email application??

Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
Hi, ya'll,
I am doing a mail application now.
But, I am stuck here since yesterday..plz help..
I have a xsl file.
set a goble variable to pass to another file
<xsl:variable name="FromAddress" >
<xsl:value-of select="./Parties/Party/@Address" />
</xsl:variable>
<!-- which will get the resutl: "Name" <name@javaranch.com> -->
I use value="{$FromAddress}" to pass parameters as reply function in an email application
<!-- I can get the result: "Name" <name@javaranch.com> -->
But, the problem I face is to reuse this value. I need to take this email address as reply email address..
Problem: it takes everything to pass..and
either xml '>' expected or transcoding invalid XML.
I'll just need name@javaranch.com as my parameters..(I use IBMTranscoding Publisher to translate my stylesheet)
how can get just name@javaranch.com
not "Name" <name@javaranch.com>??
in java, u can use String Token to get it, but, how can I do here?? any way?? Thanks in advance.
Guillaume Compagnon
Ranch Hand

Joined: Aug 09, 2001
Posts: 106
Sure! there is no StringTokenizer in XSL

(StringTokenizer is not a very performant classe, U know)
Is it not possible for U to have the data in 2 different variables : the name and the email ?
that will be easy to concatenate the two than separate your existing data (perhaps it is not possible in XSL ... XSL is not a very rich language, not as so much than Java)

------------------
---------
Guillaume


---------<BR>Guillaume
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
You can use substring function. In your case it will be:
<xsl:variable name="cleanAddres" select="substring($FromAddress, 2, string-length($FromAddress)-2)"/>

[This message has been edited by Mapraputa Is (edited August 09, 2001).]


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
Thx.
finally seems a light there..
one more help, plz..
but, how can I know where is the start point?
<xsl:variable name="cleanAddress" select="substring($FromAddress, 2, string-length($FromAddress)-2)"/>
here result
Original== "Mail" <mail@javaranch.com>
Results==> Mail" <mail@yahoo.com
how can I let the parser knows I'll start to get string from <
since different users have different length of email address.
thx again..
Z

Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Then you need substring-before() and substring-after() functions. You call substring-before() with '>' parameter, and substring-after() with '<', but since you cannot use < symbol in XSLT directly, you escape it as '&lt;'
<xsl:variable name="cleanAddress"
select="substring-before (
substring-after($FromAddress, '&lt;'), '>'
)"/>
[This message has been edited by Mapraputa Is (edited August 09, 2001).]
Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
Mapraputa,
Thx.
I got it. Everything works fine now. I am ready to check in my codes and complete tasks.
Z
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can get just name@javaranch.com without tags in email application??
 
Similar Threads
A Interesting project for everyone who is interested.
Changing the param of an applet with XSL or JS ...
xsl getNext to sort output
An Unwanted Part of the XML Input File is Included in the XSL Transformation Result
using variable value inside a variable call ...