Re: xpath sequence methods and subscripts

Martin Honnen <[email protected]> Tue, 08 Feb 2011 13:33:02 +0100
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <[email protected]>
rvj wrote:
> 1. anyone got an example of how to return the results of a sequence method
> such as tokenize ?
>
>      <assign var="?alltokens"  expr="tokenize('in the beginning') />
>
> 2. or how to return the second "token" - some kind of subscript on data??
>
>      <assign var="?secondtoken"  expr="data(tokenize('in the beginning'),2)
> />

I am not sure what technology you are trying to use. This is the Mozilla 
newsgroup for XML. tokenize is a function supported in XPath and XSLT 
2.0 and in XQuery 1.0 but as far as I know Mozilla does only support 
XSLT and XPath 1.0 which does not know any sequences.

In XPath 2.0 to access the second item in the sequence $foo is simply
   $foo[2]
so
   tokenize('in the beginning', ' ')[2]
should give you the string 'the'.


-- 

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/