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

"not a node item" inside distinct-values

Subject: "not a node item" inside distinct-values
From: "Rick Roen" <Rick@xxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Jun 2006 08:56:40 -0500
xpath not a node item
XSLT 2.0
XML Spy

I have the following snippet of xml:

	<item racknum="1" traynum="7" pocketnum="11" itemnum="176"
qty_ship="12">SQUASH BENNINGS GREEN TINT</item>
	<item racknum="1" traynum="7" pocketnum="12" itemnum="177"
qty_ship="42">SQUASH BLACK BEAUTY</item>
	<item racknum="1" traynum="7" pocketnum="13" itemnum="178"
qty_ship="18">SQUASH EARLY PROLIFIC STRAIGHT NECK</item>
	<item racknum="2" traynum="8" pocketnum="1" itemnum="179"
qty_ship="12">SQUASH EARLY SUMMER CROOKNECK</item>
	<item racknum="2" traynum="8" pocketnum="2" itemnum="180"
qty_ship="6">SWISS CHARD FORDHOOK GIANT</item>
	<item racknum="2" traynum="8" pocketnum="3" itemnum="183"
qty_ship="24">TOMATO CELEBRITY HYBRID</item>
	<item racknum="2" traynum="8" pocketnum="4" itemnum="204"
qty_ship="24">TOMATO FLAVOR KING HYBRID</item>
	<item racknum="2" traynum="8" pocketnum="5" itemnum="186"
qty_ship="30">WATERMELON CRIMSON SWEET</item>
	<item racknum="2" traynum="8" pocketnum="6" itemnum="205"
qty_ship="12">WATERMELON SUGAR BABY</item>


I want to get the largest @pocketnum for each @racknum, i.e. racknum = 1
largest pocketnum = 13, racknum = 2 largest pocketnum = 6

My XSLT is like this:

<xsl:for-each select="distinct-values(//item/@racknum)">
	<xsl:variable name="rack-num" select="."/>
	<xsl:variable name="pocket-num" select="//item[./@racknum =
$rack-num and position() = last()]"/>
	<p>Rack: <xsl:value-of select="$rack-num"/> max pocket:
<xsl:value-of select="$pocket-num"/></p>
</xsl:for-each>

I get an error "Error in XPath 2.0 expression Not a node item"

Oustide of the <xsl:for-each... I can use:
 
<xsl:value-of select="//item[./@racknum = 2 and position() =
last()]/@pocketnum"/>

and get the results I expect, i.e. 6.

This must have something to do with the context within the "for-each", but I
can't figure out how to get the information.

Any suggestions?

Rick

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.