Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Converting a nu.xom.Document to aorg.w3c.dom.Document

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Christophe Marchand <christophe.marchand AT axyus.com>
  • To: Michael Kay <mike AT saxonica.com>
  • Cc: 'XOM API for Processing XML with Java' <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Converting a nu.xom.Document to aorg.w3c.dom.Document
  • Date: Mon, 19 Oct 2009 17:10:40 +0200

Thanks for this, Michael, I now can divide by 10 (!) my print process for huge documents. I think I'm going to forget DOM since document size is bigger than 100Kb...

Best regards,
Christophe

Michael Kay a écrit :
The general rule in Saxon is that everything has to use the same NamePool - or at any rate, if things use different NamePools, then they must never interact. Generally that means they must use the same Configuration. Your TransformerFactory tf and your Processor are created independently of each other, therefore using different configurations, so you get a conflict. The rule is there to ensure that the integer name codes contained in the compiled XSLT are the same as the integer namecodes contained in the built instance document.
It would be best to do this all within s9api, so that everything derives from the same Processor. The alternative is to get the Configuration from the TransformerFactory, and use the methods on the Configurtation object to built the wrapped XOM document.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay


------------------------------------------------------------------------
*From:* Christophe Marchand [mailto:christophe.marchand AT axyus.com]
*Sent:* 19 October 2009 09:52
*To:* Michael Kay
*Cc:* 'XOM API for Processing XML with Java'
*Subject:* Re: [XOM-interest] Converting a nu.xom.Document to
aorg.w3c.dom.Document

Hi Michael,

Thanks for these entries, it helps !

I encounter a strange exception :
java.lang.IllegalArgumentException: Externally supplied NodeInfo
belongs to the wrong Configuration
at net.sf.saxon.Configuration.unravel(Configuration.java:2695)
at
net.sf.saxon.Controller.prepareInputTree(Controller.java:1664)
at net.sf.saxon.Controller.transform(Controller.java:1589)

My code looks like this :

Builder parser = new Builder();
Document doc = parser.build(inputFile);
net.sf.saxon.s9api.DocumentBuilder s9DomBuilder = new
Processor(false).newDocumentBuilder();
XdmNode s9tree = s9DomBuilder.wrap(doc);
Controller tt = (Controller)tf.newTransformer(new
StreamSource(openStream(new URL(xslUrl))));
tt.setParameter("nomenclaturePasEnrichie", nomenclature);
DOMResult domResult = new DOMResult();
tt.transform(s9tree.asSource(), domResult);

Any idea ?

Thanks in advance,
Christophe


Michael Kay a écrit :
Not much available, I'm afraid, by way of sample code.
If you're using the s9api interface, you can wrap a XOM document
using DocumentBuilder.wrap(document), and the resulting XdmNode
can be used as input to a transformation or query.
If you're using the JAXP interface, use new
net.sf.saxon.xom.DocumentWrapper(document), and the resulting
NodeInfo implements the JAXP Source class and can therefore be
used as transformation input.
Note that for a complex transformation, working from the wrapped
XOM document isn't always optimal; it's sometimes better to copy
the data across to a Saxon TinyTree, which you can do with
DocumentBuilder.build().
Michael Kay
Saxonica


------------------------------------------------------------------------
*From:* Christophe Marchand
[mailto:christophe.marchand AT axyus.com]
*Sent:* 16 October 2009 13:36
*To:* Michael Kay
*Cc:* 'XOM API for Processing XML with Java'
*Subject:* Re: [XOM-interest] Converting a nu.xom.Document to
aorg.w3c.dom.Document

Hi Michael,

thanks for your responses (including those on XPath).

Do you have some links on examples on using Saxon wrappers on
XOM objects ?

Thanks a lot in advance,
Christophe

Michael Kay a écrit :
If you run the transformation using Saxon interfaces, you can supply
a XOM
document (wrapped in a Saxon-supplied wrapper) as the input to the
transformation, and supply a DOMResult as the destination.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: xom-interest-bounces AT lists.ibiblio.org [mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of Christophe Marchand
Sent: 14 October 2009 14:45
To: xom-interest AT lists.ibiblio.org
Subject: [XOM-interest] Converting a nu.xom.Document to aorg.w3c.dom.Document

Hi,

is there a way to convert a nu.xom.Document to a DOM Document ?

After a XSL Transform, I need to give the result to Flying Saucer, which uses DOM. I would like to avoid a serialization / parsing...

Another question : as transform alway produces a Nodes, there is no way to produce html, isn't it ?

Regards,
Christophe
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest







Archive powered by MHonArc 2.6.24.

Top of Page