[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Martijn wrote:
See below.
That's basically correct, for English. You may wish to
use the XSLT Standard Library's to-lower template in order
to handle non-English case folding.
Of course, using translate() is much more succinct:
but as I mentioned above doesn't handle case-folding in general.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] lowercasing all attributes...
Subject: Re: [xsl] lowercasing all attributes... From: Steve Ball <Steve.Ball@xxxxxxxxx> Date: Tue, 29 Jan 2002 12:13:55 +1100 |
Martijn wrote:
I'd like to lowercase a document's attributes through <xsl:apply-templates select="???">
Do you mean that you'd like to select nodes based on their attribute names or values, but in a case-insensitive manner?
See below.
I know it's translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') but how 'bout the template match pattern and the select for apply-templates ??
That's basically correct, for English. You may wish to
use the XSLT Standard Library's to-lower template in order
to handle non-English case folding.
Unfortunately, XSLT v1.0 doesn't provide a way of defining a function in the stylesheet so we have to do things the hard way. If I'm looking for the attribute named 'foo', but in any permutation of case ('Foo', 'FOO', etc), try this(*):
<xsl:template match='*'> <xsl:for-each select='@*'> <xsl:variable name='lower'> <xsl:call-template name='str:to-lower'> <xsl:with-param name='text' select='.'/> </xsl:call-template> </xsl:variable>
<xsl:if test='$lower = "foo"'> <!-- This is the one I want --> </xsl:if> </xsl:for-each> </xsl:template>
Of course, using translate() is much more succinct:
<xsl:template match='*/@*[translate(., "ABC...", "abc...") = "foo"]'> <!-- This is the one I want --> </xsl:template>
but as I mentioned above doesn't handle case-folding in general.
* You must setup XSLTSL to work in your stylesheet. See http://xsltsl.sf.net/ for instructions on how to do that.
HTHs, Steve Ball
-- Steve Ball | XSLT Standard Library | Training & Seminars Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development Steve.Ball@xxxxxxxxx +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] lowercasing all attribute, ronald heller | Thread | [xsl] Hi Dimitre, question on extra, Ahmad J Reeves |
Re: [xsl] Call perl script within x, Steve Ball | Date | RE: [xsl] Simple attribute value re, Edward . Middleton |
Month |