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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all - I am trying to do the

Status
Not open for further replies.

chael

Programmer
May 31, 2002
192
US
Hi all -

I am trying to do the following in my XSL but XMLSpy keeps telling me that I have an 'unknown method'. I can't figure this out...what am I doing wrong?

<xsl:attribute name=&quot;class&quot;>
<xsl:if test=&quot;contains(.,'xyz')&quot;/>ClassNameHere
</xsl:attribute>
 
well, I couldn't figure out what I was doing wrong so I put it into a javascript function:

<xsl:attribute name=&quot;class&quot;>
<xsl:eval no-entities=&quot;1&quot;>GetClass(this.text)</xsl:eval>
</xsl:attribute>

with the following function:

function GetClass(node)
{
var sOutput;
var sInput;

sInput = new String(node);
sOutput = sInput.substr(sInput,1);

if (sOutput == '(') {
return 'Negative'; }
else {
return 'Regular'; }
}

Not quite how I wanted to do this, but it works.

Does anyone know what I was doing wrong initially?
 
Hi Chael!

The problem is the msxml version.
In the version you are currently using doesn't accept the
contains(.,'xyz') function.

Even if you have installed the msxml3, if you star your xsl with
<xsl:stylesheet xmlns:xsl=&quot;you will be under older version rules.

To use the &quot;contains&quot; function you have to install msxml3 at least (or the most recent msxml4) parser.

Check out at:

Moreover, instead of using that code above to start you xsl file, you have to use the following bellow:

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;
However, you will no be able to use &quot;eval&quot; if you start the xsl like this.

Cheers!
Humberto Seiji Fukuda

kogu@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top