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

Re: xslt 1, node sets in variables

Subject: Re: xslt 1, node sets in variables
From: Joelle Tegwen <tegwe002@xxxxxxx>
Date: Fri, 31 Jul 2009 16:13:04 -0500
Re:  xslt 1
Sorry, I had been making multiple changes to the code and didn't get it rolled back far enough.

When I do what you suggested, it doesn't generate any errors, but I still don't get the result as a node-set. The copy-of statement dumps the xml of the tree to the output. Also, count(exsl:node-set($projects)) returns 1 (It should return 26 when there is no filter).

<xsl:template match="projects">
<xsl:variable name="projects">
<xsl:choose>
<xsl:when test="$active_filter = 'active'">
<xsl:copy-of select="project[@active!=0]"/>
</xsl:when>
<xsl:when test="$active_filter = 'archived'">
<xsl:copy-of select="project[@active=0]"/>
</xsl:when>
<xsl:when test="$active_filter = 'new'">
<xsl:copy-of select="project[@new=1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="project"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:copy-of select="$projects"/>
<xsl:choose>
<xsl:when test="count(exsl:node-set($projects))>10">
<xsl:call-template name="pagenated">
<xsl:with-param name="projects" select="exsl:node-set($projects)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="not_pagenated">
<xsl:with-param name="projects" select="exsl:node-set($projects)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Thanks for your help.
J


Wendell Piez wrote:

<xsl:template match="projects">


  <!-- first, bind the variable -->
  <xsl:variable name="projects">
    <xsl:choose>
      <xsl:when test="$active_filter = 'active'">
        <xsl:copy-of select="project[@active!=0]"/>
      </xsl:when>
    (... etc ...)
  </xsl:variable>

  <!-- now, you want to copy it to the result of this template -->
  <xsl:copy-of select="$projects"/>

  <!-- next, all the other stuff using the variable -->
  <xsl:value-of select="count(exsl:node-set($projects))"/>
    (... etc ...)
</xsl:template>

I hope that helps,
Wendell

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-2007 All Rights Reserved.