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

Re: selecting then conditional test

Subject: Re: selecting then conditional test
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 09 Oct 2000 15:05:35 +0100
first conditional test
Jason,

>My xsl is as follows:
>
><xsl:template match="alljobs">
><xsl:for-each select="job/item1[not(.=following::job/item1)]">
>  <xsl:sort/>
>  <xsl:if test="ancestor::job/item1!='N/A'">
>    <xsl:value-of select="."/>
>  </xsl:if>
></xsl:for-each>
>
>I've also tried: <xsl:if test="//item1!='N/A'">
>
>Unfortunately these don't work. I eliminate the duplicates and sort it but
>the if statement doesn't work. What am I doing wrong? Thanks for your help!

The second (//item1 != 'N/A') doesn't work because you're testing there
whether *any* item1 in the document doesn't equal 'N/A', which is always true.

The first does work, at least in Saxon, although you could simplify things
by only selecting those item1s that don't equal N/A in the first place:

<xsl:for-each select="job/item1[not(. = 'N/A' or . = following::job/item1)]">
  <xsl:sort/>
  <xsl:value-of select="."/>
</xsl:for-each>

This produces only 'one' and 'two' with both Saxon and Xalan (although with
no carriage return between them - you have to add that yourself using
xsl:text).

I hope that helps,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 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.