testing an attribute value and node value

Subject: testing an attribute value and node value
From: "Russ Holmes" <rholmes@xxxxxxxxx>
Date: Tue, 19 Sep 2000 10:11:03 +1200
I'm trying to test the value of an attribute and the value of the node, but
am having trouble with the test expression.

My XML is;

<?xml version='1.0'?>
<PageData>
       <CUSTOM>
            <F n="100">1</F>
            <F n="101">1</F>
       </CUSTOM>
</PageData>

I want to generate HTML for each node 'F' dependent on the value of the 'n'
attribute and the value of the current node.

So, if current node n="100" and the current node value = '1' then output

    <B>100 Works</B>

if current node n="101" and the current node value = '1' then output

    <B>101 Works</B>

My XSL looks like;

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";
xmlns:html="http://www.w3.org/TR/REC-html40";>


<xsl:template match="/">
<HTML >
  <HEAD>
    <TITLE>Practice.pgMatths</TITLE>
  </HEAD>
  <BODY >
        <xsl:apply-templates select="//F"/>
  </BODY>
</HTML></xsl:template>

<xsl:template match="F">
<DIV>
  <xsl:choose>
      <xsl:when test="@n[.='100' and //F[.='1']]"><B>100
Works</B></xsl:when>
      <xsl:when test="@n[.='101' and  //F[.='1']]"><B>101
Works</B></xsl:when>
  </xsl:choose>
 </DIV>

</xsl:template>

</xsl:stylesheet>

This fails when you change one of the node values to something other than
'1'.
What's up with my test?

My other thought was to alter the XMl slightly so that it had the '1' value
as an attribute..
<F n="100" on="1"/>.  Would this be easier?

Thanks

Russ






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


Current Thread