P
pepin_labulle
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.TransformerException: 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.
If I don't specify the XML source file name in the query, Saxon raises
the following error :
javax.xml.transform.TransformerException: 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.