Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] User Questions

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Peter Murray-Rust <pm286 AT cam.ac.uk>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] User Questions
  • Date: Mon, 1 Aug 2005 16:30:22 -0700

* What is the role of a Document (it is much less central than in W3C).
Obviously it holds the prolog, etc.

In DOM a Document acts as factory, in XOM it doesn't.

I note that it cannot be detached
from its rootElement. (I sometimes need to replace a rootElement with
its child, and this seems to be forbidden without copying the tree.

It works via child.detach(), followed by doc.setRootElement(child).
This ends up detaching the former root element. Moving nodes around is easier in XOM than in DOM.

* Is is possible to serialize a Node other than document without making
a copy?

You can subclass Serializer go gain access to its protected methods such as writeNode().
Note, however that if you are using namespaces, you may (or may not) be in trouble as
the XOM Serializer assumes that an entire document is written, rather than arbitrary
subtrees. Thus, when serializing arbitrary nodes it can potentially "forget" to output namespace declarations, resulting in malformed output.
(I have a Nux ResultSequenceSerializer.write(Nodes) that works around those potential problems without requiring copying, though it's not yet released.)

Wolfgang.




Archive powered by MHonArc 2.6.24.

Top of Page