I declare a variable but told 'no following siblings instructions has no effect'

Here should go questions about transforming XML with XSLT and FOP.
BryceS
Posts: 6
Joined: Fri Oct 19, 2012 1:20 am

I declare a variable but told 'no following siblings instructions has no effect'

Post by BryceS »

Hi,

I can declare a variable containing a sequence of strings and use it as parameter to a template like so:

Code: Select all

<xsl:variable name="Gaits" as="xs:string*" select="('Trot')"/>
<xsl:apply-templates select="Sires">
<xsl:with-param name="Gaits" select="$Gaits"></xsl:with-param>
</xsl:apply-templates>
This above works fine, but when I put the same thing inside a choose statement like so:

Code: Select all

        <xsl:choose>
<xsl:when test="$Val = 'P'">
<xsl:variable name="Gaits" as="xs:string*" select="('Pace')"/>
</xsl:when>
<xsl:when test="$Val = 'T'">
<xsl:variable name="Gaits" as="xs:string*" select="('Trot')"/>
</xsl:when>
<xsl:when test="$Val = 'C'">
<xsl:variable name="Gaits" as="xs:string*" select="('Pace', 'Trot')"/>
</xsl:when>
</xsl:choose>
I get warning for each 'variable' line of
[Saxon-PE 9.4.0.3] A variable with no following sibling instructions has no effect
and consequently when I try to use it in the 'apply-templates' call it says my variable 'Gaits' has not been declared.

What am I doing wrong?
Am I not allowed to set a variables content based on a condition or am I just going about it the wrong way?

Thanks,
Bryce S.
BryceS
Posts: 6
Joined: Fri Oct 19, 2012 1:20 am

Re: I declare a variable but told 'no following siblings instructions has no effect'

Post by BryceS »

OK, found out what I was doing wrong.

I was out of scope when trying to use variable outside of the 'when' where it was declared. Since I had no following statement inside the 'when' clause it was saying not used (in an odd way...) :)
Post Reply