Re: [xsl] case-sensitivity in xml

Subject: Re: [xsl] case-sensitivity in xml
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 21 Jan 2005 18:30:03 -0500
Hi Rahil,

At 05:52 PM 1/21/2005, you wrote:
I am aware that XML is a case-sensitive language but is there a way to override its case-sensitivity when processing an xml document using XSLT?

Yes, but it's not pretty.


When faced with this, I have generally preprocessed the input to normalize the case of element and attribute names. So I don't have to let the case-folding logic into the main stylesheet.

In general, case-folding is done with the translate function. So if

<xsl:variable name="UPPER" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>

then translate($string,$UPPER,$lower) will convert to lower case (at least in the English/Latin alphabet).

Case-folding element and attribute names in an instance could be done with a modified identity transform and the xsl:element instruction. (Ask again if these hints are not enough to get you there.)

Also, is there a way to extract certain bits from the inner text of an xml document using XSLT such that {abc, xyz} can become abc,xyz ?

Use the translate() function for this too, only substitute the characters you don't want with the empty string:


translate($string,'{ }','') will make '{abc, xyz}' into 'abc,xyz'.

translate() is well-documented.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread