Re: [xsl] Schema-aware pretty-printing

Subject: Re: [xsl] Schema-aware pretty-printing
From: Graydon <graydon@xxxxxxxxx>
Date: Wed, 21 Dec 2011 22:25:27 -0500
On Wed, Dec 21, 2011 at 09:48:59PM -0500, Murray McDonald scripsit:
> A web search seems to indicate that OXygen is capable of doing an
> intelligent pretty-print (the information I found is in the context of XHTML
> but I assume it's more generalized than that??), however, I can't really
> justify buying it just for that.

Oxygen's format-and-indent is fully general in as much you can tell
oXygen which arbitrary elements are preserve-space and in that the
contents of mixed-content elements gets left in an unindented state.

> If needs be, I can write an XSLT to parse a DTD, classify each element as
> "inline", "mixed", "block" or "empty" and then do an identity transform
> against my XML source files inserting line-breaks and leading tabbing as
> required.
> 
> I am wondering if anyone else has any other suggestions for me?

I can't imagine doing any significant amount of XSLT programming
_without_ using oXygen; I also can't imagine that you won't get your
purchase price back in saved time _just with this problem_, never mind
the subsequent year.

The other solution is to not try to hand-edit the PIs in place;
presumably you can identify their location with very specific XPath, the
kind that has position numbers after every element down from the root,
and mechanically insert them via XSLT.  The one-template-per-path
approach plus copy-constructor has the virtues of extending nicely and
repeatability but also the fault of requiring you to identify all those
locations precisely.

-- Graydon

Current Thread