Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Detecting upper case [Thread Next] Re: Detecting upper caseTo: NULL Date: 7/11/2006 11:46:00 AM Please write as (after removing spaces between & and =) $i & lt ; = $len Regards, Mukul "FinallyInSeattle" wrote: > Many thanks Mukul! > > One question - I'm getting errors in VS 2005 about the line that reads: > <xsl:when test="$i <= $len"> (Character "<" is illegal in XML > attribute values) > > I've tried the following and still get an error: > <xsl:when test="$i le $len"> (Expected end of the expression, > found 'le '. $i -->le <-- $len) > > What am I missing? > > Mukul Gandhi wrote: > > 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 | |||
|
