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

RE: Mad multiple select, and I'm getting it all wrong!

Subject: RE: Mad multiple select, and I'm getting it all wrong!!!
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 25 Jul 2001 06:30:06 -0700 (PDT)
multiple select email
--- Daniel Newman <daniel.newman@xxxxxxxxxxx> wrote:
> sorry to have bothered you guys, as I'd found my error about 2 minutes after
> I'd sent this out!!! Doh. But I guess it helped to write it all up. Thanks
> anyway.
> 
> If you're all still in a helping frame of mind, maybe you could have a go at
> this little problem I'm having:
> 
> I have this parameter I'm passing to a template:--
> 
> <xsl:with-param name="Amount">
> 	<xsl:choose>
> 		<xsl:when test="class_code != 'OMN' ">
> 			<xsl:value-of  select="Holding" />
> 		</xsl:when>
> 		<xsl:otherwise>
> 			<xsl:value-of  select="Holding div 100" />
> 		</xsl:otherwise>
> 	</xsl:choose>
> </xsl:with-param>
> 
> And I want to tidy the code up. I've tried:--
> 
> <xsl:with-param name="Amount" select="Holding[../class_code != 'OMN'] |
> (Holding div 100)" />
> 
> But it keeps saying that the brackets do not evaluate to a node set.

This is true -- you're trying to obtain the union of a node-set with a number ...

> 
> What I'm trying to do, is return Holding most of the time, but return
> Holding divided by 100 when class_code = 'OMN'.
> 
> It sort of worked without the brackets (in that it didn't complain), but it
> was dividing everything by a hundred, which is why I tried to only apply the
> division on the second statement.
> 
> What am I doing wrong?
>


I guess (again) that you want to conditionally specify two different numeric values.
However, in your original source xml "Holding" were empty elements!

Therefore I changed them to contain numbers like this:

<ROOT>
<HoldingInformation2Response>
	<Items>
		<Item>
			<Holding>1200</Holding>
			<class_code>OMN</class_code>
			<Available/>
		</Item>
		<Item>
			<Holding>800</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>

In case my guess is right, then here's an example how this can be done (decide for
yourself whether this is really "tidying up" :o) ):


/ROOT/HoldingInformation2Response/Items/Item[1]/Holding 
* number(/ROOT/HoldingInformation2Response/Items/Item[1]/class_code != 'OMN') 

+

/ROOT/HoldingInformation2Response/Items/Item[1]/Holding 
* number(/ROOT/HoldingInformation2Response/Items/Item[1]/class_code = 'OMN') div 100

This will return 12.

/ROOT/HoldingInformation2Response/Items/Item[2]/Holding 
* number(/ROOT/HoldingInformation2Response/Items/Item[2]/class_code != 'OMN') 

+

/ROOT/HoldingInformation2Response/Items/Item[2]/Holding *
number(/ROOT/HoldingInformation2Response/Items/Item[2]/class_code = 'OMN') div 100

This will return 800


Hope this helped.

Cheers,
Dimitre Novatchev.



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.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.