RE: [xsl] Conditional branching on string attribute in IE5?

Subject: RE: [xsl] Conditional branching on string attribute in IE5?
From: cknell@xxxxxxxxxx
Date: Mon, 30 Dec 2002 18:38:30 -0500
Try this approach. It worked with MSXSL and XALAN parsers.

<?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
    <xsl:template match="info[contains(@path, '.jpg')]">
      <xsl:element name="a">
        <xsl:attribute name="img">
          <xsl:value-of select="@path" />
        </xsl:attribute>
      </xsl:element>
    </xsl:template>
  </xsl:stylesheet>

The output was:
<?xml version="1.0" encoding="UTF-8"?>

 <a img="abc.jpg" />

-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     drsystems@xxxxxxxx
Sent:     Mon, 30 Dec 2002 08:13:59 +0500 (IST)
To:       XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  [xsl] Conditional branching on string attribute in IE5?

Hi,

This is for IE5. For an XML file like:
<xml>
 <info path="abc.txt">
 <info path="abc.jpg">
</xml>
  
I want to check the value of xml/info/path,
and if it contains a .jpg or .gif extension, 
generate an img node, else generate an
href node.

I tried the following:
.
<xsl:for-each select="xml/info">
 <xsl-if test="contains(@path,'.jpg')">
   <xsl-element name="a">
    ..
and got an error, "Unknown method contains(@".

What is the right way to do this for IE5?
Upgrade to IE6 is not an option :-(
This is urgent, and I am stuck at this.
Please help out a new XSL enthusiast! :)

Thanks,


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread