Re: [xsl] Is it possible to set the mode dynamically?

Subject: Re: [xsl] Is it possible to set the mode dynamically?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Jan 2020 11:01:18 -0000
Am 07.01.2020 um 11:51 schrieb rus tle profrustyleafiii@xxxxxxxxxxx:
> Is it possible to set the mode dynamically?
>
> The use case:
>
> 1. Setting a variable to a file name
>
> <xsl:variablename="PayloadName"select="/POM/Netflix/@payload"/>
>
> 2. Using that variable to load the file dynamically into another variable
>
> <xsl:variablename="payload"select="document(concat($PayloadName,
> '.xml'))/payloadb/>
>
> 3. Calling a template and passing the file name as as a param to be
> used in that called template as the mode.
>
> <xsl:call-templatename="create-html-tables">
> <xsl:with-paramname="PayloadName"select="$PayloadNameb/>
> </xsl:call-template>
>
> <xsl:templatename="create-html-tables">
> <xsl:paramname=bPayloadName"/>
> <xsl:apply-templatesselect="$pom//Event"mode=b$payloadNameb/>
> </xsl:template>
>
> Is that a possibility in anyway shape or formb&? Otherwise I am
> thinking the only alternative would be to use a choose and then
> hardcodeB the mode - which works, but just wondering if there was a
> cleaner way?
>
> <xsl:choose>
> <xsl:whentest="$PayloadName = 'pivot-table-payload'">
> <xsl:apply-templatesselect="$pom//Event"mode="pivot-table"/>
> B  B  </xsl:when>
> <xsl:otherwise>
> <xsl:apply-templatesselect="$pom//Event"mode="default"/>
> </xsl:otherwise>
> </xsl:choose>
>
> Many thanks,
>
> Rusty


Using a shadow attribute in XSLT 3 it might work:
https://www.w3.org/TR/xslt-30/#shadow-attributes


The variable/param would need to be global and static.


Additionally there is fn:transform to run on the fly generated XSLT.

Current Thread