<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
saxon:evaluate evaluates the given XPath expression using the
context node from the call to saxon:evaluate. So yes, the path can
be relative. Just change "/author[1]" to "author[1]".<br>
<br>
Michael Kay<br>
Saxonica<br>
<br>
On 24/12/2010 05:33, Hisham Benotman wrote:
<blockquote
cite="mid:AANLkTinEGYkgn-FdpfoeOfTJ0Aobs92vt4Nni_LVctX2@mail.gmail.com"
type="cite">Hi
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>I am using saxon processor in oXygen.</div>
<div><br>
</div>
<div>The following is sample xquery and data files, my application
is different.</div>
<div>
<div>XQuery:</div>
<div>
<div><Authors></div>
<div>
{</div>
<div> (: Step One I get the dynamic path from paths.xml file
:)</div>
<div> let $author_path :=
data(doc('paths.xml')/Xpaths/Author_Path) </div>
<div> for $elem2 in doc('Books.xml')/Books/Book (:Get book
elements:)</div>
<div> return $elem2/saxon:evaluate($author_path) (:
Want to navigate a book element here but it does not work:)</div>
<div> } </div>
<div></Authors></div>
</div>
</div>
<div>------------------------------------------------------------</div>
<div>Data file books.xml</div>
<div><Books></div>
<div>
<div> <Book></div>
<div> <author>John</author></div>
<div> <Title>XQuery</Title></div>
<div> </Book></div>
<div> <Book></div>
<div> <author>Tim</author></div>
<div> <Title>XSLT</Title></div>
<div> </Book></div>
<div></Books> </div>
</div>
<div>---------------------------------------------------------------------------------------------</div>
<div>File that contains xpaths that will be loaded and run
dynamically</div>
<div>paths.xml</div>
<div>
<div><Xpaths></div>
<div> <Author_Path> /author[1] </Author_Path></div>
<div></Xpaths></div>
</div>
<div>--------------------------------------------------------------------------------------------</div>
<div><br>
</div>
<div>The query returns nothing , when I use static path return
$elem2/author[1]</div>
<div>it works. When I change the path stored in paths.xml to
/Books/Book/author[1] it returns all authors in each iteration.</div>
<div>
<div><Authors></div>
<div> <author>John</author></div>
<div> <author>Tim</author></div>
<div> <author>John</author></div>
<div> <author>Tim</author></div>
<div>
</Authors></div>
</div>
<div><br>
</div>
<div>I appreciate any help</div>
<div><br>
</div>
<div>Thank you</div>
<div>Hisham</div>
<div><br>
</div>
<div><br>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:talk@x-query.com">talk@x-query.com</a>
<a class="moz-txt-link-freetext" href="http://x-query.com/mailman/listinfo/talk">http://x-query.com/mailman/listinfo/talk</a></pre>
</blockquote>
<br>
</body>
</html>