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

XSL For-Each Help!

Subject: XSL For-Each Help!
From: Rusty Morton <rusty_morton@xxxxxxxxx>
Date: Mon, 17 Jul 2006 12:17:54 -0700 (PDT)
xsl for each help
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

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.