473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Xslt Help

16
How to convert a node value to lowercase???
I have
<xsl:when test="//@locationName ='xyz'">

I have to convert the locationName to lowercase in the xslt page.
Can I use the toLower function?

I am new to XSLT, Pls help...
Sep 22 '08 #1
16 2313
MarkoKlacar
296 Expert 100+
Hi,

Yes you can use toLower. Do you know how to get the value you need to change the case for?

/MK
Sep 22 '08 #2
Bhavs
16
Hi,

Yes you can use toLower. Do you know how to get the value you need to change the case for?

/MK
Hi Mark,

Thanks for replying.

No, I dont know how to get value.. Can u pls let me know how to get?
Sep 22 '08 #3
MarkoKlacar
296 Expert 100+
Hi,

It's Marko, but it's ok.... : - )

In your case, if I understood in correctly, you want to get the value of an attribute? This will help you to understand how you should do that.

Sooner or later you will probably want to get the value of an element, this is what you would want to read in order to see how that's done.

Let me know if you need more help.

/MK
Sep 22 '08 #4
Dormilich
8,658 Expert Mod 8TB
No, I dont know how to get value.. Can u pls let me know how to get?
I think, in this case it is better to use a template or for-each construct than <xsl:if>, since you do not have access to the node-set of your test clause.

In addition I would also recommend a xslt tutorial (e.g. w3schools.com) for reading on the template construct.

you can apply kind-of if-statements by using a "conditional xpath" (like //element[@attr = 'value'])

regards
Sep 22 '08 #5
Bhavs
16
Hi Marko,
Thanks for the info.

Tried with the following code

<xsl:variable name='location'>
<xsl:call-template name='str:to-lower'>
<xsl:with-param name='text' select='//@locationName'/>
</xsl:call-template>
</xsl:variable>


But it says the the prefix 'str' is note defined

Regards,
Bh
Sep 22 '08 #6
MarkoKlacar
296 Expert 100+
Hi,

Have you declared it? The way your code looks now you have declared a function, no need to do that since the toLower is a standard function. Perhaps you need to have a quick look at namespaces in XSL to get you started. You can also have a look at this.

/MK
Sep 22 '08 #7
Bhavs
16
Hi,

I am using this namespace

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

Do I need to add anything else??

Thnks..
Sep 22 '08 #8
MarkoKlacar
296 Expert 100+
Hi,

That should about cover it as far as I know...

Have you figured out how to call the function?
Have you solved the problem?

/MK
Sep 22 '08 #9
Bhavs
16
Hi,

That should about cover it as far as I know...

Have you figured out how to call the function?
Have you solved the problem?

/MK

Hi Marko,

NO, I haven't, as I am getting an eror telling that prefix str is not defined.

Regards,
Bh
Sep 22 '08 #10
Dormilich
8,658 Expert Mod 8TB
As far as I know, there is no toupper-function in either XSLT 1.0 or XPath 1.0 (there you could use the translate() function, but that's not that elegant). There is such a function in XPath 2.0 (lower-case()).

str:to-lower is a library (XSLT Standard Library ) dependant function (this has nothing to do with the core XSLT)

regards
Sep 22 '08 #11
Bhavs
16
Hi all,

I am using XSLT 1.0

So, that might be the reson that str:to-lower is not getting recognised.

So, now I am trying to use the translate function to do the same.
But it doesn' seem to be working.

<xsl:variable name='location'>
<xsl:value-of select='translate("//@locationName","JERSEY","jersey")'/>
</xsl:variable>

<xsl:choose>
<xsl:when test="location ='jersey'">
.
.
.
.
.
</xsl:choose>
Sep 22 '08 #12
Dormilich
8,658 Expert Mod 8TB
your test condition looks for a child element named location, whose string value is "jersey", if you want to use the variable, use $location.

btw. to put a a value in $location you should rather use the select attribute:
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name='location' select='translate("//@locationName","JERSEY","jersey")'/>
  2. ...
  3. <xsl:when test="$location = 'jersey'">
regards
Sep 22 '08 #13
Bhavs
16
your test condition looks for a child element named location, whose string value is "jersey", if you want to use the variable, use $location.

btw. to put a a value in $location you should rather use the select attribute:
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name='location' select='translate("//@locationName","JERSEY","jersey")'/>
  2. ...
  3. <xsl:when test="$location = 'jersey'">
regards
Hi..
]<xsl:variable name='location' select='translate("//@locationName","JERSEY","jersey")'/>

For the above, the xsl is taking //@locationName as //@locationName literally.
I mean its not taking the value of the node :D

So its translating //@locationName with //@locationname


Pls give me some ideas to take the value os the node here.
I tried many things, but none of them seem to wrk..
Sep 22 '08 #14
Dormilich
8,658 Expert Mod 8TB
ah, ok.
you give the location path as a string (my fault, didn't see it in the first place)... try
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name='text' select='translate(//@locationName,"JERSEY","jersey")'/>
  2. // or
  3. <xsl:variable name='location' select="//@locationName"/>
  4. <xsl:variable name='text' select='translate($location,"JERSEY","jersey")'/>
  5.  ...
  6. <xsl:when test="$text = 'jersey'">
regards
Sep 22 '08 #15
Bhavs
16
Thanks... It is working fine now........ :)
Sep 22 '08 #16
Dormilich
8,658 Expert Mod 8TB
glad I could help you

regards
Sep 22 '08 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
1
by: Victor | last post by:
Hi, this might sound silly but I cannot figure out how to incorporate some XML of employees into some XML of a company to give new XML containing them all. For example, this is the company now ...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
5
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
4
by: Moogy | last post by:
I'm pulling my hair out here. First, I'm new to XML, so that doesn't help, but none of this makes any sense to me. All I'm trying to do is take a simple source XML file and translate it with an...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
3
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as...
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
15
by: Jeff Uchtman | last post by:
Can I draw from 2 XML sources, the structure is exactly the same execpt for data contained into 1 xslt using math to add some structrure, and displaying others as node 1 and node 2? This data is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.