This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: testing an attribute value and node value


At 10:11 AM 09/19/2000 +1200, Russ Holmes wrote:
>I'm trying to test the value of an attribute and the value of the node, but
>am having trouble with the test expression.
>...
>I want to generate HTML for each node 'F' dependent on the value of the 'n'
>attribute and the value of the current node.
>My XSL looks like;

Need to change a few things in the stylesheet:
1. Change the namespace URI for the xsl: prefix. The one you're using is 
for a long out-of-date Microsoft IE version, which no one (including MS) 
recommends any longer.

2. Add a version="1.0" attribute to your <xsl:stylesheet> element.

3. Add a template for your root node.

4. Remove the xsl:choose structure and replace it with a simple xsl:if, and 
simplify the test condition.

The following stylesheet works with IE5 (July preview release), Saxon, and xt:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:html="http://www.w3.org/TR/REC-html40">

   <!-- Might want to use the HTML output method, too -->

   <xsl:template match="/">
     <html>
       <body>
         <xsl:apply-templates />
       </body>
     </html>
   </xsl:template>

   <xsl:template match="F">
     <DIV>
       <!-- Need to test for values of F other than 1?
       If so, you'll need to go back to the xsl:choose/:when
       structure. -->
       <xsl:if test=".=1"><B><xsl:value-of select="@n"/> Works</B></xsl:if>
     </DIV>
   </xsl:template>

</xsl:stylesheet>


==========================================================
John E. Simpson               | "If you were going to
http://www.flixml.org         | shoot a mime, would you use
XML Q&A: http://www.xml.com   | a silencer?" (Steven Wright) 


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]