|
Subject: Re: [xsl] XSLT function for title capitalization? From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 9 Apr 2018 21:11:02 -0000 |
$ saxon9 -it:m ct.xsl
<?xml version="1.0" encoding="UTF-8"?>
: A Memorandum of Understanding
: Where Did the Druids Come From
: Being for the Benefit of [Mr.] Kite
where ct.xsl is
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:l="data:,l"
>
<xsl:function name="l:tc" as="xs:string">
<xsl:param name="s"/>
<xsl:value-of>
<xsl:analyze-string select="lower-case($s)" regex="(\w)(\w*)">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="position()!=1 and .=('the','for','of')">
<xsl:sequence select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="concat(upper-case(regex-group(1)),regex-group(2))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:sequence select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:value-of>
</xsl:function>
<xsl:template name="m">
: <xsl:value-of select="l:tc('A MEMORANDUM OF UNDERSTANDING')"/>
: <xsl:value-of select="l:tc('WHERE DID THE DRUIDS COME FROM')"/>
: <xsl:value-of select="l:tc('BEING FOR THE BENEFIT OF [MR.] KITE')"/>
</xsl:template>
</xsl:stylesheet>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSLT function for title c, John Lumley john@xxx | Thread | Re: [xsl] XSLT function for title c, Peter Flynn peter@xx |
| Re: [xsl] XSLT function for title c, John Lumley john@xxx | Date | Re: [xsl] XSLT function for title c, Michael Kay mike@xxx |
| Month |