Hello everybody, I know little about XSLT, but i need a very simple thing. Basically i need to format (indent) an xml file. This transformation already does everything i need:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:patchv2="http://patchv2.dnbgp.dnb.com/schema/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml"/>
<xsl:param name="indent-increment" select="' '" />
<xsl:template match="*">
<xsl:param name="indent" select="'
'"/>
<xsl:value-of select="$indent"/>
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates>
<xsl:with-param name="indent" select="concat($indent, $indent-increment)"/>
</xsl:apply-templates>
<xsl:if test="*">
<xsl:value-of select="$indent"/>
</xsl:if>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()|processing-instruction()">
<xsl:copy />
</xsl:template>
<!-- WARNING: this is dangerous. Handle with care -->
<xsl:template match="text()[normalize-space(.)='']"/>
</xsl:stylesheet>
The problem though is that this works fine for simple xml (no workspace....), but my xml file:
Code:
<patchv2:patchList xmlns:patchv2="http://patchv2.dnbgp.dnb.com/schema/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ci-dnbi.us.dnb.com/standards/schema/patchv2-2.0.2.xsd" xsi:schemaLocation="http://patchv2.dnbgp.dnb.com/schema/2.0.0 http://ci-dnbi.us.dnb.com/standards/schema/patchv2-2.0.2.xsd">
<patchv2:patchEntry>
<patchv2:patchVersion>RT60.2NA2A</patchv2:patchVersion>
</patchv2:patchEntry>
...
</patchv2:patchList>
gets tranformed (indented correctly) to:
Code:
<patchList xmlns:patchv2="http://patchv2.dnbgp.dnb.com/schema/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ci-dnbi.us.dnb.com/standards/schema/patchv2-2.0.2.xsd" xsi:schemaLocation="http://patchv2.dnbgp.dnb.com/schema/2.0.0 http://ci-dnbi.us.dnb.com/standards/schema/patchv2-2.0.2.xsd">
<patchEntry>
<patchVersion>RT60.2NA2A</patchVersion>
</patchEntry>
...
</patchList>
Can someone helps me to change the transformation so it will keep the patchv2: bit? Thank you.....