xsl-list
[Top] [All Lists]

Re: case-sensitivity in xml

2005-01-21 16:30:03
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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
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>
--~--