Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] Converting nodes back into elements and documents.

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Furash Gary" <furashg AT mcao.maricopa.gov>
  • To: "Elliotte Harold" <elharo AT metalab.unc.edu>, <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: RE: [XOM-interest] Converting nodes back into elements and documents.
  • Date: Wed, 18 May 2005 08:09:49 -0700


First, thanks for putting together XOM. I've been using it for the past
day and am thoroughly impressed. It's easily the best XML library and
has my vote for incorporation into J2SE.

Second, okay... But here's what I'm trying. It's beanshell, so pretend
that I'm casting all the variables and doing try and catch (it doesn't
make any difference).


transformXml(xmlFile, xsltFile) {
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
builder = new Builder();
transform = new XSLTransform(builder.build(xsltFile));
output = transform.transform(builder.build(xmlFile));
doc = new Document(output);
return doc;
}

It errors out on the new Document line with

"Script: transformXmlTest.bsh produced an eval Error: Sourced file:
transformXmlTest.bsh : Constructor error: Can't find constructor:
nu.xom.Document( nu.xom.Nodes ) in class: nu.xom.Document : at Line: 32
: in file: /bshCommands/transformXml.bsh : new Document ( output )"

Which makes sense, an Element is a Kind of Node (not vice versa). So,
how do I turn those nodes into Elements so I can make an XML document.
I understand why the transformer doesn't return XML/Elements - because
an XSLT transform MIGHT not make an XML document (it could make
anything). But in this case it is.

G

Gary Furash, MBA, PMP
Applications Manager, Maricopa County Attorney's Office

-----Original Message-----
From: Elliotte Harold [mailto:elharo AT metalab.unc.edu]
Sent: Tuesday, May 17, 2005 3:57 PM
To: Furash Gary
Cc: xom-interest AT lists.ibiblio.org
Subject: Re: [XOM-interest] Converting nodes back into elements and
documents.

Furash Gary wrote:
>
> transform.transform(... applies a transformation and returns a tree of

> nodes. How do I turn those nodes into an XML elements.
>

What do you mean by "XML elements"? You can serialize these nodes the
same way you'd serialize any other node from XOM. there's nothing
special about them.


--
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