I have this following xslt. I notice that sometimes the element name 'tuple' has an attribute. I want to remove the attribute and add it as an Element. I added a test to verify if 'tuple' has an attribute but it returns a blank 'ecatalogue' element.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="atom">
<xsl:element name="{@name}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="table">
<xsl:element name="{@name}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<!--this test doesn't work properly -->
<xsl:template match="tuple">
<xsl:choose>
<xsl:when test="@name">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<!-- nothing to do
the node should stay the same
-->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- end test -->
</xsl:stylesheet>
result I had with this template above.
<ecatalogue>
</ecatalogue>
No comments:
Post a Comment