Counting in xslt 2003-04-16 - By Phil Friedman
Dan, you can use the translate function. Here are some examples...
<xsl:template name="compare-no-case"> <xsl:param name="str1"/> <xsl:param name="str2"/> <!-- return value --> <xsl:value-of select="boolean( translate($str1,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = translate($str2,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') )"/> </xsl:template> <!-- compare-no-case -->
<xsl:template name="lowercase"> <xsl:param name="text"/> <!-- <xsl:message terminate="no"><xsl:value-of select="$text"/>:<xsl:value-of select="translate($text,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:message> --> <!-- return value --> <xsl:text></xsl:text><xsl:value-of select="translate($text , 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' , 'abcdefghijklmnopqrstuvwxyz' )"/><xsl:text></xsl:text> </xsl:template> <!-- lowercase -->
<xsl:template name="uppercase"> <xsl:param name="text"/> <!-- return value --> <xsl:text></xsl:text><xsl:value-of select="translate($text , 'abcdefghijklmnopqrstuvwxyz' , 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' )"/><xsl:text></xsl:text> </xsl:template> <!-- uppercase -->
Regards, Philip Friedman -- Terralink Software Systems -- 207-772-6500 x101
On Wed, 16 Apr 2003 16:45:19 +0100, Good Dan-dgood01 <Dan.Good@(protected)> may have written:
|Hi Joe, |I'm not sure what you mean by folding the values? |I just had an idea that I could write a stylesheet to create an |intermediate xml doc with all values of @(protected) in lowercase and |then apply my existing stylesheet to the intermediate xml doc. A bit |extreme but I've got to meet a deadline for this. | |Thanks, |Dan | |-----Original Message----- |From: Joseph Kesselman [mailto:keshlam@(protected)] |Sent: 16 April 2003 14:00 |To: xalan-j-users@(protected) |Subject: Re: Counting in xslt | | | |Classic solution would be to fold the values to a single case before |comparing them. I'm having trouble accessing the spec right now, but |there's probably something in the XSLT function library which would |accomplish this... | |______________________________________ |Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. | |"may'ron DaroQbe'chugh vaj bIrIQbej" ("Put down the squeezebox and |nobody gets hurt.") | |
|
|