[xsl] Re: Mad multiple select, and I'm getting it all wrong!!!

Subject: [xsl] Re: Mad multiple select, and I'm getting it all wrong!!!
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 25 Jul 2001 05:32:26 -0700 (PDT)
Daniel Newman wrote:

> I'm writing a select for an apply-templates command, but I'm getting it all
> mixed up. This is what I've written:
> 	<xsl:apply-templates
> 		select="HoldingInformation2Response/Items/Item[class_code =
> 			RetrieveClassInfoRSResponse/Items/Item/ClassCode
> [../DisplayOnInternetSite
> = 'Y']]" />

Yes, this is not correct -- HoldingInformation2Response/Items/Item nodes do not have
children named "RetrieveClassInfoRSResponse".

> And what I want to do, is select all Item nodes from
> HoldingInformation2Response/Items where it's class_code is equal to all
> ClassCode nodes from RetrieveClassInfoRSResponse/Items/Item where
> DisplayOnInternetSite = 'Y'

One class_code value cannot be "equal to all ClassCode nodes" -- most probably you
meant "equal to ***some*** of the ClassCode nodes".

> Here are the nodes in a visual sense:

> <ROOT>
> <HoldingInformation2Response>
> 	<Items>
> 		<Item>
> 			<Holding/>
> 			<class_code>OMN</class_code>
> 			<Available>
> 		</Item>
> 		<Item>
> 			<Holding/>
> 			<class_code>DRP</class_code>
> 			<Available>
> 		</Item>
> 	</Items>
> </HoldingInformation2Response>
> <RetrieveClassInfoRSResponse>
> 	<Items>
> 		<Item>
> 			<ClassCode>OMN</ClassCode>
> 			<DisplayOnInternetSite>N</DisplayOnInternetSite>
> 		</Item>
> 	</Items>
> 	<Items>
> 		<Item>
> 			<ClassCode>DRP</ClassCode>
> 			<DisplayOnInternetSite>Y</DisplayOnInternetSite>
> 		</Item>
> 	</Items>
> </RetrieveClassInfoRSResponse>
> </ROOT>

The above is not well-formed xml -- two unclosed <Available> elements -- I guess
they must be <Available/>.

With all these corrections performed, one possible XPath expression evaluating to
the node-set you (most probably) targeted is:

                                 [DisplayOnInternetSite = 'Y']/ClassCode

This correctly returns one Item node:

  <Holding />
  <Available />

I'd strongly recommend using a tool like the XPath Visualiser that allows a complex
XPath expression to be built in steps, visualizing the results of all intermediate

Hope this helped.

Dimitre Novatchev.

Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger

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

Current Thread