[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Cannot use a parameter value in the group-starting-with attribute?


Subject: [xsl] Cannot use a parameter value in the group-starting-with attribute?
From: Peter Desjardins <peter.desjardins.us@xxxxxxxxx>
Date: Fri, 14 May 2010 15:49:17 -0400

Hi. I'm writing a 2.0 stylesheet and my processor is Saxon HE 9.2.1.1.
Also, I'm just starting out with XSLT.

I am trying to create a template with parameters that will use the
for-each-group element. I find that I cannot use a parameter value in
the group-starting-with attribute.

For example, I call my parametrized template from the following template.

<xsl:template match = "body" >
    <xsl:call-template name="wrapping-template">
         <xsl:with-param name="starting-element" select = "h1" />
    </xsl:call-template>
</xsl:template>

If I include the parameter value in a select attribute, the stylesheet
compiles and I see the expected output. The for-each element iterates
over a sequence of h1 elements.

<xsl:template name = "wrapping-template" >
    <xsl:param name = "starting-element" />
    <xsl:for-each select = "$starting-element">
        <xsl:value-of select = "name()" />
    </xsl:for-each>
</xsl:template>

If I include the parameter value in the group-starting-with attribute,
the stylesheet fails to compile.  The error message is "XTSE0340: XSLT
Pattern syntax error at char 0 on line 28 in {$starting-element}:
Unexpected token in pattern, found "$"." Line 28 is the one shown
below with the <xsl:for-each-group> element.

<xsl:template name = "wrapping-template" >
    <xsl:param name = "starting-element" />
    <xsl:for-each-group select = "*" group-starting-with = "$starting-element" >
        <xsl:apply-templates select="." mode="group"/>
    </xsl:for-each-group>
</xsl:template>

Are parameter values not allowed in the group-starting-with attribute?
Is there some syntax I can use to expand the parameter before the
processor tries to interpret the group-starting-with attribute?

Thanks for your help.

Peter


Current Thread
Keywords