You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rohit Bhalerao <ro...@hotmail.com> on 2001/04/11 15:13:31 UTC
xml sorting and counting
hi there!
I want to count the number of elements in my xml..
I am using the xml file like this..
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="testcount.xsl" type="text/xsl" ?>
<root>
<foo>
<bar>bard</bar>
<bar>bark</bar>
</foo>
<foo>
<bar>bark</bar>
<bar>barb</bar>
</foo>
</root>
and the xsl is
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="//bar">
<xsl:variable name="value" select="."/>
<xsl:if test="count(preceding::bar[.=$value]) = 0">
<xsl:value-of select="."/><xsl:text> : </xsl:text>
<xsl:value-of select="count(//bar[.=$value])"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
its giving me exception like
org.apache.xalan.xslt.XSLProcessorException: Warning: can't output text
before document element! Ignoring...
.
.
.
.
Please tell me where I am going wrong?? if I am making some basic mistake
please correct me.
Thanks a lot in advance,
Rohit
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>