Ooops, didn't read the question properly...
Try something like...
== XML =========================================
<?xml version="1.0"?>
<root>
<attribute name="bbBusState"/>
</root>
== end of XML ==================================
== XSL =========================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="root">
<xsl:apply-templates select="attribute"/>
</xsl:template>
<xsl:template match="attribute">
<xsl:text>public static final String </xsl:text>
<xsl:call-template name="Camel2Underscore">
<xsl:with-param name="str" select="@name"/>
</xsl:call-template>
<xsl:text>_ATTR_TYPE</xsl:text>
</xsl:template>
<xsl:template name="Camel2Underscore">
<xsl:param name="str"/>
<xsl:param name="u-str"
select="translate($str,$ucase,'||||||||||||||||||| |||||||')"/>
<xsl:choose>
<xsl:when test="substring($u-str,1,1) = '|'">
<xsl:text>_</xsl:text>
<xsl:value-of select="substring($str,1,1)"/>
<xsl:call-template name="Camel2Underscore">
<xsl:with-param name="str" select="substring($str,2)"/>
<xsl:with-param name="u-str" select="substring($u-str,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($u-str,'|')">
<xsl:variable name="runlen"
select="string-length(substring-before($u-str,'|'))"/>
<xsl:value-of
select="translate(substring($str,1,$runlen),$lcase ,$ucase)"/>
<xsl:call-template name="Camel2Underscore">
<xsl:with-param name="str" select="substring($str,$runlen + 1)"/>
<xsl:with-param name="u-str" select="substring($u-str,$runlen +
1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate($str,$lcase,$ucase)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
== end of XSL ==================================
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:HK*******************@newsfep2-win.server.ntli.net...
Hi Mikael,
Try the translate() function, e.g.
<xsl:value-of
select="translate(@name,'abcdefghijklmnopqrstuvwxy z','ABCDEFGHIJKLMNOPQRSTUV WXYZ')"/>
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Mikael Petterson" <mi*************@hotmail.com> wrote in message
news:9WK7b.3317$P51.5569@amstwist00... Hi,
I have the following in my xml file:
<attribute name="bbBusState">
I need to generate to the following:
public static final String BB_BUS_STATE_ATTR_TYPE.
Any hints???
//Mikael