Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] feature request: being able to specify the NodeFactory for DomConverter

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Steve Loughran <steve.loughran AT gmail.com>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] feature request: being able to specify the NodeFactory for DomConverter
  • Date: Sat, 14 Jan 2006 08:48:52 -0500

Steve Loughran wrote:
I'm trying to convert a w3c.dom.Document into a xom one, but need to
pass in my own node factory.

there isnt any option to pass one down, nor can I easily tack one in
by a bit of subclassing, as the DomConverter doesnt use a node factory
and doesnt have a method createNodeFactory() that I could have
overridden.


DOMConverter in CVS now contains a couple of methods that will allow you to supply a NodeFactory when converting documents and document fragments from DOM to XOM.

public static Document convert(org.w3c.dom.Document domDocument, NodeFactory factory)
public static Nodes convert(org.w3c.dom.DocumentFragment fragment, NodeFactory factory)

Please try this out and see if it works for you. Also, anyone else whose using the DOMConverter may want test their code with this to see if I accidentally broke it. The internal changes have been quite significant.

I'm also curious about thoughts on the API. One definite possibility is making both methods return a Nodes object rather than a document. As is, some of the trickier node factories can prevent the conversion by returning the wrong thing in the wrong place. However simple cases should work.

If this case had come up in the 1.0 time frame it might have convinced me to make the convert methods instance methods instead of static methods. However I'm hesitant to make that change now.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page