Transform xml to html adding or changing particular xml nodes and
corresponding attributes. The whole work must be done in the xsl itself.
- The Html result:
<p>1</p>
<p>2</p>
<p code="cc" price="33">C</p>
<p>3</p>
- The Html desired transformation result:
<p>1</p>
<p>2</p>
<p>33</p>
- The xml:
<?xml version="1.0" encoding="UTF-8"?>
<Features>
<Feature code="a" price = "1"></Feature>
<Feature code="b" price = "2"></Feature>
<Feature code="c" price = "3"></Feature>
</Features>
- The xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Feature[@code='c']">
<p code="cc" price="33">C</p>
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="//Feature"/>
</xsl:template>
<xsl:template match="Feature">
<xsl:apply-templates select="@price"/>
</xsl:template>
<xsl:template match="@price">
<p><xsl:value-of select="."/> </p>
</xsl:template>
</xsl:stylesheet>
I appreciate any instructions