简体   繁体   中英

XSL sequence in param

I found a way to pass a sequence of values between templates using the following code:

<xsl:call-template name="myTemplate">
    <xsl:with-param name="myParam" select="@foo, @bar"/>
</xsl:call-template>

So, in this case the param myParam in the template myTemplate will be a sequence containing 2 values.

But, if you use the following code, it's not working:

<xsl:call-template name="myTemplate">
    <xsl:with-param name="myParam">
        <xsl:value-of select="@foo, @bar"/>
    </xsl:with-param>
</xsl:call-template>

The result is a simple concatenation of @foo and @bar .
I also tried with <xsl:copy-of select="@foo, @bar"/> but it's the same result.

So, can someone explains me how to pass a sequence of values in the content of <xsl:with-param /> and not directly via the select attribute.

Thank you.

can someone explains me how to pass a list of values in the content of <xsl:with-param /> and not directly via the select attribute.

Not sure why it's necessary to avoid the select attribute. In fact, I believe it's preferable.

But to answer your question, you can use xsl:sequence .


This is, of course, all in the context of XSLT 2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM