This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: Any good XML pretty printing tools?
- From: Norman Walsh <ndw at nwalsh dot com>
- To: Stefan Bylund <steby at enea dot se>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Thu, 16 Jan 2003 21:11:20 -0500
- Subject: DOCBOOK-APPS: Re: Any good XML pretty printing tools?
- References: <3E26B9F1.6257B31F@enea.se>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
/ Stefan Bylund <steby@enea.se> was heard to say:
| Does anybody know if there are any good command-line driven XML pretty printing
| tools out there? Preferably, one should be able to configure the indentation
| width and maximal line length.
This works for me.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
exclude-result-prefixes="saxon"
version="1.0">
<xsl:output method="xml" indent="yes"
saxon:indent-spaces="2"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()">
<xsl:if test="not(preceding-sibling::node()[1][self::comment()])">
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:copy/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="processing-instruction()">
<xsl:if test="not(preceding-sibling::node()[1][self::processing-instruction()])">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:copy/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
Be seeing you,
norm
- --
Norman Walsh <ndw@nwalsh.com> | The things we have most longed for
http://www.oasis-open.org/docbook/ | do not happen; or if they do, it
Chair, DocBook Technical Committee | is never at the time nor under the
| circumstances when they could have
| made us happiest.--La Bruyère
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/>
iD8DBQE+J2ZIOyltUcwYWjsRAkjqAKCbXNbUvD2/SI5J7Aua8h0CB1i1+QCcDJHO
UEduJWnBK427Ox48yd9+kxk=
=RoWW
-----END PGP SIGNATURE-----