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: Peter Murray-Rust <pm286 AT cam.ac.uk>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] User Questions
  • Date: Tue, 02 Aug 2005 08:46:41 +0100

On Mon, 2005-08-01 at 16:30 -0700, Wolfgang Hoschek wrote:

Thank you for the quick and useful reply

> > * 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.
>
This makes much more sense than the W3C approach where the Document
seemed to have undue importance and had to be accessible at many places
in the code. It seems that other than holding the prolog and managing
overall serialization it is not normally needed explicitly. That will
certainly simplify my code a lot.

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

Again this makes sense - I have learnt bad habits (and fear) through the
W3C approach to namespaces. I now think I shall learn to love them as
XOM seems to provide exactly the right approach. I particularly like
being gently coerced to do the correct thing.

> (I have a Nux ResultSequenceSerializer.write(Nodes) that works around
> those potential problems without requiring copying, though it's not
> yet released.)
>

Yes. I have always wondered why the W3C did not provide a serializer -
it seemed such an obvious component.

P.

> .
--
Peter Murray-Rust
Unilever Centre for Molecular Informatics,
Department of Chemistry, University of Cambridge
Cambridge, CB2 1EW, UK
Tel: +44-1223-760369





Archive powered by MHonArc 2.6.24.

Top of Page