p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: Error in function count()


Message #1 by "Nanda Kumar (RBIN/DBA-MST)" <Nanda.Kumar@i...> on Mon, 30 Jul 2001 07:43:32 +0200
thanks it is working..

Bye 
Nandu 

> -----Original Message-----
> From:	atruong@o... [SMTP:atruong@o...]
> Sent:	Monday, July 30, 2001 10:29 PM
> To:	P2P_XSLT
> Subject:	[xslt] RE: Error in function count()
> 
> I tried this transformation using several parsers: Xalan, Saxon & 
> Sablotron, and they all give this result:
> 
> Review of 4.5 = 2Review of 4 = 2
> 
> If you don't want to switch parsers, I'd try changing the syntax of the 
> stylesheet to see what's wrong with your parser. Here's a couple of 
> variations you can try:
> 
> Stylesheet:
> -----------
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
> <xsl:output method="text"/>
>  <xsl:template match="books">
>   <p>Review of 4.5 = <xsl:value-of select="count(book[review=4.5])"/></p>
>   <p>Review of 4 = <xsl:value-of select="count(book[review=4])"/></p>
>  </xsl:template>
> </xsl:stylesheet>
> 
> Stylesheet 2:
> -------------
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
> <xsl:output method="text"/>
>  <xsl:template match="/">
>   <p>Review of 4.5 = <xsl:value-of select="count(/books/book
> [review=4.5])"/></p>
>   <p>Review of 4 = <xsl:value-of select="count(/books/book
> [review=4])"/></p>
>  </xsl:template>
> </xsl:stylesheet>
> 
> > I have updated the system with MSXML3 and later executed the same code. 
> But
> > still i am not getting the result.
> > Please let me know whether i have to make any changes to this code ?
> > 
> > Thanks
> > Nandu
> > 
> > > -----Original Message-----
> > > From:	Michael Kay [SMTP:mhkay@i...]
> > > Sent:	Monday, July 30, 2001 2:50 PM
> > > To:	P2P_XSLT
> > > Subject:	[xslt] RE: Error in function count()
> > > 
> > > I think your code is correct but you are running it through MSXML2, 
> which
> > > doesn't support XSLT. Check the MSXML FAQ at 
> http://www.netcrucible.com/
> > > for
> > > details of how to install MSXML3.
> > > 
> > > Mike Kay
> > > Software AG
> > > 
> > > > -----Original Message-----
> > > > From: Nanda Kumar (RBIN/DBA-MST) [mailto:Nanda.Kumar@i...]
> > > > Sent: 30 July 2001 06:44
> > > > To: P2P_XSLT
> > > > Subject: [xslt] Error in function count()
> > > >
> > > >
> > > > Here is a XML and i am trying to retrive the total number of
> > > > books with
> > > > review 4.0 and 4.5. But while executing this i am able to
> > > > display only the
> > > > text part. i.e 'Review of 4.5 = ' and 'Review of 4.0 = ' . The count
> > > > function doesn't give any results.
> > > >
> > > > Kindly let me know the error in this xsl.
> > > >
> > > > Here is the XSL :
> > > >
> > > > <?xml version="1.0"?>
> > > >
> > > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > > > version="1.0">
> > > > 	<xsl:template match="/">
> > > > 		<p>Review of 4.5 = <xsl:value-of
> > > > select="count(books/book[review=4.5])"/></p>
> > > > 		<p>Review of 4 = <xsl:value-of
> > > > select="count(books/book[review=4])"/></p>
> > > > 	</xsl:template>
> > > > </xsl:stylesheet>
> > > >
> > > > Here is the XML :
> > > >
> > > > <books>
> > > >   <book>
> > > >     <name
> > > > link="http://www.amazon.com/exec/obidos/ASIN/0789722429/vbxml">XML
> > > > by Example</name>
> > > >     <author>Benoit Marchal</author>
> > > >     <listprice>24.99</listprice>
> > > >     <price>17.49</price>
> > > >     <review>4.5</review>
> > > >     <publish>QUE</publish>
> > > >   </book>
> > > >   <book>
> > > >     <name
> > > > link="http://www.amazon.com/exec/obidos/ASIN/1861003110/vbxml"
> > > > >Professional
> > > > XML</name>
> > > >     <author>Mark Birbeck, Michael Kay, stev Livingstone,
> > > > Stephen F. Mohr,
> > > > Didier Martin, Dino Esposito, Steven Livingston, Brian
> > > > Loesgen, Nikola Ozu,
> > > > Mark Seabourne</author>
> > > >     <listprice>49.99</listprice>
> > > >     <price>34.99</price>
> > > >     <review>4</review>
> > > >     <publish>Wrox</publish>
> > > >   </book>
> > > >   <book>
> > > >     <name
> > > > link="http://www.amazon.com/exec/obidos/ASIN/0735605629/vbxml">Xml
> > > > in Action</name>
> > > >     <author>William J. Pardi</author>
> > > >     <listprice>39.99</listprice>
> > > >     <price>31.99</price>
> > > >     <review>3.5</review>
> > > >     <publish>Microsoft Press</publish>
> > > >   </book>
> > > >   <book>
> > > >     <name
> > > > link="http://www.amazon.com/exec/obidos/ASIN/1861002289/vbxml">Xml
> > > > Design and Implementation</name>
> > > >     <author>Paul Spencer</author>
> > > >     <listprice>399.99</listprice>
> > > >     <price>31.99</price>
> > > >     <review>4</review>
> > > >     <publish>Wrox Press Inc</publish>
> > > >   </book>
> > > >   <book>
> > > >     <name
> > > > link="http://www.amazon.com/exec/obidos/ASIN/0201433354/vbxml">XML:
> A
> > > > Managers Guide</name>
> > > >     <author>Kevin Dick</author>
> > > >     <listprice>34.95</listprice>
> > > >     <price>29.95</price>
> > > >     <review>4.5</review>
> > > >     <publish>Addison-Wesley Pub Co</publish>
> > > >   </book>
> > > > </books>
> > > >
> > > >
> > > > Thanks in advance
> > > > Nandu

  Return to Index