Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Detecting upper case >Thread Next - Re: Detecting upper case RE: Detecting upper caseTo: NULL Date: 7/11/2006 7:32:00 AM
Please try this stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="caps" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template match="/field">
<xsl:call-template name="ModifyString">
<xsl:with-param name="original-string" select="@key" />
<xsl:with-param name="new-string" select="substring(@key,1,1)" />
<xsl:with-param name="i" select="2" />
<xsl:with-param name="len" select="string-length(@key)" />
</xsl:call-template>
</xsl:template>
<xsl:template name="ModifyString">
<xsl:param name="original-string" />
<xsl:param name="new-string" />
<xsl:param name="i" />
<xsl:param name="len" />
<xsl:choose>
<xsl:when test="$i <= $len">
<xsl:choose>
<xsl:when test="contains($caps, substring($original-string, $i,
1))">
<xsl:call-template name="ModifyString">
<xsl:with-param name="original-string"
select="$original-string" />
<xsl:with-param name="new-string" select="concat($new-string,
' ', substring($original-string, $i, 1))" />
<xsl:with-param name="i" select="$i + 1" />
<xsl:with-param name="len" select="$len" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ModifyString">
<xsl:with-param name="original-string" select="$original-string" />
<xsl:with-param name="new-string" select="concat($new-string,
substring($original-string, $i, 1))" />
<xsl:with-param name="i" select="$i + 1" />
<xsl:with-param name="len" select="$len" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$new-string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
When this stylesheet is applied to the following XML:
<field key="DocumentLogicalType">Submission</field>
The wanted output is produced:
Document Logical Type
Regards,
Mukul
"FinallyInSeattle" wrote:
> I have the situation where I have a document element that looks like
> the following:
>
> <field key="DocumentLogicalType">Submission</field>
>
> I'd like to render "DocumentLogicalType" as "Document Logical Type" -
> basically inserting a space whenever an upper case character is
> encountered. How do I detect upper case (as opposed to a translation)?
>
> Thanks in advance!
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
