RE: [xsl] selecting for variable based on attribute

Subject: RE: [xsl] selecting for variable based on attribute
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 18 Aug 2006 17:21:27 +0100
Both the items in your example have @hardware='0', so why would you expect
the condition [@hardware ne '0'] to select them?

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Rick Roen [mailto:Rick@xxxxxxxxxxxxxxxxxx] 
> Sent: 18 August 2006 17:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] selecting for variable based on attribute
> 
> XSLT 2.0
> 
> I have an xml like this snippet: 		
> 
> <items>
>       <item print="1" hardware="0" packetdescription="FLOWER " sku="">
> 			<itemnum>3</itemnum>
> 			<location>687</location>
> 			<qty_order>5</qty_order>
> 			<qty_ship>5</qty_ship>
> 			<upc>051178000033</upc>
> 			<rack>1</rack>
> 			<tray>1</tray>
> 			<pocket>2</pocket>
> 			<name>ALYSSUM BASKET GOLD</name>
> 			<eta/>
> 			<retail>1.49</retail>
> 			<cost>0.708</cost>
> 			<total>3.54</total>
> 		</item>
> 		<item print="1" hardware="0" packetdescription="FLOWER "
> sku="">
> 			<itemnum>4</itemnum>
> 			<location>686</location>
> 			<qty_order>5</qty_order>
> 			<qty_ship>5</qty_ship>
> 			<upc>051178000040</upc>
> 			<rack>1</rack>
> 			<tray>1</tray>
> 			<pocket>3</pocket>
> 			<name>ALYSSUM CARPET OF SNOW</name>
> 			<eta/>
> 			<retail>0.99</retail>
> 			<cost>0.470</cost>
> 			<total>2.35</total>
> 		</item>...
> 	</items>
> 
> And an xslt snippet like this:
> 
> 			<xsl:variable name="rack" 
> select="items/item[rack castable as xs:integer and tray 
> castable as xs:integer and pocket castable as xs:integer and 
> @hardware ne '0' ]"/>
> 
> This returns an empty sequence for $rack.  When I leave out 
> the "@hardware ne '0'" then it returns what I would expect, 
> i.e. the items/item.
> 
> How do I test for the hardware attribute <> 0?
> 
> 
> Rick

Current Thread