Thread view

Hello,
another exception when using XQuery with a NodeInfo instance from the
following code fragment is thrown:
if (item instanceof NodeInfo) {
if
(!((NodeInfo)item).getConfiguration().isCompatible(config)) {
throw new IllegalArgumentException(
"Supplied node must be built using the same
or a compatible Configuration");
}
}
This would mean, that the configuration is not compatible, but what I do
is:
final NodeWrapper doc =
(NodeWrapper) new DocumentWrapper(session, new
Configuration(), mFile
.getAbsolutePath()).wrap();
(NodeInfo and DocumentInfo implementations).
The code I use for XQuery is the following:
final XdmDestination destination = new XdmDestination();
try {
final Processor proc = new Processor(false);
final XQueryCompiler comp = proc.newXQueryCompiler();
final XQueryExecutable exp = comp.compile(mExpression);
final net.sf.saxon.s9api.XQueryEvaluator exe = exp.load();
exe.setSource(doc);
exe.run(destination);
} catch (final SaxonApiException e) {
LOGGER.error("Saxon Exception: " + e.getMessage(), e);
}
return destination;
So I'm not sure, basically I create a new configuration instance for the
DocumentInfo implementation (net.sf.saxon.Configuration).
greetings,
Johannes

>
> Thanks so the Exception isn't thrown anymore with the following code:
>
> final XdmDestination destination = new XdmDestination();
>
> try {
> final Processor proc = new Processor(false);
> final Configuration config = proc.getUnderlyingConfiguration();
> final NodeWrapper doc =
> (NodeWrapper) new DocumentWrapper(mSession, config, mTarget
> .getAbsolutePath()).wrap();
> final XQueryCompiler comp = proc.newXQueryCompiler();
> final XQueryExecutable exp = comp.compile(mExpression);
> final net.sf.saxon.s9api.XQueryEvaluator exe = exp.load();
> exe.setSource(doc);
> exe.run(destination);
> } catch (final SaxonApiException e) {
> LOGGER.error("Saxon Exception: " + e.getMessage(), e);
> }
>
> But it seems now a ArrayIndexOutOfBoundsException is thrown in
> TinyBuilder.makeTextNode(TinyBuilder.java:344) as running the
> XQueryEvaluator.
>
> I wonder what I've done that it tries to build a TinyTree
> instead of my own implementation of the DocumentInfo/NodeInfo
> interfaces.
The tree model used by an XdmDestination is determined by its TreeModel
property. In principle you can call setTreeModel() to make it use a
user-defined tree model, but I'm not sure this is something I have tested.
As for the exception: it's caused when you try to write a text node to an
XdmDestination without a containing document or element node. I'm not quite
sure of the status of this: I've fixed it in the development branch (to
raise a clean error, rather than trying to create the XdmDestination with
the parentless text node). I can't see any evidence that I raised a bug on
it, or fixed it in the 9.2 branch, however.
Regards,
Michael Kay
http://www.saxonica.com/http://twitter.com/michaelhkay

On Mon, 2010-03-22 at 04:01 +0100, Johannes Lichtenberger wrote:
> But it seems now a ArrayIndexOutOfBoundsException is thrown in
> TinyBuilder.makeTextNode(TinyBuilder.java:344) as running the
> XQueryEvaluator.
>
> I wonder what I've done that it tries to build a TinyTree instead of my
> own implementation of the DocumentInfo/NodeInfo interfaces.
It seems that XdmDestination uses the TinyTree object model per default.
So do I have to implement an object model or something? I'm actually
using our XML database system in conjunction with Cocoon and want to
write an XQueryGenerator.
Basically I want to query a Treetank file (shreddered XML file) and want
to create SAX events for the output of the query.
regards,
Johannes

>
> It seems that XdmDestination uses the TinyTree object model
> per default.
> So do I have to implement an object model or something? I'm
> actually using our XML database system in conjunction with
> Cocoon and want to write an XQueryGenerator.
>
> Basically I want to query a Treetank file (shreddered XML
> file) and want to create SAX events for the output of the query.
>
If you want SAX events as the output of your query, use a SAXDestination
rather than an XdmDestination.
But the recipient of SAX events might also have trouble coping with a SAX
stream representing a parentless text node.
Regards,
Michael Kay
http://www.saxonica.com/http://twitter.com/michaelhkay