Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Subclassing Serializer

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Subclassing Serializer
  • Date: Mon, 07 Oct 2002 12:08:35 -0400

I've been looking at how much a subclass of Serializer should be able to do and actually can do. The speciifc context is an effort to write a Serializer subclass that outputs canonical XML. Here's what I've discovered:

1. It is possible for subclasses to filter entire nodes as they're serialized. That is, it can replace elements, modify text, strip out comments, add comments, and so forth.

2. It is not currently possible to change the way data is output at sub-node level. For instance, the subclass cannot choose to lexically order the attributes as required by canonical XML or decide what does and does not go into a CDATA section.

As a result of 2, a CanonicalXMLSerializer would need to basically reimplement every method in the superclass, up to the point of maintaining its own OutputStrea. There would be essentially no implementation reuse, only interface reuse.

Is this a problem? Are there other, plausible use-cases where a subclass would want more control of the output? If so, should this be provided by publically exposing the TextWriter class or by adding delegating protected methods to Serializer such as

protected void writeMarkup(String s)
protected void writePCDATA(String s)

An additional advantage of exposing TextWriter publically is that it might make it possible for third parties to add support for additional encodings in their own applications (by subclassing TextWriter) without having those added to the nu.xom package.

I can see at least three sides to this question. Thoughts and comments are appreciated.

--
Elliotte Rusty Harold





Archive powered by MHonArc 2.6.24.

Top of Page