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

Stuck on how to properly use 'preceding' axis

Subject: Stuck on how to properly use 'preceding' axis
From: Rusty Morton <rusty_morton@xxxxxxxxx>
Date: Wed, 12 Jul 2006 13:34:28 -0700 (PDT)
axis schemalocation
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

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.