[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Counting records
Subject: [xsl] Counting records From: "Bradley, Peter" <pbradley@xxxxxxxxxx> Date: Mon, 8 Dec 2008 16:06:58 -0000 |
Hi, I have a requirement to count the number of rows in an XML result set returned from a database. The result set can be empty, in which case the returned XML will look like this: <?xml version="1.0" encoding="utf-16"?> <HesaValidate_Response xmlns="http://HesaValidateSqlSend"> </HesaValidate_Response> If any rows are returned they will look like the following: <?xml version="1.0" encoding="utf-16"?> <HesaValidate_Response xmlns="http://HesaValidateSqlSend"> <row instance_no="1 " hesa_prog_id="6612" personal_id="07004871" surname="Aaaaa " forenames="Aaaa " prog_id="6612" mode_id="5" year_id="1" occurrence="01" full_title="Postgraduate Certificate Professional Practice: Additional Learning Needs in Education " error_message="Blank HESA No/Instance No/HESA Programme" /> <row instance_no="1 " hesa_prog_id="6612" personal_id="07004872" surname="Bbbbbb" forenames="Bbbbbb " prog_id="6612" mode_id="5" year_id="1" occurrence="01" full_title="Postgraduate Certificate Professional Practice: Additional Learning Needs in Education " error_message="Blank HESA No/Instance No/HESA Programme" /> <row hesa_no="0710890036741" instance_no="1 " personal_id="07003686" surname="Ccccc " forenames="Ccccc " prog_id="9041" mode_id="1" year_id="1" occurrence="01" full_title="BSc (Hons) Sport Management " error_message="Blank HESA No/Instance No/HESA Programme" /> </HesaValidate_Response> I've tried to do this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:variable name="RowCount" select="count(//row)"/> The number of rows is: <xsl:value-of select="$RowCount"/> </xsl:template> </xsl:stylesheet> I probably don't need the variable, but I'm just using what I know. The problem is that this always returns zero: as does count(/HesaValidate_Response/row), and count(row); which I suppose is to be expected if //row does. Anyway, I'm obviously missing something incredibly obvious. If someone could point out to me what it is, I'd be grateful. Thanks Peter
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML to XML Namespace conv, Martin Honnen | Thread | Re: [xsl] Counting records, Martin Honnen |
RE: [xsl] XML to XML Namespace conv, Michael Kay | Date | Re: [xsl] removing nodes to parent , Cindy Lard |
Month |
Keywords