xsl-list
[Top] [All Lists]

Re: pretty-printing XML

2003-03-26 11:36:49
I like the way this stylesheet works under Saxon.  It doesn't do much for me
with other XSL processors such as Xalan and msxsl, though.  I don't know
what it would do with your XML comments.  I suspect this may fall into your
long list of stylesheets that don't do the job.  It has the one advantage of
being simple.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
   <xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

Randy Oxentenko

----- Original Message -----
From: "Lars Huttar" <lars_huttar(_at_)sil(_dot_)org>
To: "XSL-List (E-mail)" <XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, March 26, 2003 12:06 PM
Subject: [xsl] pretty-printing XML


Dear XSL users,
I'm looking for a way to nicely print out my XML data.
I've looked at a few XSL stylesheets that claim to pretty-print XML,
but they don't seem to do what I want.  In particular, my XML has
lots of very long comment lines, which I would like to be wrapped
to a sensible line length, and indented with a hanging indent like this:

  <!-- blah blah
    blah blah
    blah blah -->

I've tried using Emacs XML modes to wrap them using sgml-fill-element;
I've tried the Physiome Languages XML Pretty Printer, the DecisionSoft
online pretty printer, and others.
The latter indents comments well but starts them all at the left margin,
no matter how deeply they're nested.  It also breaks the line whenever
the comment mentions an <element> and goes back to the left margin.
The former doesn't seem to indent elements based on their nesting depth.
Mark Brown and Jeni Tennison's XML tree pretty printer is useful, but
displays the tree rather than the XML text itself.
"Tidy" doesn't seem to wrap long lines when it should.

What I have had success with is using XMLSpy to print the XML, which
puts it in sort of a table view.  However my trial period for XMLSpy
has expired.  I've decided I'm willing to purchase it, if only for
printing, but I thought I'd ask you folks first.

What do you use for printing out your XML data, so you can look at it
offline?  A stylesheet?  Other free software?

Thanks,
Lars


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>