Xpath

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

Xpath

Peymirat Damien
Hi all,

   I have a question about Xpath expression. I have a file which path is
test/test2/test3/toto.xml . My question is how can I put toto.xml alone
??
I know there are functions as substring-berfore, substring-after ... but
is there a funtion like this : substring-after(
test/test2/test3/toto.xml, last('/') )

Thank you for your answers

Damien.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Xpath

Ryan Puddephatt
You could use tokenize to split the string

Ryan Puddephatt
Software Engineer

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP

e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108

 

>-----Original Message-----
>From: Peymirat Damien [mailto:[hidden email]]
>Sent: 18 September 2006 13:47
>To: [hidden email]
>Subject: [ops-users] Xpath
>
>Hi all,
>
>   I have a question about Xpath expression. I have a file
>which path is test/test2/test3/toto.xml . My question is how
>can I put toto.xml alone ??
>I know there are functions as substring-berfore,
>substring-after ... but is there a funtion like this :
>substring-after( test/test2/test3/toto.xml, last('/') )
>
>Thank you for your answers
>
>Damien.
>
>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xpath

Erik Bruchez
Administrator
In reply to this post by Peymirat Damien
Damien,

 > I have a question about Xpath expression. I have a file which path is
 > test/test2/test3/toto.xml . My question is how can I put toto.xml alone
 > ??
 > I know there are functions as substring-berfore, substring-after ... but
 > is there a funtion like this : substring-after(
 > test/test2/test3/toto.xml, last('/') )

Unfortunately there is no such function, and I complained about that
kind of use cases to the working group in charge of XPath 2.0, but to
no avail [1].

In this case, as Ryan is suggesting, you can use tokenize():

   tokenize($path, '/')[last()]

-Erik

[1] http://lists.w3.org/Archives/Public/public-qt-comments/2003Oct/0072

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE : Xpath

Peymirat Damien
In reply to this post by Peymirat Damien
Thank you Erik & Ryan

Here is my final solution to separate a path in two :

test1/test2/test3/toto.xml --> test1/test2/test3  toto.xml

For the first part :

substring(substring-before($path,tokenize($path, '/')[last()]),1,string-length(substring-before($path,tokenize($path, '/')[last()]))-1)    ( it's so pretty :-D )

For the second part :

tokenize($path, '/')[last()]

Do you think that it is the only solution ??

-----Message d'origine-----
De : Erik Bruchez [mailto:[hidden email]] De la part de Erik Bruchez
Envoyé : lundi 18 septembre 2006 17:09
À : [hidden email]
Objet : Re: [ops-users] Xpath


Damien,

I have a question about Xpath expression. I have a file which path is test/test2/test3/toto.xml . My question is how can I put toto.xml alone ?? I know there are functions as substring-berfore, substring-after ... but  is there a funtion like this : substring-after( test/test2/test3/toto.xml, last('/') )



Unfortunately there is no such function, and I complained about that kind of use cases to the working group in charge of XPath 2.0, but to no avail [1].

In this case, as Ryan is suggesting, you can use tokenize():

   tokenize($path, '/')[last()]

-Erik

[1] http://lists.w3.org/Archives/Public/public-qt-comments/2003Oct/0072

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws