Saxon and XQuery : how not to repeat the XML source file name in the query ?

Discussion in 'XML' started by pepin_labulle@yahoo.fr, Jul 4, 2005.

  1. Guest

    I'm a newbie with XQuery and I'm trying to execute a query with Saxon.
    If I don't specify the XML source file name in the query, Saxon raises
    the following error :
    javax.xml.transform.Transforme­rException: Finding root of tree: the
    context item is not set
    Even if I specified the source file name in the command line.

    Here is the command line I used :
    java -cp saxon8.jar net.sf.saxon.Query -s books.xml books.xq

    where books.xq =

    xquery version "1.0";
    for $b in //BOOKS/ITEM
    order by string-length($b/TITLE) return
    <book>
    <author> { $b/AUTHOR } </author>
    <title> { $b/TITLE } </title>
    </book>

    I can avoid the error by using this line in the query :
    for $b in doc("books.xml")//BOOKS/ITEM

    But, I don't want to repeat the file name in the query. I'd like to use
    the same query whatever the file name is.
    Is it possible ?

    Actually, Saxon behaves the same in command line or called from a java
    program.
    I used a utility called bumblebee to test my query with different
    XQuery processors, and i get the same result with Qizx.

    Thank you and excuse my english.
     
    , Jul 4, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin G. Jones
    Replies:
    0
    Views:
    413
    Benjamin G. Jones
    Jan 8, 2004
  2. Stylus Studio
    Replies:
    0
    Views:
    458
    Stylus Studio
    Jul 21, 2004
  3. FBS

    XQuery ( XML Query )

    FBS, Jun 8, 2005, in forum: XML
    Replies:
    1
    Views:
    522
    Martin Honnen
    Jun 8, 2005
  4. Ken North
    Replies:
    0
    Views:
    633
    Ken North
    Jul 14, 2005
  5. Replies:
    2
    Views:
    5,155
    Stryder
    Feb 25, 2009
Loading...

Share This Page