Harrie wrote:
[color=blue]
> but
> then I remembered the xsl:output 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">
>
> <xsl:output 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,[/color]
Really? xsl:copy-of will copy the element, its attribute and its child
nodes, then you additionallty use xsl:apply-templates to process the
child nodes again so you should got a lot of duplicated content that way.
[color=blue]
> but I cannot copy the DOCTYPE declaration (and
> XML declaration, but that's of less importance to me at this moment).[/color]
You can't copy those but you can output them with the xsl:output
instruction e.g.
<xsl:output omit-xml-declaration="no" />
<xsl:output encoding="utf-8" />
<xsl:output
doctype-public="public id here"
doctype-system="syste id here" />
Of course it will be a problem if you want to use one stylesheet to
indent lots of different XML documents with different doctype
declarations but if you know the doctype all those documents need then
you can make sure that is output with the above instruction.
In addition to that some XSLT processors have extensions, like Saxon 6
for instance
<http://saxon.sourceforge.net/saxon6.5.5/extensions.html#saxon:doctype>
to allow you to output doctype declarations.
--
Martin Honnen
http://JavaScript.FAQTs.com/