Hi,
I have an xml :
<DataRecords>
<Point Alias='A' Value='1' Status='0' />
<Point Alias='B' Value='2' Status='0' />
</DataRecords>
I have needed by an XSL to insert a node between <DataRecords> and <Point>
Example :
<DataRecords>
<Record>
<Point Alias='A' Value='1' Status='0' />
</Record>
<Record>
<Point Alias='B' Value='2' Status='0' />
</Record>
</DataRecords>
Can anyone help me?
Thanks
Beni
Martin Honnen - 10 Sep 2004 12:39 GMT
> I have an xml :
>
[quoted text clipped - 14 lines]
> </Record>
> </DataRecords>
Simply use the identity transformation and add one template for <Point>
elements that wraps them into a <Record> element:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Point">
<Record>
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</Record>
</xsl:template>
</xsl:stylesheet>

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
Randal Chapman - 10 Sep 2004 17:53 GMT
> <DataRecords>
> <Point Alias='A' Value='1' Status='0' />
> <Point Alias='B' Value='2' Status='0' />
> </DataRecords>
> <DataRecords>
> <Record>
[quoted text clipped - 4 lines]
> </Record>
> </DataRecords>
<xsl:for-each select="DataRecords/Point">
<xsl:text disable-output-escaping="yes"><Record></xsl:text>
<Point>
<xsl:attribute name="Alias"><xsl:value-of select="@Alias" /></xsl:attribute>
<xsl:attribute name="Value"><xsl:value-of select="@Value" /></xsl:attribute>
<xsl:attribute name="Status"><xsl:value-of select="@Status" /></xsl:attribute>
<xsl:text disable-output-escaping="yes"></Record></xsl:text>
</xsl:for-each>
_Randal