xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Adam Constabaris <adamc AT unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] XOM to DOM?
- Date: Tue, 21 Mar 2006 13:26:16 -0500
> I have my document in XOM and I need to get it into the DOM object model (so
> that I can unmarshal it using Castor). I tried the following:
> domParser = new DOMParser();
>
> domParser.parse(xmlOutputFromR.toString());
[ Note the Xerces DOMParser.parse() method expects the document's System ID (a string that points to the document's location), not the document's contents as a string ]
There's a DOMConverter class in the nu.xom.converters package for just this purpose. The only tricky part is that you have to supply a concrete W3C DOMImplementation object. A JAXP-friendly way to get a DOMImplementation object is illustrated in the unit tests for the DOMConverter class:
nu.xom.Document xomDoc;
// populate the XOM Document
// straight cut n' paste
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
builder = factory.newDocumentBuilder();
impl = builder.getDOMImplementation();
org.w3c.dom.Document domDoc = DOMConvertor.convert(xomDoc, impl);
HTH,
AC
-
[XOM-interest] XOM to DOM?,
Thomas A Hurley, 03/21/2006
- Re: [XOM-interest] XOM to DOM?, Adam Constabaris, 03/21/2006
Archive powered by MHonArc 2.6.24.