Re: [xsl] How should I handle very similar templates ? Inserting a string into a match spec ?

Subject: Re: [xsl] How should I handle very similar templates ? Inserting a string into a match spec ?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Apr 2023 12:03:32 -0000
Am 4/20/2023 um 1:48 PM schrieb Richard Kerry richard.kerry@xxxxxxxx:
>
> Applying these two will remove all Release elements, and all mentions
> of Debug from remaining elements.
> I have another stylesheet that does the opposite, ie delete Debug
> elements and Release attributes.
>
> What I'd like to do is pass the keywords in as parameters; something like
> bbbbbb<xsl:template match="*[ @Condition =
> '''$(Configuration)''==''{$delete-element-name}|Win32''' ]" />
>
> bbbbbb<xsl:template match="@Condition[ .=
> '''$(Configuration)''==''{$delete-attribute-name}|Win32''' ]" />
>
> with appropriate variables or parameters declared.B  I tried a couple
> of variants of the above, to no avail.
> But I'm not even sure if this is possible.B  Is it?B  If it is possible
> but I need to approach it differently, please can someone advise.
>
With XSLT 1.0 / XSLT 1.0 processors you are not allowed to use variable
or parameter references inside match patterns, if I recollect that
correctly.


Which XSLT version/processor are you using? For XSLT 3 it seems like
your code should using shadow attributes and static params e.g.
<xsl:template _match="*[ @Condition =
'''$(Configuration)''==''{$delete-element-name}|Win32''' ]" /> if you
declare <xsl:param name="delete-element-name" as="xs:string"
static="yes" select="'Release'"/>.


Otherwise you need to use string concatenation e.g.

<xsl:template match="*[ @Condition = '''$(Configuration)''=='''
||$delete-element-name || '|Win32''' ]" />

Current Thread