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

RE: [xsl] IGNORE CASE IN XSLT match


Subject: RE: [xsl] IGNORE CASE IN XSLT match
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Wed, 1 Oct 2008 08:38:31 -0400

> I would like to find out ,is there any way to ignore case while
> match template in XSLT.

In some theoretical sense, the short answer is "no". XML is case
sensitive, and thus a <mix> is simply a different element than a
<Mix>. However, XPath (and thus XSLT) is perfectly capable of
matching more than one element name at once:
  <xsl:template match=" mix | Mix "> ... </xsl:template>
or performing string manipulation inside a predicate in a match,
which is what Scott Trenda's solution takes advantage of:

XSLT 2.0
---- ---
  <xsl:template match="*[ lower-case( local-name() ) = 'mix']">

XSLT 1.0
---- ---
  <xsl:template match="*[ translate( local-name(),
                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                     'abcdefghijklmnopqrstuvwxyz'
                                    ) = 'mix']">


Current Thread
Keywords