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

Selecting nodes that have an attribute

Subject: Selecting nodes that have an attribute
From: Garrett Coakley <gc@xxxxxxxxxxxxxxxx>
Date: Fri, 27 Aug 1999 17:30:26 +0100 (GMT Daylight Time)
selecting nodes attribute

Hi all,


I'm trying to select a series of nodes, only if they have a certain 
attribute (called yearend). This is a snippet of the XML

<ESTIMATES>
	<ESTIMATE>
		<ANNUALFORECAST yearend="12/1999F">
			<ESTIMATEDATA>
			<SALES name="Sales">25</SALES>
			</ESTIMATEDATA>			
		</ANNUALFORECAST>
		<ANNUALFORECAST yearend="12/2000F">
			<ESTIMATEDATA>
			<SALES name="Sales">27</SALES>
			</ESTIMATEDATA>			
		</ANNUALFORECAST>			
	</ESTIMATE>
	<ESTIMATE>
		<ANNUALFORECAST>
			<ESTIMATEDATA>
			<SALES>25</SALES>
			</ESTIMATEDATA>
		</ANNUALFORECAST>
		<ANNUALFORECAST>
			<ESTIMATEDATA>
			<SALES>27</SALES>
			</ESTIMATEDATA>
		</ANNUALFORECAST>				
		</ESTIMATE>
</ESTIMATES>


And this is the XSL:

<xsl:template match="ESTIMATES">
<xsl:for-each select="ESTIMATE/ANNUALFORECAST[@yearend]">
<TD COLSPAN="5">
<xsl:value-of select="@yearend"/>
</TD>
</xsl:for-each>


I thought that the 'for-each' I have on the second line would only
select ANNUALFORECAST where it had a yearend attribute, but the HTML
that is being produced has a number of extra (empty) table cells. Which
funnily enough corresponds to the total amount of ANNUALFORECAST's in
the branch.


I've been banging my head against this problem for a couple of days now,
and it's got to the stage where I probably couldn't see the right answer
if it landed on my desk in a gold sequinned ballgown.

Have I seriously missed something in the XSLT spec?

Thanks for any help or pointers.


Garrett.

-- 
-----------------------------------------------------------
Garrett Coakley        |  "A man's friendships are one of
Design Engineer        |   the best measures of his worth."
www.community.co.uk    |                     Charles Darwin  


 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.