[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Counting records

Subject: Counting records
From: "Bradley, Peter" <pbradley@xxxxxxxxxx>
Date: Mon, 8 Dec 2008 16:06:58 -0000
 Counting records
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.