[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Stuck on how to properly use 'preceding' axis


Subject: Re: [xsl] Stuck on how to properly use 'preceding' axis
From: Rusty Morton <rusty_morton@xxxxxxxxx>
Date: Wed, 12 Jul 2006 17:11:46 -0700 (PDT)

Thanks for the help Jason!

You are absolutely right on the EME value - it should
not be shown as well. 

I tweaked your solution just a little since i have to
store the value in a variable - and got it to work
using the following:

<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>


Though the above worked - and did in fact remove
duplicates, it also removed some unique values as
well.
The logic above seems to be also removing values if
the CanOrderFlag ='false'OR CanShipFlag = 'false' in
any nodes following the first. When I need it to
return any distinct values within any of the
<ItemsAsMade> nodes where it satisfies the
CanOrder/Ship condition.
For example, seethe sample XML below.....

- <ItemsAsMade>
- <ItemAsMade>
  <ManufacturerCode>SHO</ManufacturerCode> 
  <SupplierCode>SHO</SupplierCode> 
  <Currency>USD</Currency> 
  - <ItemsAsSold>
    - <ItemAsSold>
        <DistributorCode>UKI</DistributorCode> 
        <CanOrderFlag>true</CanOrderFlag> 
        <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
        <DistributorCode>MEX</DistributorCode> 
        <CanOrderFlag>true</CanOrderFlag> 
        <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
        <DistributorCode>INS</DistributorCode> 
        <CanOrderFlag>true</CanOrderFlag> 
        <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
        <DistributorCode>ROM</DistributorCode> 
        <CanOrderFlag>true</CanOrderFlag> 
        <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
        <DistributorCode>SHC</DistributorCode> 
        <CanOrderFlag>false</CanOrderFlag> 
        <CanShipFlag>false</CanShipFlag> 
      </ItemAsSold>
    </ItemsAsSold>
  </ItemAsMade>
- <ItemAsMade>
  <ManufacturerCode>SHC</ManufacturerCode> 
  <SupplierCode>SHC</SupplierCode> 
  <Currency>EUR</Currency> 
  - <ItemsAsSold>
    - <ItemAsSold>
       <DistributorCode>BER</DistributorCode> 
       <CanOrderFlag>true</CanOrderFlag> 
       <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
       <DistributorCode>UKI</DistributorCode> 
       <CanOrderFlag>true</CanOrderFlag> 
       <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
       <DistributorCode>INS</DistributorCode> 
       <CanOrderFlag>false</CanOrderFlag> 
       <CanShipFlag>false</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
       <DistributorCode>ROM</DistributorCode> 
       <CanOrderFlag>false</CanOrderFlag> 
       <CanShipFlag>false</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
       <DistributorCode>MEX</DistributorCode> 
       <CanOrderFlag>false</CanOrderFlag> 
       <CanShipFlag>false</CanShipFlag> 
      </ItemAsSold>
    - <ItemAsSold>
       <DistributorCode>SHC</DistributorCode> 
       <CanOrderFlag>true</CanOrderFlag> 
       <CanShipFlag>true</CanShipFlag> 
      </ItemAsSold>
  </ItemsAsSold>
 </ItemAsMade>
</ItemsAsMade>


--------Using the modified Code above, I now get the
following resultset-----

stringvalue="UKI,SHC"

--------When I should be getting the following
results------------
stringvalue="UKI,MEX,INS,ROM,SHC"


It has to be close, I tried moving the
CanOrderFlag/Ship into an xsl:if test outside the
loop, but that failed.
Any more help would be greatly appreciated!!!

Thanks!

-Rusty


Current Thread
Keywords
xml