First xml file in.xml:
<conf title="co" attr01="val01">
<c attr02="val02">
<Item key="db" attr03="val03">
<m1 />
<s>
<m2 />
<Item key="1">
<m3 />
<sp>
<Chart />
</sp>
</Item>
<m4 />
<Item key="2">
<sp>
<m5 />
<Chart />
</sp>
</Item>
<Item key="3">
<sp>
<Chart />
</sp>
</Item>
<m6 />
</s>
</Item>
</c>
</conf>
The second xml file profile.xml, which completes the first file with information about the widgets:
<p title="profile">
<c>
<Item key="db">
<s>
<Item key="1">
<sp>
<Chart>
<Widget title="widget12">
<Test title="test1"/>
</Widget>
</Chart>
</sp>
</Item>
<Item key="2">
<sp>
<Chart>
<Widget title="widget32">
<Test title="test3"/>
</Widget>
</Chart>
</sp>
</Item>
<Item key="3">
<sp>
<Chart>
<Widget title="widget54">
<Test title="test6"/>
</Widget>
</Chart>
</sp>
</Item>
</s>
</Item>
</c>
</p>
The profile.xml file differs from in.xml in that it has a different root tag name, each Chart tag has a corresponding child Widget tag, only parent tags relative to the Chart tag are present in the file and all tags except the root and Widget have only key attributes.
After the transformation, the resulting file differs from the original one only in the Widget child tags of the Chart tag:
<conf title="co" attr01="val01">
<c attr02="val02">
<Item key="db" attr03="val03">
<m1 />
<s>
<m2 />
<Item key="1">
<m3 />
<sp>
<Chart>
<Widget title="widget12">
<Test title="test1"/>
</Widget>
</Chart>
</sp>
</Item>
<m4 />
<Item key="2">
<sp>
<m5 />
<Chart>
<Widget title="widget32">
<Test title="test3"/>
</Widget>
</Chart>
</sp>
</Item>
<Item key="3">
<sp>
<Chart>
<Widget title="widget54">
<Test title="test6"/>
</Widget>
</Chart>
</sp>
</Item>
<m6 />
</s>
</Item>
</c>
</conf>
There is now an incomplete XSLT1.0 transformation file:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="fileName" select="'profile.xml'" />
<xsl:param name="updates" select="document($fileName)" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
How to rewrite the "p" template XSLT1.0?