According to the XML:DB API Documentation it's possible to query non
persistent data using Sedna's XQuery engine by doing something like this:
Document myDoc = loadFromLocalXML();
xqService1.declareVariable("myDoc", myDoc);
xqService1.query(
"for $x in $myDoc/a/b/c return $x/string()");
However using a very simple document such as :
<root><a>text1</a><b>text2</b></root>
And trying to execute the query (or any other query for that matter)
org.w3c.dom.Document doc = loadMyXMLDocument(pathToXML)
String query = "for $iin $doc/root/a/text() return $i";
ser.declareVariable("doc", doc);
I get the following error:
It is a static error if an expression is not a valid instance of the grammar
defined in A.1 EBNF.
Details: at (1:78), syntax error, unexpected >, expecting "," or }
at (1:147), unexpected symbol in constructor: '/'
at (1:153), unexpected symbol in constructor: '}'
at (1:154), unclosed XML element
When I tried to debug, I found in some hidden variable, the following:
declare variable $doc := document{<?xml version="1.0"
encoding="utf-8"?><root><a>text1</a><b>text2</b></root>};
for $mdr in $doc/root/a/text() return $mdr
If I execute this using se_term ... it fails with the same error as
previously , HOWEVER....
If I try to execute the same but removing the "*<?xml version="1.0"
encoding="utf-8"?>*", thus becoming:
declare variable $doc := document{<root><a>text1</a><b>text2</b></root>};
for $mdr in $doc/root/a/text() return $mdr
My query returns "text1" as expected
So the question Is.... is this some bug in Sedna XML:DB API or am I doing
something wrong?
Many thanks for any help =)
--
Pedro Pereira
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion