xsl-list
[Top] [All Lists]

RE: [xsl] IGNORE CASE IN XSLT match

2008-10-01 08:38:56
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']">


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--