[xquery-talk] saxon:evaluate with relative xpath

Hisham Benotman hrbpdx at gmail.com
Thu Dec 23 21:33:04 PST 2010


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.
   (: 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:)
Data file books.xml
File that contains xpaths that will be loaded and run dynamically
    <Author_Path>  /author[1]  </Author_Path>

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.

I appreciate any help

Thank you
-------------- 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