M
Mikael Petterson
Hi,
I got some help to go from:
bbBusState to BB_BUS_STATE.
However I found out :-( that the xml contained attributes like:
TxDeviceGroup and that becomes:
_TX_DEVICE_GROUP
This is the code I got from Marrow (thanks Marrow ) (See below)
I must admit (Marrow) that I do not fully understand what the code
does so I am having problems to modify it to remove the underscore
for attributes that begins with a cap.
I have tried to add the following code (see My code below).
My strings became a mess :-(
//Mikael
My code
=======
<xsl:choose>
<xsl:when test="starts-with($u-str,'|')">
<xsl:variable name="u-str-len" select="string-length($u-str)"/>
<xsl:variable name="u-str-rest" select="substring($u-str,2,$u-str-len)"/>
<xsl:variable name="str-first-chr" select="substring($str,1,1)"/>
<xsl:call-template name="Camel2Underscore">
<xsl:with-param name="u-str" select="concat($str-first-chr,
$u-str-rest)"/>
</xsl:call-template>
</xsl:when>
=======================================================
<xsl:template name="Camel2Underscore">
<xslaram name="str"/>
<xslaram name="u-str"
select="translate($str,$ucase,'||||||||||||||||||||||||||')"/>
<!-- Here I tested to add my code -->
<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>
<xsltherwise>
<xsl:value-of select="translate($str,$lcase,$ucase)"/>
</xsltherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I got some help to go from:
bbBusState to BB_BUS_STATE.
However I found out :-( that the xml contained attributes like:
TxDeviceGroup and that becomes:
_TX_DEVICE_GROUP
This is the code I got from Marrow (thanks Marrow ) (See below)
I must admit (Marrow) that I do not fully understand what the code
does so I am having problems to modify it to remove the underscore
for attributes that begins with a cap.
I have tried to add the following code (see My code below).
My strings became a mess :-(
//Mikael
My code
=======
<xsl:choose>
<xsl:when test="starts-with($u-str,'|')">
<xsl:variable name="u-str-len" select="string-length($u-str)"/>
<xsl:variable name="u-str-rest" select="substring($u-str,2,$u-str-len)"/>
<xsl:variable name="str-first-chr" select="substring($str,1,1)"/>
<xsl:call-template name="Camel2Underscore">
<xsl:with-param name="u-str" select="concat($str-first-chr,
$u-str-rest)"/>
</xsl:call-template>
</xsl:when>
=======================================================
<xsl:template name="Camel2Underscore">
<xslaram name="str"/>
<xslaram name="u-str"
select="translate($str,$ucase,'||||||||||||||||||||||||||')"/>
<!-- Here I tested to add my code -->
<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>
<xsltherwise>
<xsl:value-of select="translate($str,$lcase,$ucase)"/>
</xsltherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>