Trying to solve an issue for someone else and instead have run into my own odd issue which I am sure is simple yet the answer is eluding me!
The XML I have:
<xml>
<head>
<info>
<content>
<source attribute1="RSC1985s5c1" attribute2="6(17)">
data1
</source>
<cite/>
<case/>
(
<target attribute1="LRC1985s5c1" attribute2="6(17)1">
3e/191
</target>
)
</content>
<content>
<source attribute1="RSC1985s5c1" attribute2="6(17)">
data2
</source>
<cite/>
<case/>
(
<target attribute1="LRC1985s5c4" attribute2="6(17)1">
4e/54
</target>
)
</content>
</info>
</head>
</xml>
With XSLT to combine the two content elements:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="info">
<xsl:copy>
<xsl:element name="content">
<xsl:for-each select="content">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:for-each>
</xsl:element>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This creates:
<?xml version="1.0" encoding="utf-8"?><xml> //Just noticed here too!
<head>
<info><content> //Why no new line here?
<source attribute1="RSC1985s5c1" attribute2="6(17)">
data1
</source>
<cite />
<case />
(
<target attribute1="LRC1985s5c1" attribute2="6(17)1">
3e/191
</target>
)
<source attribute1="RSC1985s5c1" attribute2="6(17)">
data2
</source>
<cite />
<case />
(
<target attribute1="LRC1985s5c4" attribute2="6(17)1">
4e/54
</target>
)
</content></info> //And again here?
</head>
</xml>
The issue highlighted using commenting is what I cannot figure out, why there is no new line between the elements.
Thanks in advance.
With the provided transformation slightly modified:
I get with Saxon 6.5.5 and a number of other XSLT 1.0 processors a well-indented output:
Some XSLT processors may still produce unwanted-indentation — there is no strict standard in the W3C XSLT 1.0 recommendation how exactly indentation should be performed.