You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by William Flanders <fl...@denalisoft.com> on 2000/07/27 20:07:17 UTC

XML Serializer Pretty Print?

This may be an ongoing issue, and from what I've read of the
mailing list archives, I can't seem to get a resolution to it.

I'd like to print out an XML document in a human readable
way, and have certain text nodes be marked as whitespace
preserving, but not all of them.

The utility "tidy" produces about what I'm looking for.

Example input:

<doc><tag1 a="b" c="d"> text text text </tag1>
<tag2 a="b" c="d" xml:space = "preserve">
this
should
be 
preserved
</tag2></doc>

XMLSerializer's output(roughly):

<doc>
  <tag1 a = "b"
  c = "d"> text text text </tag1>
  <tag2 a = "b"
  c = "d"> this should be preserved</tag2></doc>

The output I'm looking for:

<doc>
  <tag1 a = "b" c = "d"> 
     text text text
  </tag1>
  <tag2 a = "b" c = "d" xml:space = "preserve">
this
should
be
preserved
  </tag2>
</doc>


I've inserted some tracing into XMLSerializer to figure out why
xml:space=preserve doesn't work at the very least, and I've
found that startElement() is never called.  I grepped through the
serialize package, and I've found that there is never a call
to that method, period.

How have other people handled this?  It's difficult to even
debug my XML-oriented code without a proper serializer...
Should I write my own?

Thanks,

Bill