xsl-list
[Top] [All Lists]

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

2006-07-12 13:35:11
Hi All,

I recently posted the same issue under a different
subject but have had no responses. I believe I may not
have expressed my problem correctly so here it goes:

PROBLEM: Trying to return a distinct list of
'DistributorCode' values for each 'Item' node. My
expression using the preceding axis is not removing my
duplicates (most likely due to my noobness of
understanding the language).

-------MY SAMPLE XML:----------
<Items
xmlns:loader="http://xxx/loader/1.0";;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";;
xsi:schemaLocation="http://xxx/ns/pioneer/1.0
http://xxx/xsd/pioneer.xsd";;>
- <Item ItemId="640308"
createDate="2002-10-30T10:06:24Z"
lastChangeDate="2006-03-29T12:27:13Z">
  <CatalogNumber>123456</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>
  <Item Id = "xxxxx">
    ....thousand more Items..
</Items>


--------My v1.0 XSLT code:----------

<xsl:variable name="distributorVal">    
<!-- only process distributorCodes if canShip
andcanOrder 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> 



----Current Results Returned based on Code used
above---
stringvalue="SIG,ARG,FRA,SIG,EME,FRA,SIG,EME,FRA" 


-------Result set I want to have-----------
stringvalue="SIG,ARG,FRA,EME" 


I am hoping its simply an alteration of the tag:
  <xsl:if test="//ItemAsSold[not(DistributorCode =
preceding::DistributorCode)]">

I have tried a number of different methods to no
avail..PLEASE help!!

Thanks,

-Rusty
                                        


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>