This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Mad multiple select, and I'm getting it all wrong!!!
- To: daniel dot newman at bis-web dot com
- Subject: [xsl] RE: Mad multiple select, and I'm getting it all wrong!!!
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Wed, 25 Jul 2001 06:30:06 -0700 (PDT)
- Cc: xsl-list at lists dot mulberrytech dot com
- Reply-To: xsl-list at lists dot mulberrytech dot com
--- Daniel Newman <daniel.newman@bis-web.com> 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