J
John Bailo
Given this XML:
<?xml version="1.0" encoding="UTF-8"?>
<pallet>
<position row="0" bay="0" level="A">
<client id="ABC"></client>
</position>
<position row="1" bay="1" level="B">
<client id="DEF"></client>
</position>
<position row="1" bay="1" level="C">
<client id="GHI"></client>
</position>
</pallet>
I want to return a subset,
<pallet>
<position row="0" bay="0" level="A">
<client id="ABC"></client>
</position>
</pallet>
But I can't seem to extend my stylesheet to something 3 nodes deep.
This:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl
utput method="xml"/>
<xsl:template match="/">
<pallet>
<xsl:apply-templates select="pallet/position"/>
</pallet>
</xsl:template>
<xsl:template match="pallet">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="position[@row=0]">
<position>
<xsl:attribute name="row">
<xsl:value-of select="@row"/>
</xsl:attribute>
<xsl:attribute name="bay">
<xsl:value-of select="@bay"/>
</xsl:attribute>
<xsl:attribute name="level">
<xsl:value-of select="@level"/>
</xsl:attribute>
</position>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
will return
<?xml version="1.0" encoding="UTF-16"?>
<pallet>
<position row="0" bay="0" level="A" />
</pallet>
But say I want to extend it to return:
<?xml version="1.0" encoding="UTF-16"?>
<pallet>
<position row="0" bay="0" level="A" />
<client id="ABC">
</client>
</pallet>
How do I do that?
<?xml version="1.0" encoding="UTF-8"?>
<pallet>
<position row="0" bay="0" level="A">
<client id="ABC"></client>
</position>
<position row="1" bay="1" level="B">
<client id="DEF"></client>
</position>
<position row="1" bay="1" level="C">
<client id="GHI"></client>
</position>
</pallet>
I want to return a subset,
<pallet>
<position row="0" bay="0" level="A">
<client id="ABC"></client>
</position>
</pallet>
But I can't seem to extend my stylesheet to something 3 nodes deep.
This:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl
<xsl:template match="/">
<pallet>
<xsl:apply-templates select="pallet/position"/>
</pallet>
</xsl:template>
<xsl:template match="pallet">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="position[@row=0]">
<position>
<xsl:attribute name="row">
<xsl:value-of select="@row"/>
</xsl:attribute>
<xsl:attribute name="bay">
<xsl:value-of select="@bay"/>
</xsl:attribute>
<xsl:attribute name="level">
<xsl:value-of select="@level"/>
</xsl:attribute>
</position>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
will return
<?xml version="1.0" encoding="UTF-16"?>
<pallet>
<position row="0" bay="0" level="A" />
</pallet>
But say I want to extend it to return:
<?xml version="1.0" encoding="UTF-16"?>
<pallet>
<position row="0" bay="0" level="A" />
<client id="ABC">
</client>
</pallet>
How do I do that?