[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
xsl test node value
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.