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
utput 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
aram name="str"/>
<xsl
aram 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
therwise>
<xsl:value-of select="translate($str,$lcase,$ucase)"/>
</xsl
therwise>
</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