H
hzgt9b
I am a bit of a newbie to XSLT and am feeling my way around. Here is a
sample I found on the internet that I am trying to replicate on my
machine but am having problems. Specifically, the "<xsl:for-each-
group" element gets an error: "Keyword xsl:template may not contain
xsl:for-each-group ". I can find documentation for this element, so
I'm a bit lost as to the source of the problem. Anyone have any ideas.
See my XML ans XSL files below:
Thanks in advance,
celoftis
XML: (saved as test.xml)
----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<cities>
<city name="Williamsburg" state="Virginia" pop="11998" />
<city name="New York City" state="New York" pop="80000" />
<city name="Washington" state="DC" pop="553523" />
<city name="Richmond" state="Virginia" pop="300000" />
</cities>
XSL: (saved as test.xsl)
----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<table>
<xsl:for-each-group select="cities/city" group-by="@state"> <!--I can
see error on this line (I can't copy the tooltip contant, but it's
something like,'for-each-group' is invalid child element for template,
etc.....) -->
<tr>
<td><xsl:value-of select="@state" /></td>
<td>
<xsl:value-of select="current-group()/@name" separator=", " />
</td>
<td><xsl:value-of select="sum(current-group()/@pop)" /></td>
</tr>
</xsl:for-each-group>
</table>
</xsl:template>
</xsl:stylesheet>
sample I found on the internet that I am trying to replicate on my
machine but am having problems. Specifically, the "<xsl:for-each-
group" element gets an error: "Keyword xsl:template may not contain
xsl:for-each-group ". I can find documentation for this element, so
I'm a bit lost as to the source of the problem. Anyone have any ideas.
See my XML ans XSL files below:
Thanks in advance,
celoftis
XML: (saved as test.xml)
----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<cities>
<city name="Williamsburg" state="Virginia" pop="11998" />
<city name="New York City" state="New York" pop="80000" />
<city name="Washington" state="DC" pop="553523" />
<city name="Richmond" state="Virginia" pop="300000" />
</cities>
XSL: (saved as test.xsl)
----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<table>
<xsl:for-each-group select="cities/city" group-by="@state"> <!--I can
see error on this line (I can't copy the tooltip contant, but it's
something like,'for-each-group' is invalid child element for template,
etc.....) -->
<tr>
<td><xsl:value-of select="@state" /></td>
<td>
<xsl:value-of select="current-group()/@name" separator=", " />
</td>
<td><xsl:value-of select="sum(current-group()/@pop)" /></td>
</tr>
</xsl:for-each-group>
</table>
</xsl:template>
</xsl:stylesheet>