Click to See Complete Forum and Search --> : Help on apply-templates


srihariacha
July 23rd, 2008, 12:10 PM
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="ProductData/Product">
</xsl:template>

<xsl:template match="ProductData/Product">
<font color="green">
<LI><xsl:apply-templates/></LI>
</font>
</xsl:template>


and the XML code is

<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="Product.xsl"?>
<ProductData>
<Product ProdID="1">
<ProductName>Curd Mixer</ProductName>
<Price>20</Price>
</Product>
<Product ProdID="2">
<ProductName>Milk Mixer</ProductName>
<Price>40</Price>
</Product>
</ProductData>


and the following error is displayed while opening in IE
Line: 4
Char: 3
Error: End tag 'xsl:template' does not match the start tag 'xsl:apply-templates'.
Code:0
URL:file....

compavalanche
July 23rd, 2008, 01:10 PM
The error says it all. You need to close your apply-templates tag.

Just add a '/>' at the end instead of just the '>'

srihariacha
July 23rd, 2008, 01:15 PM
I'm not sure where you want me to put the closing tag!

compavalanche
July 23rd, 2008, 04:30 PM
You have this.

<xsl:apply-templates select="ProductData/Product">

It needs to be this

<xsl:apply-templates select="ProductData/Product"/>

Or equivalently:
<xsl:apply-templates select="ProductData/Product">
</xsl:apply-templates>

Every <blah> tag has to be closed either inline with <blah /> or separately with <blah></blah>