Thanks a lot. It works now.<br><br><div class="gmail_quote">On Sun, Dec 26, 2010 at 11:16 AM, Michael Kay <span dir="ltr">&lt;<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  
    
    
  
  <div 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 &quot;/author[1]&quot; to &quot;author[1]&quot;.<br>
    <br>
    Michael Kay<br>
    Saxonica<div><div></div><div class="h5"><br>
    <br>
    On 24/12/2010 05:33, Hisham Benotman wrote:
    </div></div><blockquote type="cite"><div><div></div><div class="h5">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>&lt;Authors&gt;</div>
          <div>
            {</div>
          <div>   (: Step One I get the dynamic path from paths.xml file
             :)</div>
          <div>   let $author_path :=
            data(doc(&#39;paths.xml&#39;)/Xpaths/Author_Path) </div>
          <div>   for $elem2 in doc(&#39;Books.xml&#39;)/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>&lt;/Authors&gt;</div>
        </div>
      </div>
      <div>------------------------------------------------------------</div>
      <div>Data file books.xml</div>
      <div>&lt;Books&gt;</div>
      <div>
        <div>   &lt;Book&gt;</div>
        <div>       &lt;author&gt;John&lt;/author&gt;</div>
        <div>       &lt;Title&gt;XQuery&lt;/Title&gt;</div>
        <div>   &lt;/Book&gt;</div>
        <div>   &lt;Book&gt;</div>
        <div>       &lt;author&gt;Tim&lt;/author&gt;</div>
        <div>       &lt;Title&gt;XSLT&lt;/Title&gt;</div>
        <div>   &lt;/Book&gt;</div>
        <div>&lt;/Books&gt; </div>
      </div>
      <div>---------------------------------------------------------------------------------------------</div>
      <div>File that contains xpaths that will be loaded and run
        dynamically</div>
      <div>paths.xml</div>
      <div>
        <div>&lt;Xpaths&gt;</div>
        <div>    &lt;Author_Path&gt;  /author[1]  &lt;/Author_Path&gt;</div>
        <div>&lt;/Xpaths&gt;</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>&lt;Authors&gt;</div>
        <div>   &lt;author&gt;John&lt;/author&gt;</div>
        <div>   &lt;author&gt;Tim&lt;/author&gt;</div>
        <div>   &lt;author&gt;John&lt;/author&gt;</div>
        <div>   &lt;author&gt;Tim&lt;/author&gt;</div>
        <div>
          &lt;/Authors&gt;</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>
      </div></div><pre><fieldset></fieldset>
_______________________________________________
<a href="mailto:talk@x-query.com" target="_blank">talk@x-query.com</a>
<a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a></pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
<a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
<a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a><br></blockquote></div><br>