This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPATH: Can not convert #STRING to a NodeList!
- To: "Palaniappan, Krishnasamy" <PalaniK at diebold dot com>
- Subject: Re: [xsl] XPATH: Can not convert #STRING to a NodeList!
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 22 Dec 2000 10:23:48 +0000
- CC: "'xslt'" <XSL-List at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <B56CDE69406ED211844700A02461EDDE02A780C2@a09devlab.diebold.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Krish,
> I call this template using:
> <xsl:call-template name="values_SUST">
> <xsl:with-param name="b_level_total" select="'B4TOTAL'"/>
> <xsl:with-param name="category" select="'TDES'"/>
> <xsl:with-param name="bcolor" select="'black'"/>
> </xsl:call-template>
>
> what I desire is:
> The template values_SUST needs to be called with 3 string arguments
> ("B4TOTAL","TDES","black"). While "black" should become the color in
> the template, B4TOTAL and TDES are actually nodes. Can I not do
> this?
In answer to your subject's question: you cannot convert strings to
node lists unless you use an extension function like saxon:evaluate.
However, you can select elements that have the same name as the
string. For example:
<xsl:value-of select="*[local-name() = $b_level_total]" />
One problem that you might be experiencing is that you seem to be
testing whether the value of $category is equal to the *value* of TDES,
SUB-TOTAL and TOTAL elements, whereas I think you want to test whether
it's equal to the strings 'TDES', 'SUB-TOTAL' or 'TOTAL', i.e.:
<xsl:choose>
<xsl:when test="$category='TDES'">
<xsl:value-of select="TDES"/>
</xsl:when>
<xsl:when test="$category='SUB-TOTAL'">
SUB-TOTAL
</xsl:when>
<xsl:when test="$category='TOTAL'">
TOTAL
</xsl:when>
</xsl:choose>
Also, where you're inserting the colour that you're passing as a
parameter, remember that you need to use attribute value templates to
put the value of the parameter into the value of the attribute, i.e.:
<fo:block font-size="6pt" color="{$bcolor}" text-align="center">
<xsl:value-of select="*[local-name() = $b_level_total]/CNT"/>
</fo:block>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list