xsl-list
[Top] [All Lists]

Re: [xsl] XSLT function for title capitalization?

2018-04-09 18:40:00
On 09/04/18 22:04, John Lumley john(_at_)saxonica(_dot_)com wrote:
The simplest would be to tokenise to words and then apply-templates with
three cases:

1. [1]  capitalize($word)
2. $word = (’of,'and'... /etc.) - $word/
3. capitalize($word)

Plus exceptions. O'Reilly does NOT become O'reilly. McMahon does not
become Mcmahon, etc etc.

If you have to do it, you have to do it, but I agree with Michael, it's
incredibly ugly, and (fortunately) restricted mainly to the USA these
days, from what I see printed and published this side of the pond. And
USA publishers are *very* conservative.

Best is to store them all with sentence capitalisation (that is, init
cap on first word and proper nouns only), and have a word-capitalisation
routine to output them that way when needed.

///Peter
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>