|
Subject: [xsl] XSL For-Each Help! From: Rusty Morton <rusty_morton@xxxxxxxxx> Date: Mon, 17 Jul 2006 12:17:54 -0700 (PDT) |
Hi All,
Please see the below, I am in desperate need to
resolve this issue and cannot figure it out for the
life of me...
----Problem----:
I am trying to obtain a distinct list of
values('DistributorCodes') for each 'Item' from a
large XML file containing thousands of items.
----Needs-----:
I need to store the result in a variable within my
stylesheet in order to satisfy other dependencies
---Sample XML-----:
<Items>
<Item ID="1234">
<ItemsAsMade>
<ItemAsMade>
<SupplierCode>SHO</SupplierCode>
<ItemsAsSold>
<ItemAsSold>
<DistributorCode>MEX</DistributorCode>
<CanOrder>true</CanOrder>
<CanShip>true</CanShip>
</ItemAsSold>
<ItemAsSold>
<DistributorCode>CAN</DistributorCode>
<CanOrder>false</CanOrder>
<CanShip>false</CanShip>
</ItemAsSold>
<ItemAsSold>
<DistributorCode>USA</DistributorCode>
<CanOrder>true</CanOrder>
<CanShip>true</CanShip>
</ItemAsSold>
</ItemsAsSold>
</ItemAsMade>
<ItemAsMade>
<SupplierCode>SHC</SupplierCode>
<ItemsAsSold>
<ItemAsSold>
<DistributorCode>CAN</DistributorCode>
<CanOrder>true</CanOrder>
<CanShip>true</CanShip>
</ItemAsSold>
<ItemAsSold>
<DistributorCode>USA</DistributorCode>
<CanOrder>false</CanOrder>
<CanShip>false</CanShip>
</ItemAsSold>
<ItemAsSold>
<DistributorCode>MEX</DistributorCode>
<CanOrder>false</CanOrder>
<CanShip>false</CanShip>
</ItemAsSold>
</ItemsAsSold>
</ItemAsMade>
</ItemsAsMade>
</Item>
.....lots more Items...
</Items>
-----My Current Stylesheet snippet-----
<xsl:variable name="distributorVal">
<!-- only process distributorCodes if canShip and
canOrder are both true -->
<xsl:for-each
select="//ItemAsMade/ItemsAsSold/ItemAsSold[CanOrderFlag
='true'][CanShipFlag = 'true'][not(DistributorCode =
preceding::DistributorCode)]/DistributorCode">
<xsl:value-of select="."/>
<xsl:text>,</xsl:text>
</xsl:for-each>
</xsl:variable>
---Curent results based on above code------
CAN
---Expected results---------------------
MEX,CAN,USA
---Findings--------------------
It seems that if any second <ItemAsMade> element
within the <ItemsAsMade> has a 'false' value it
overrides the first <ItemAsMade> even if that one is
set to true, where as if either <ItemAsMade> has both
the canorder and canship flags set to true then that
distributor should be extracted.
---Plea for Help--------------------
PLEASE...PLEASE....can any of you UBER Gods of XSL
help me!!
I have been mucking with this for the past week and
cannot figure it out!
Thanks!!
-Rusty
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Matching elements based o, Florent Georges | Thread | Re: [xsl] XSL For-Each Help!, Wendell Piez |
| Re: [xsl] Re: Keeping a running tot, Steve | Date | Re: [xsl] Re: Keeping a running tot, didoss |
| Month |