Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contains Function - Need help soon

Status
Not open for further replies.

k8277

Programmer
Jan 10, 2003
104
US
I was tasked with modifying an xsl file and I know very little about xsl/xml.

I need to read the value of a node and then determine if it contains a string value. I have been researching xpath and the contains function but I am having problems.

I found this link on here: I think it solves my problem because I was using this at the top of my xsl file:

<xsl:stylesheet xmlns:xsl="
and it says I need to use:

<xsl:stylesheet version="1.0" xmlns:xsl="
However, I do use "eval" and according to the thread I cited, I can't if I use the second refernce. I don't want to modify the xsl file too much.


Is there any other options or can I do my string test without using the contains function?
 
Dont use eval, theres no need for it.

To test for a string is the same as to test whether the node contains anything at all. So just use:
Code:
<xsl:if test="mynode">.......

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Thanks,

So can I replace my existing line of code:

Code:
<xsl:eval>formatNumber(parseFloat(this.selectSingleNode("SalesOrder/Total").text),"$#,###,###,###.00")</xsl:eval>

With this:

Code:
<xsl:if test="formatNumber(parseFloat(this.selectSingleNode("SalesOrder/Total").text),"$#,###,###,###.00")"></xsl:if>
 
Those bits of code are doing different things. Top one is formatting the number. Bottom one is an if statement (which won't work). Explain what you are trying to achieve and post the relevant code.

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
You said I don't need the "eval" code -- what is the "eval" code doing in the first example? I assumed the formatnumber function was doing a format, so I was just trying to get rid of the eval code.
 
Eval allows you to use some script. If you really want to use script, you can do so using extension functions. However, you can accomplish most tasks in XSL without the need for script (there is a built-in function called format-number).

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top