[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: lowercasing all attributes...
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.
<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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|