Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Detecting upper case

From: MukulGandhi@-----------.---------.---
To: 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!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent