[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] boolean values
Subject: Re: [xsl] boolean values From: Romeo.Disca@xxxxxxxxxxx (Romeo Disca) Date: Thu, 28 Aug 2003 00:05:29 +0200 |
Well, Matt, I'm still new to XSLT, nevertheless I would go like this: (Hope I'm right and this helps) ---------------------------------- . . <xsl:variable name="hasContractsTest"> <xsl:call-template name="hasContracts"> <xsl:with-param name="branding" select="$branding"/> </xsl:call-template> </xsl:variable> <xsl:variable name="hasContracts" select="boolean(hasContractsTest)"/> . . -------- <xsl:template name="hasContracts"> <xsl:param name="branding"> <xsl:choose> <xsl:when test="$branding = 'ABC' and /Output/Contracts/Contract[substring(ContractId,1,1) = 'Q']">1</xsl:when> <xsl:when test="/Output/Contracts/Contract">1</xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:template> ==================== It's not necessary to call the count() function, because if the test /Output...'Q' will return an empty node-set the processor interprets it as false. One or more elements in the node-set as true. Yours Romeo. Am Mittwoch, 27. August 2003 22:35 schrieb Keller, Matt: > I'm having trouble creating variables that are equivalent to a boolean > value. > > I have a variable that was previously coded in this fashion: > > <xsl:variable name="hasContracts" > select="boolean(/Output/Contracts/Contract)"/> > > This returned an actual true/false boolean value, and I was able to test > for it like this: > > <xsl:if test="$hasContracts"> > > However, due to business needs, I have to expand my variable. I have since > code it in this manner: > > <xsl:variable name="hasContracts"> > <xsl:choose> > <xsl:when test="$branding = 'ABC'"><xsl:value-of > select="count(/Output/Contracts/Contract[substring(ContractId,1,1)='Q']) > > 0"/> </xsl:when> <xsl:otherwise><xsl:value-of > select="boolean(/Output/Contracts/Contract)"/></xsl:otherwise> > </xsl:choose> > </xsl:variable> > > And now it is no longer a boolean value, perhaps because true or false is a > child of the xsl:variable element? > > Is there a way to put the value of your variable in a xsl:choose and retain > a true boolean value? > > Thanks, > > Matt > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- Romeo Disca Email: romeo.disca@xxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] boolean values, Keller, Matt | Thread | RE: [xsl] boolean values, Michael Kay |
RE: [xsl] Variable - Results Tree F, Martinez, Brian | Date | [no subject], prenom nom |
Month |
Keywords