364,085 Members | 5432 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

XSLT Selecting characters in string

requeth@gmail.com
P: n/a
requeth@gmail.com
Allo,

I'm a little confused. I have an XSLT, in which my parser selects a
node, but I want to just capture the first two characters to a
variable. How would I do this? I know how to create the variable, but
I'm not sure how to take just the first two characters of the string.

Thanks,

RT Starid

Sep 26 '06 #1
Share this Question
Share on Google+
3 Replies


Joseph Kesselman
P: n/a
Joseph Kesselman
requeth@gmail.com wrote:
variable. How would I do this? I know how to create the variable, but
I'm not sure how to take just the first two characters of the string.
XSLT and XPath come with a function library that includes the
traditional substring function. Just set the variable to an XPath
expression that invokes it. For example, if you want the truncated value
of the current node's foo attribute, you could write

<xsl:variable name="myvar" select="substring(@foo,0,2)


http://www.w3.org/TR/1999/REC-xpath-...ring-Functions
(though it looks like there's a typo in one of the examples).



--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Sep 26 '06 #2

Dimitre Novatchev
P: n/a
Dimitre Novatchev
<xsl:variable name="myvar" select="substring(@foo,0,2)


XPath is 1-based. Therefore, the expression to produce the substring,
consisting of the first two characters in the string value of @foo is:

substring(@foo, 1, 2)


Cheers,
Dimitre Novatchev


"Joseph Kesselman" <keshlam-nospam@comcast.netwrote in message
news:45196e65$1@kcnews01...
requeth@gmail.com wrote:
>variable. How would I do this? I know how to create the variable, but
>I'm not sure how to take just the first two characters of the string.
>
XSLT and XPath come with a function library that includes the traditional
substring function. Just set the variable to an XPath expression that
invokes it. For example, if you want the truncated value of the current
node's foo attribute, you could write
>
<xsl:variable name="myvar" select="substring(@foo,0,2)
>
>
http://www.w3.org/TR/1999/REC-xpath-...ring-Functions
(though it looks like there's a typo in one of the examples).
>
>
>
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Sep 27 '06 #3

Joe Kesselman
P: n/a
Joe Kesselman
Dimitre Novatchev wrote:
XPath is 1-based. Therefore, the expression to produce the substring,
consisting of the first two characters in the string value of @foo is:
substring(@foo, 1, 2)
Whups. Yes, my bad. I'm coding in three languages at once these days,
and I got confused.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 27 '06 #4

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework