xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Creating a Document from the result of an XSLT transformation
- From: Benja Fallenstein <b.fallenstein AT gmx.de>
- To: elharo AT metalab.unc.edu
- Cc: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] Creating a Document from the result of an XSLT transformation
- Date: Wed, 03 Mar 2004 10:41:18 +0200
Dear Elliotte,
(Maybe this came up in the past but a cursory search of the archives didn't turn up discussion of this.)
First of all, thanks for your work on XOM. (I've just recently used it for the first time, and finally, there's a tree-based XML API I can understand ;-))
I've been using XSLTransform to transform a document into another document. However, the result type of XSLTransform.transform() is Nodes. This makes sense as applying an XSLT stylesheet may produce a node set with more than one "root element."
However, if I know that the result I want is a document, is there some easy way to create a Document object? So far I'm assuming that the Nodes contains a single Element, which I use as the root of a Document, but this seems flawed since besides the Element there may be processing instructions etc.
Am I missing something?
I've thought about this, and if I'm not in fact missing something, what to me seems to be the "natural" way of doing this is to have a constructor for Document that takes a Nodes object, and, obviously, throws an error if there is more than one Element in it. Then I could write
doc = new Document(stylesheet.transform(doc));
and catch the appropriate error to handle cases where the result is in fact not a document.
Of course I *could* myself write some code that converts the Nodes to a Document properly, it just seems so counter-intuitive and the wrong place to do it. But perhaps that's just me?
Thanks,
- Benja
-
[XOM-interest] Creating a Document from the result of an XSLT transformation,
Benja Fallenstein, 03/03/2004
-
Re: [XOM-interest] Creating a Document from the result of an XSLT transformation,
Elliotte Rusty Harold, 03/11/2004
- Re: [XOM-interest] Creating a Document from the result of an XSLT transformation, Benja Fallenstein, 03/11/2004
-
Re: [XOM-interest] Creating a Document from the result of an XSLT transformation,
Elliotte Rusty Harold, 03/11/2004
Archive powered by MHonArc 2.6.24.