xpath sequence methods and subscripts

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

xpath sequence methods and subscripts

rvj-2

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)
/>
 


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: xpath sequence methods and subscripts

rvj-2
I guess it's subsequence !


"rvj" <[hidden email]> wrote in message
news:[hidden email]...

>
> 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)
> />
>
>
>


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: xpath sequence methods and subscripts

rvj-2
.....is this the correct syntax to return "the"?

<assign var="?secondtoken"  expr="subsequence('in','the','beginning'),2)"
/>




"rvj" <[hidden email]> wrote in message
news:[hidden email]...

>I guess it's subsequence !
>
>
> "rvj" <[hidden email]> wrote in message
> news:[hidden email]...
>>
>> 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)
>> />
>>
>>
>>
>
>


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: xpath sequence methods and subscripts

rvj-2
or

 <assign var="?secondtoken"  expr="subsequence(tokenize(@phrase),2)"

where @phrase is "in the beginning"

"rvj" <[hidden email]> wrote in message
news:[hidden email]...

> .....is this the correct syntax to return "the"?
>
> <assign var="?secondtoken"  expr="subsequence('in','the','beginning'),2)"
> />
>
>
>
>
> "rvj" <[hidden email]> wrote in message
> news:[hidden email]...
>>I guess it's subsequence !
>>
>>
>> "rvj" <[hidden email]> wrote in message
>> news:[hidden email]...
>>>
>>> 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) />
>>>
>>>
>>>
>>
>>
>
>


_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: xpath sequence methods and subscripts

Martin Honnen-3
In reply to this post by rvj-2
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/
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml