|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XT, call-template, parameters, default values
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








