This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Performance problem in transformation


I am trying to filter out duplicate records from   input XML document.
If  I have around 80 records in the XML document and out of which 43 are

unique, transformation is taking forever to complete.  (the size of this

input XML document is 223K)

Can you suggest any better ways of  removing duplicate records ?

Following is my stylesheet code

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:lxslt="http://xml.apache.org/xslt";
    xmlns:java="http://xml.apache.org/xslt/java";
    version="1.0">

<!-- These parameters should be set by the caller of this stylesheet -->



<!-- Get the number of records -->
<xsl:variable name="count" select="count(//sales_orders_sd_doc)"/>

<xsl:variable name="unique-list"
select="//sales_orders_sd_doc[not(.=following::sales_orders_sd_doc)]" />

<xsl:variable name="unique-count" select="count($unique-list)" />


<!-- Main template -->
<xsl:template match="/event">
 <ROOT message="test">
 <!-- Calling outer-loop template -->
 <xsl:call-template name="outer-loop">
 </xsl:call-template>
 </ROOT>
</xsl:template>

<!-- outer-loop template -->
<xsl:template name="outer-loop">

    <!-- Set a counter to start with 1 -->

 <xsl:param name="counter" select="1"/>
 <xsl:param name="counter2" select="1"/>
 <xsl:param name="docNumber" select="$unique-list[$counter2]"/>

 <xsl:choose>
 <xsl:when test="$docNumber=/event/sales_orders_sd_doc[$counter]">
 <xsl:param name="test" select="1"/>
 <Row>
  <AA>
         <xsl:value-of select="/event/sales_orders_base_uom[$counter]"/>

        </AA>
  <C>
         <xsl:value-of select="/event/sales_orders_dlv_qty[$counter]"/>
        </C>
  <BBB>
         <xsl:value-of
select="/event/sales_orders_exchg_rate_v[$counter]"/>
        </BBB>
  <D>
         <xsl:value-of select="/event/sales_orders_sd_doc[$counter]"/>
        </D>
 </Row>
 <!-- Check the counter -->
     <xsl:if test="$unique-count >= $counter2">
     <!-- If counter is less than count call template inner-loop -->
        <xsl:call-template name="outer-loop">
    <!-- Increment the counter and pass it to the template -->
          <xsl:with-param name="counter2" select="($counter2)+ 1"/>
    <xsl:with-param name="counter" select="1"/>
         </xsl:call-template>
     </xsl:if>
 </xsl:when>
 <xsl:otherwise>
 <!-- Check the counter -->
     <xsl:if test="$count > $counter">
     <!-- If counter is less than count call template inner-loop -->
        <xsl:call-template name="outer-loop">
    <!-- Increment the counter and pass it to the template -->
          <xsl:with-param name="counter" select="($counter)+ 1"/>
    <xsl:with-param name="counter2" select="$counter2"/>
        </xsl:call-template>
     </xsl:if>

 </xsl:otherwise>
 </xsl:choose>
</xsl:template>

</xsl:stylesheet>


Thanx in advance!
Shashank


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]