Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2004, 03:51 PM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Counting node-set children in template

I have been using the xsltproc parser (part of GNOME's libxslt), and have run into an interesting problem.

When I try to execute a template returning a node-set, I try to execute a count() on the returned variable. This invariably gives me 1, which is not the desired answer; I need a count of particular nodes in the subset.

(My XSL stylesheet is not doing direct processing, but instead looping through the initial document to create specific pairings. It's a medical billing application.)

Here's an example of some of the code fragments that are causing trouble (I'm using EXSLT for some of the set functions):

      <xsl:variable name="subset">
             <xsl:call-template name="get-valid-diagnosis-set">
                      <xsl:with-param name="procedureset">
                             <xsl:value-of select="$set" />
                      </xsl:with-param>
             </xsl:call-template>
      </xsl:variable>

      <xsl:variable name="remaining" value="set:difference($set, $subset)" />
      <debug><xsl:text>remaining: </xsl:text><xsl:value-of select="count($remaining)"/></debug>

Thanks,
Jeff
([email protected])
FreeMED Software Foundation
http://freemedsoftware.com/
 
Old May 1st, 2004, 12:20 AM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not in front of my work system at the moment
but I believe that set:diference may be returning
a result tree fragment rather than a node-set. If
this is the case you will need to convert the RTF
to a node-set before doing the count.

EXSLT provides the exsl:node-set function for this
purpose.

- F



 
Old May 3rd, 2004, 08:48 AM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure why, but it didn't seem to do anything differently. I'll give you the other code segments around it:

        <xsl:template name="process-payer">
                <xsl:param name="patient" />
                <xsl:param name="payer" />
                <xsl:variable name="procedures" select="/rootnode/procedure[payerkey=$payer and patientkey=$patient]" />
                <xsl:variable name="procedurecount" select="count($procedures)" />

                <xsl:if test="count($procedures) &gt; 0">
                        <debug><xsl:text>process-payer procedure count is </xsl:text><xsl:value-of select="count($procedures)" /></debug>
                        <xsl:call-template name="process-procedure-set">
                                <xsl:with-param name="set">
                                        <xsl:value-of select="$procedures" />
                                </xsl:with-param>
                        </xsl:call-template>
                </xsl:if>
        </xsl:template>

        <xsl:template name="process-procedure-set">
                <xsl:param name="set" />

                <debug><xsl:text>passed set is </xsl:text><xsl:value-of select="count($set)" /></debug>


                <xsl:variable name="subset">
                        <xsl:call-template name="get-valid-diagnosis-set">
                                <xsl:with-param name="procedureset">
                                        <xsl:value-of select="$set" />
                                </xsl:with-param>
                        </xsl:call-template>
                </xsl:variable>
              ....
        </xsl:template>

---

The issue seems to be that while the first function returns that there are count() values of anywhere from 8 to 20 (which there should be in the test instance I'm running), the called procedure only counts 1. Using exsl:node-set() does not fix this.

Thanks,
Jeff
([email protected])
FreeMED Software Foundation
http://freemedsoftware.com/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy parent node and not its children bonekrusher XSLT 4 August 29th, 2007 08:44 AM
Creating a template to generate a node set Chamkaur XSLT 1 July 27th, 2007 02:51 AM
Node counting sarahl2 XSLT 2 February 21st, 2006 02:25 PM
Trying to get node name of childs children keldan XML 1 August 1st, 2003 03:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.