I have an XML "1.0" XSLT transformation where I need case insensitive matching. I am using the following to rename "my_col" to "renamed_col",
<xsl:template match="my_col">
<renamed_col>
<xsl:apply-templates select="@* | node()"/>
</renamed_col>
</xsl:template>
This works fine if I use "my_col", but fails when I use "My_Col". I need to match this column irrespective of the letter case.
Any help would be greatly appreciated.
Try this:
<xsl:template match="*[ translate( local-name(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz'
) = 'my_col']">
The answer given by Priyansh Goel will cover all possible case variations (except with names that use characters other than those listed). However, if you know what variations to expect, you could make this simpler (and faster) by listing them explicitly, e.g.:
<xsl:template match="my_col | My_Col">
<renamed_col>
<xsl:apply-templates select="@* | node()"/>
</renamed_col>
</xsl:template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With