Subject: Re: XT, call-template, parameters, default values From: Phil Lanch <phil@xxxxxxxxxxxxxxx> Date: Thu, 09 Dec 1999 12:04:27 +0000 |
Jon Smirl wrote: > > The output from the following example is $$22$ not $22$22$ like I expected. > At the intermediate stage VALUE is not specified but I need to select it in > order to pass it on to the next stage. It appears that selecting it binds it > so that I don't pick up the default in the final stage. > > I can move my defaults up to the second level but this will make me copy > them a hundred times. Is there a better way? > > <kTaxItem type="vendTaxEnum">22</kTaxItem> > > <xsl:apply-templates select="kTaxItem"/> > > <xsl:template match="*[@type='vendTaxEnum']"> > <xsl:param name="value"/> > <xsl:call-template name="buildEnum"> > <xsl:with-param name="value" select="$value"/> > <xsl:with-param name="enums" > select="document('../common/enum.xml')/enums/taxEnum"/> > </xsl:call-template> > </xsl:template> > > <xsl:template name="buildEnum"> > <xsl:param name="value" select="."/> > <xsl:param name="enum"/> > value is $<xsl:value-of select="$value"/>$<xsl:value-of select="."/>$ > </xsl:template> When you don't specify a value for a variable, it still has one: a null string. That's the value of $value in the *[@type='vendTaxEnum'] template, and so it's passed to $value in the buildEnum template. You could test the value of the $value inside the buildEnum template, something like below. This involves changing *only* the buildEnum template. (The way I've done it, the default value is *the string value of* the current node. If that's not what you want in your non-simplified stylesheet, then I supppose xsl:copy or xsl:copy-of would help.) <xsl:template name="buildEnum"> <xsl:param name="value"/> <xsl:variable name="actualValue"> <xsl:choose> <xsl:when test="$value"> <xsl:value-of select="$value"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:param name="enum"/> value is $<xsl:value-of select="$actualValue"/>$<xsl:value-of select="."/>$ </xsl:template> -- bah...glugglug...humbug phil *witnesh relocation program alumnush* XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
XT, call-template, parameters, defa, Jon Smirl | Thread | choice between tighter template mat, Christopher Devenoge |
Re: two questions on Oracle XSL, Sebastian Rahtz | Date | Newbie question with javascript/xsl, John . Cyriac |
Month |