xsl-list
[Top] [All Lists]

Re: [xsl] replace -x to -X

2006-07-10 09:40:34
Actuall max it could be string1-string2-string3, but not more...

I will use the code below,
Thx.

On 7/10/06, Mukul Gandhi <gandhi(_dot_)mukul(_at_)gmail(_dot_)com> wrote:
Can you please clarify whether the string is of form string1-string2.
Or is it of form string1-string2- ......... -stringN ?

Is its of 2nd form, then you have to do what Andrew has told.

Is its of 1st form, then you can write the code as below:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

   <xsl:output method="text" />

   <xsl:variable name="small" select="'abcdefghijklmnopqrstuvwxyz'" />
   <xsl:variable name="caps" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

   <xsl:template match="/">
      <xsl:variable name="tmp_string" select="'JIMMY-DIMMy'" />

      <xsl:variable name="string1"
select="substring-before($tmp_string, '-')" />
      <xsl:variable name="string2" select="substring-after($tmp_string, '-')" />

      <xsl:variable name="result"
select="concat(translate(substring($string1,1,1),$small,$caps),translate(substring($string1,2),$caps,$small),'-',translate(substring($string2,1,1),$small,$caps),translate(substring($string2,2),$caps,$small))"
/>

      <xsl:value-of select="$result" />

   </xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 7/10/06, Renate <renaate(_at_)gmail(_dot_)com> wrote:
> I have a string $tmp_string.
>
> for ex., JIMMY-DIMMy
>
> And I need to change the following:
> first letter is in uppercase
> other letters are in lowercase
> first letters after "-" sign also is in uppercase
>
> the result will be:
> Jimmy-Dimmy
>
>
> I know how to make Jimmy-dimmy, but how to make Jimmy-Dimmy...???

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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