xsl-list
[Top] [All Lists]

RE: [xsl] String Case Conversion: Title Case

2009-10-07 12:21:27
I've had the pleasure of doing this in the past and here is a helpful hint as 
to what Wendell has mentioned. I created an XML doc that contained a list of 
interesting names, acronyms, prepositions, etc, to test against and eventually 
it all sat in a db for ease of updating and pumped out the XML. This list was 
maintained not by myself but by others. As long as they followed the their own 
spelling rules, everything was fine. When testing against the list I 
lower-cased the test string vs a lower-case instance in the control list and 
grabbed the content of the entry. If you are using a processor with db 
extensions, then you can test against the db directly, I believe.

<controlVocab>
   <entry>and</entry>
   <entry>XML</entry>
   ...
</controlVocab>

Marijan (Mario) Madunic
Publishing Specialist
New Flyer Industries

-----Original Message-----
From: Wendell Piez [mailto:wapiez(_at_)mulberrytech(_dot_)com] 
Sent: Wednesday, October 07, 2009 10:45 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] String Case Conversion: Title Case

At 03:43 AM 10/7/2009, Mike wrote:
I have used upper-case and lower-case methods in xslt2.0. But
I like to know, how to convert Title-Case/Upper-Lower Case.
Could any one share with me the logic for this.


There is no function for creating title-case in the standard function
library because it was considered too culturally sensitive. Conventions for
capitalizing titles vary greatly from one country to another, and even among
different publishers within the same country (compare British with US
newspapers, for example). Simply forcing any letter to lower-case if it is
preceded by another letter and to upper-case otherwise does not give
acceptable results in any country, but if that's what you want to do, it's
easy enough to write your own function. You can test whether a character is
a letter using the regex construct \p{L}.

If you do write your own function, you will quickly find you need a 
stop list to fix problems with acronyms and interesting names (such 
as "XML" and "XPath", not "Xml" and "Xpath"), to say nothing of 
whatever local rules your title case convention follows (such as 
leaving prepositions in lower case, or whatever).

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


--------------------------------------------------------------------
Please consider the environment before printing this e-mail.

CONFIDENTIALITY STATEMENT: This communication (and  any and all information or 
material transmitted with this communication) is confidential, may be 
privileged and is intended only for the use of the intended recipient. If you 
are not the intended recipient, any review, retransmission, circulation, 
distribution, reproduction, conversion to hard copy, copying or other use of 
this communication, information or material is strictly prohibited and may be 
illegal. If you received this communication in error or if it is forwarded to 
you without the express authorization of New Flyer, please notify us 
immediately by telephone or by return email and permanently delete the 
communication, information and material from any computer, disk drive, diskette 
or other storage device or media. Thank you.


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