H
Harrie
Hi group,
I want to indent existing XML files so they are more readable (at least
to me). At this moment I'm looking at the XML files OpenOffice.org's
Writer application produces in it's zipped "SXW" format (and they're one
line, probably to save space, which I find hard to read). At first I
thought I was going to do it with sed/awk or something like that, but
then I remembered the xslutput element with the indent attribute of
XSL and this seems more natural to me. What I'm using now is this XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="*">
<xsl:copy-of select=".">
<xsl:apply-templates/>
</xsl:copy-of>
</xsl:template>
</xsl:stylesheet>
This works like a charm, but I cannot copy the DOCTYPE declaration (and
XML declaration, but that's of less importance to me at this moment).
I've done some Googling and found out that it's not posible using XSL
since the document type declaration is not part of the tree model of the
XML file.
http://www.biglist.com/lists/xsl-list/archives/200106/msg00585.html
I'm using xsltproc as XSL processor and I know you can pass arguments to
it, so I'm looking for a way to extract the PUBLIC and/or SYSTEM
identifier of an XML file with other tools and pass it as an argument to
xsltproc, so it can generate a DTD with the doctype-public and/or
doctype-system attributes of xslutput, but I'm not really sure how to
tackle this.
Has somebody already done something like this? Does someone have some
pointers for me?
I want to indent existing XML files so they are more readable (at least
to me). At this moment I'm looking at the XML files OpenOffice.org's
Writer application produces in it's zipped "SXW" format (and they're one
line, probably to save space, which I find hard to read). At first I
thought I was going to do it with sed/awk or something like that, but
then I remembered the xslutput element with the indent attribute of
XSL and this seems more natural to me. What I'm using now is this XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="*">
<xsl:copy-of select=".">
<xsl:apply-templates/>
</xsl:copy-of>
</xsl:template>
</xsl:stylesheet>
This works like a charm, but I cannot copy the DOCTYPE declaration (and
XML declaration, but that's of less importance to me at this moment).
I've done some Googling and found out that it's not posible using XSL
since the document type declaration is not part of the tree model of the
XML file.
http://www.biglist.com/lists/xsl-list/archives/200106/msg00585.html
I'm using xsltproc as XSL processor and I know you can pass arguments to
it, so I'm looking for a way to extract the PUBLIC and/or SYSTEM
identifier of an XML file with other tools and pass it as an argument to
xsltproc, so it can generate a DTD with the doctype-public and/or
doctype-system attributes of xslutput, but I'm not really sure how to
tackle this.
Has somebody already done something like this? Does someone have some
pointers for me?