Re: testing an attribute value and node value

Subject: Re: testing an attribute value and node value
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Tue, 19 Sep 2000 11:53:45 +1200
Hi Russ,

It appears from your stylesheet namespace that you're using an old version of IE5,
so the following may not work. (Actually, I haven't had time to test it so it may
not work at all.)

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

Do you only want to produce output for certain values of @n? If not, then
you should be fine with this.

<xsl:template match="F">
  <DIV>
      <xsl:if test=". = '1'">
        <b>
          <xsl:value-of select="concat(@n, ' Works')" />
        </b>
      </xsl:if>
  </DIV>
</xsl:template>

Note that your test expression

>       <xsl:when test="@n[.='100' and //F[.='1']]">

is not selecting the parent F element of the @n attribute as you may be
thinking. "//F" selects all F elements in the document. If you want to
test on specific values of @n as well as the contents of F being "1", then
try

<xsl:template match="F">
  <DIV>
      <xsl:if test=". = '1' and @n = '100'"> ...

> My other thought was to alter the XMl slightly so that it had the '1' value
> as an attribute..

Hopefully, it shouldn't be necessary.

Hope this helps.

-- 
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand


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


Current Thread