[xsl] Unable to remove duplicates using XSLT v1.0

Subject: [xsl] Unable to remove duplicates using XSLT v1.0
From: Rusty Morton <rusty_morton@xxxxxxxxx>
Date: Tue, 11 Jul 2006 15:30:24 -0700 (PDT)
Sample XML output:

<Items
xmlns:loader="http://strykercorp.com/ns/pioneer/loader/1.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://strykercorp.com/ns/pioneer/1.0
http://pioneer.strykercorp.com/xsd/pioneer.xsd";>
- <Item ItemId="640308"
createDate="2002-10-30T10:06:24Z"
lastChangeDate="2006-03-29T12:27:13Z">
  <CatalogNumber>3044-0005</CatalogNumber> 
  <CEMark>CE0086</CEMark> 
-   <ItemsAsMade>
-    <ItemAsMade>
       <ManufacturerCode>SHC</ManufacturerCode> 
       <SupplierCode>SHC</SupplierCode> 
       <Currency>EUR</Currency> 
-      <ItemsAsSold>
-       <ItemAsSold>
          <DistributorCode>SIG</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>ARG</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
          </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>FRA</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
      </ItemsAsSold>
    </ItemAsMade>
-    <ItemAsMade>
       <ManufacturerCode>END</ManufacturerCode> 
       <SupplierCode>END</SupplierCode> 
       <Currency>US</Currency> 
-      <ItemsAsSold>
-       <ItemAsSold>
          <DistributorCode>SIG</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>EME</DistributorCode> 
          <CanOrderFlag>false</CanOrderFlag> 
          <CanShipFlag>false</CanShipFlag> 
          </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>FRA</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
      </ItemsAsSold>
    </ItemAsMade>
-    <ItemAsMade>
       <ManufacturerCode>BIO</ManufacturerCode> 
       <SupplierCode>BIO</SupplierCode> 
       <Currency>US</Currency> 
-      <ItemsAsSold>
-       <ItemAsSold>
          <DistributorCode>SIG</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>EME</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>false</CanShipFlag> 
          </ItemAsSold>
-       <ItemAsSold>
          <DistributorCode>FRA</DistributorCode> 
          <CanOrderFlag>true</CanOrderFlag> 
          <CanShipFlag>true</CanShipFlag> 
        </ItemAsSold>
      </ItemsAsSold>
    </ItemAsMade>
   </ItemsAsMade>
  </Item>


----------------------------------------

using the following v1.0 XSLT code:

<xsl:variable name="distributorVal">	
<!-- only process distributorCodes if canShip and
canOrder are both true -->
  <xsl:for-each select="*/ItemAsMade">
   <xsl:for-each select="*/ItemAsSold">
     <xsl:if test="(CanOrderFlag = 'true') and
(CanShipFlag = 'true')">
       <xsl:if test="//ItemAsSold[not(DistributorCode
= preceding::DistributorCode)]">
						<xsl:value-of select="DistributorCode" /
        <xsl:text>,</xsl:text>
      </xsl:if>
    </xsl:if>
  </xsl:for-each>
 </xsl:for-each>
</xsl:variable>



<xsl:call-template name="attrvalue_template">
  <xsl:with-param name="stringValue"
select="substring($distributorVal, 1,
string-length($distributorVal)-1)" />
</xsl:call-template>	

-------------------------------------

But, this still returns the duplicates:
stringvalue="SIG,ARG,FRA,SIG,EME,FRA,SIG,EME,FRA" 

What is the proper language formating so I can get the
following result:
stringvalue="SIG,ARG,FRA,EME" 	


Thanks in advance for the help!

Current Thread