[xquery-talk] saxon:evaluate with relative xpath
Hisham Benotman
hrbpdx at gmail.com
Thu Dec 23 21:33:04 PST 2010
Hi
Can I run dynamic RELATIVE xpath using saxon:evaluate? I retrieve book
elements from books.xml file and I want to navigate these elements using
relative xpaths and saxon:evaluate. It seems saxon:evaluate understands only
absolute paths that starts from the root element.
I am using saxon processor in oXygen.
The following is sample xquery and data files, my application is different.
XQuery:
<Authors>
{
(: Step One I get the dynamic path from paths.xml file :)
let $author_path := data(doc('paths.xml')/Xpaths/Author_Path)
for $elem2 in doc('Books.xml')/Books/Book (:Get book elements:)
return $elem2/saxon:evaluate($author_path) (: Want to navigate a
book element here but it does not work:)
}
</Authors>
------------------------------------------------------------
Data file books.xml
<Books>
<Book>
<author>John</author>
<Title>XQuery</Title>
</Book>
<Book>
<author>Tim</author>
<Title>XSLT</Title>
</Book>
</Books>
---------------------------------------------------------------------------------------------
File that contains xpaths that will be loaded and run dynamically
paths.xml
<Xpaths>
<Author_Path> /author[1] </Author_Path>
</Xpaths>
--------------------------------------------------------------------------------------------
The query returns nothing , when I use static path return $elem2/author[1]
it works. When I change the path stored in paths.xml to
/Books/Book/author[1] it returns all authors in each iteration.
<Authors>
<author>John</author>
<author>Tim</author>
<author>John</author>
<author>Tim</author>
</Authors>
I appreciate any help
Thank you
Hisham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20101223/b5179d49/attachment.htm
More information about the talk
mailing list