[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|