[XOM-interest] A small request
Elliotte Rusty Harold
elharo at metalab.unc.edu
Tue Jan 6 20:10:38 EST 2004
At 3:41 PM -0800 1/6/04, dirk bergstrom wrote:
>I know that you're opposed to spurious convenience methods, but I think that
>the effort required to implement the solution is sufficiently high (19
>lines), that it would be worthwhile.
It's not merely the effort to implement it. It's the effort to
understand it. I think the complexity of a class's API is more than
linear in the number of public methods. I've seen this in JDOM where
at least some versions have had lots of little, picky methods to set
every possible option and combination thereof that differed from each
other in very minute, not always obvious ways. (The latest version of
JDOM is a little better, but not clean enough yet for my tastes.)
I also don't think your use-case is common. This is the first time
I've heard of a request for it. So I'm not going to add it to the
core API. There are some other options for you though:
1. You can set a maxLength and an indent and then add an
xml:space="preserve" attribute to all elements where you don't want
an internal break to appear. Even when indenting and wrapping the
Serializer will not change the white space inside an element with
xml:space="preserve" (Or if it does, that's a bug I need to fix.
2. You can write your own subclass of Serializer that provides the
methods and behavior you need.
3. You can use nu.xom.samples.WrappingSerializer. This follows John
Cowan's suggestion of a Serializer subclass that can be configured to
pretty print without changing its infoset. That is, it only adds
white space in the prolog, epilog, and inside tags. Just be warned
that I make no promises about the stability of classes in the sampels
package, and they have not been heavily tested like the classes in
the core, so they may well have bugs.
--
Elliotte Rusty Harold
elharo at metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA
More information about the XOM-interest
mailing list