Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Maintaining a count of records >Thread Next - Re: Maintaining a count of records RE: Maintaining a count of recordsTo: NULL Date: 10/5/2004 3:39:00 AM Hi Stanley,
Please try this...
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/RecordSet">
<html>
<head>
<title/>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<xsl:apply-templates select="Record" />
</table>
Number of records: <xsl:value-of select="count(Record)" />
</body>
</html>
</xsl:template>
<xsl:template match="Record">
<tr>
<td><xsl:value-of select="Name" /></td>
<td><xsl:value-of select="Age" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Variables in XSLT are immutable(cannot be changed) because XSLT is designed
to be a side-effect free language(its a functional language). Allowing
variables to change introduces side-effect..
Regards,
Mukul
"Stanley Beamish" wrote:
> Hello,
>
> Is it possible to do the following: I have a XML document that contains a
> list of records, for eg.
>
> <RecordSet>
> <Record>
> <Name>Fred</Name>
> <Age>32</Age>
> </Record>
> <Record>
> <Name>Fanny</Name>
> <Age>64</Age>
> </Record>
> </RecordSet>
>
> I want to apply a transformation to this turning it into a table, and after
> the table listing how many records were returned. To do this I thought I
> could use a variable to maintain a count - but variables are immutable
> (why????). Can anyone suggest a way of doing this, or is it beyond xslt?
>
> Thanks for your attention.
>
> Stanley.
>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
