473,544 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem to remove underscore in template

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_GROU P
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="substri ng($u-str,2,$u-str-len)"/>
<xsl:variable name="str-first-chr" select="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="u-str" select="concat( $str-first-chr,
$u-str-rest)"/>
</xsl:call-template>
</xsl:when>

=============== =============== =============== ==========

<xsl:template name="Camel2Und erscore">
<xsl:param name="str"/>
<xsl:param name="u-str"
select="transla te($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="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,2)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains( $u-str,'|')">
<xsl:variable name="runlen"
select="string-length(substrin g-before($u-str,'|'))"/>
<xsl:value-of
select="transla te(substring($s tr,1,$runlen),$ lcase,$ucase)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,$runlen + 1)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,$runlen +
1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="transla te($str,$lcase, $ucase)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #1
4 2995
Without having to know the code that you were using, there are simple ways
to remove the leading underscore:

1.
<xsl:variable name="vresult1" >
<xsl:call-template name="capitaliz e">
<xsl:with-param name="str" select="$someSt r"/>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="theResult " select="substri ng($vresult1, 1 +
contains($allCa ps, substring($some Str, 1, 1)))"/>

2.
<xsl:variable name="vresult1" >
<xsl:call-template name="capitaliz e">
<xsl:with-param name="str" select="substri ng($someStr, 2)"/>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="theResult " select="concat( translate(subst ring($someStr,
1, 1), $lowercase, $allCaps), $vresult1)"/>
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mikael Petterson" <mi************ *@hotmail.com> wrote in message
news:Ia_ab.5421 $P51.8313@amstw ist00...
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_GROU P
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="substri ng($u-str,2,$u-str-len)"/> <xsl:variable name="str-first-chr" select="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="u-str" select="concat( $str-first-chr,
$u-str-rest)"/>
</xsl:call-template>
</xsl:when>

=============== =============== =============== ==========

<xsl:template name="Camel2Und erscore">
<xsl:param name="str"/>
<xsl:param name="u-str"
select="transla te($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="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,2)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains( $u-str,'|')">
<xsl:variable name="runlen"
select="string-length(substrin g-before($u-str,'|'))"/>
<xsl:value-of
select="transla te(substring($s tr,1,$runlen),$ lcase,$ucase)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,$runlen + 1)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,$runlen +
1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="transla te($str,$lcase, $ucase)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #2
Hmmmmmmm.... Simple for you yeah. Not for me.

You first define a variable called vresult1 then you call a
template called capitalize. And you send, I assume _TR_DEVICE_GROU P to
that template. Then you define a variable that is called theResult. I
guess this is where we get the TR_DEVICE_GROUP output. Which part do I
need to implement?
//Mikael

Dimitre Novatchev wrote:
Without having to know the code that you were using, there are simple ways
to remove the leading underscore:

1.
<xsl:variable name="vresult1" >
<xsl:call-template name="capitaliz e">
<xsl:with-param name="str" select="$someSt r"/>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="theResult " select="substri ng($vresult1, 1 +
contains($allCa ps, substring($some Str, 1, 1)))"/>

2.
<xsl:variable name="vresult1" >
<xsl:call-template name="capitaliz e">
<xsl:with-param name="str" select="substri ng($someStr, 2)"/>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="theResult " select="concat( translate(subst ring($someStr,
1, 1), $lowercase, $allCaps), $vresult1)"/>
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mikael Petterson" <mi************ *@hotmail.com> wrote in message
news:Ia_ab.5421 $P51.8313@amstw ist00...
Hi,

I got some help to go from:

bbBusState to BB_BUS_STATE.

However I found out :-( that the xml contained attributes like:

TxDeviceGro up and that becomes:

_TX_DEVICE_GR OUP
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="substri ng($u-str,2,$u-str-len)"/>
<xsl:variable name="str-first-chr" select="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="u-str" select="concat( $str-first-chr,
$u-str-rest)"/>
</xsl:call-template>
</xsl:when>

============= =============== =============== ============

<xsl:templa te name="Camel2Und erscore">
<xsl:param name="str"/>
<xsl:param name="u-str"
select="trans late($str,$ucas e,'|||||||||||| ||||||||||||||' )"/>

<!-- 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="substri ng($str,1,1)"/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,2)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains( $u-str,'|')">
<xsl:variable name="runlen"
select="strin g-length(substrin g-before($u-str,'|'))"/>
<xsl:value-of
select="trans late(substring( $str,1,$runlen) ,$lcase,$ucase) "/>
<xsl:call-template name="Camel2Und erscore">
<xsl:with-param name="str" select="substri ng($str,$runlen + 1)"/>
<xsl:with-param name="u-str" select="substri ng($u-str,$runlen +
1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="transla te($str,$lcase, $ucase)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>



Jul 20 '05 #3

"Mikael Petterson" <mi************ *@hotmail.com> wrote in message
news:KJ%ab.5445 $P51.8312@amstw ist00...
Hmmmmmmm.... Simple for you yeah. Not for me.

You first define a variable called vresult1 then you call a
template called capitalize. And you send, I assume _TR_DEVICE_GROU P to
that template.
No. I pass to it "TrDeviceGr oup"

As result the value of $vresult1 will be _TR_DEVICE_GROU P

The "capitalize " template is all you had at the moment (regardless if it
were Marrow's solution, or the FXSL-based solution I proposed).
Then you define a variable that is called theResult. I
guess this is where we get the TR_DEVICE_GROUP output.
Yes.
Which part do I
need to implement?


Absolutely nothing to implement -- just define the variables in this way.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Jul 20 '05 #4
Hi,

Thanks for the explanation. It really helped me out. You saved me since
I needed to write a code generator and discovered some inconsistencies .

Thanks again!! Have a nice evening!

//Mikael

Dimitre Novatchev wrote:
"Mikael Petterson" <mi************ *@hotmail.com> wrote in message
news:KJ%ab.5445 $P51.8312@amstw ist00...
Hmmmmmmm... . Simple for you yeah. Not for me.

You first define a variable called vresult1 then you call a
template called capitalize. And you send, I assume _TR_DEVICE_GROU P to
that template.

No. I pass to it "TrDeviceGr oup"

As result the value of $vresult1 will be _TR_DEVICE_GROU P

The "capitalize " template is all you had at the moment (regardless if it
were Marrow's solution, or the FXSL-based solution I proposed).

Then you define a variable that is called theResult. I
guess this is where we get the TR_DEVICE_GROUP output.

Yes.

Which part do I
need to implement?

Absolutely nothing to implement -- just define the variables in this way.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2007
by: christopher keller | last post by:
Hello, Using MS Access 97, SR2 mit MDAC 2.7 / 2.8 English/Deutsch we get the old problem of 'object not found' in DB2 Connect Version 8. ( From MS KB Q129814: "When you try to attach a DB2 table containing an underscore (_) or a percent sign (%) in its name, you receive the following error message". Cause: "The Microsoft Jet database...
2
4432
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c */ #include <time.h>
2
4815
by: krema2ren | last post by:
Hi I've the following header problem that I need two classes to know each other through a boost::shared_ptr. Does any of you smart guys have a solution? A.h ---------------------- #include "B.h"
5
274
by: axel22 | last post by:
I'm using the MSVisual Studio 2003, and I tried creating a template class. This generated a well known problem when I tried putting the class member definitions in another source file (.cpp). I decided to solve this by putting the definitions into the header, and I used the #define directive to avoid redefinitions: #pragma once
2
3537
by: kalki70 | last post by:
Hi, I'm working with templates, but I have a syntax problem I don't know how to fix. I built a small example, so maybe you can tell me how to write correctly this code. I have 2 files : template.H and template.C
7
1747
by: shuisheng | last post by:
Dear All; Would you please help me to look at the following case: //! Rotation. enum Rotation { NON_CYCLIC, CYCLIC }; //! Rotation.
4
11214
by: daroman | last post by:
Hi Guys, i've problem with my small C++ programm. I've just small template class which represetns a array, everything works fine up to combination with std::string. I did tried it with M$ VC++ and with GCC (Cygwin and Linux) and my problem is when i try do this int main(int argc, char **argv) { array<std::stringa(10); a = "Huhuhu"; <---...
5
1605
by: chris | last post by:
Guys, I have the following piece of code. Could you please help me understand why b.ToString( ) cannot be called while b.foo( ) can? When I compile I get (gcc, but visual studio gives the same pretty much). Thanks $ g++ -Wall foo.cpp foo.cpp: In function `int main(int, char**)': foo.cpp:21: error: no matching function for call to...
6
2589
by: abir | last post by:
i have a template as shown template<typename Sclass Indexer{}; i want to have a specialization for std::vector both const & non const version. template<typename T,typename Aclass Indexer<std::vector<T,A {} matches only with nonconst version. anyway to match it for both? and get if it is const or nonconst? Actually i want 2 specialization,...
0
7374
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7632
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7720
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5309
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1850
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
996
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.