XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Stefan FritzSubject: Joining 2 documents lasts too long
Author: Stefan Fritz
Date: 25 Jul 2005 03:32 AM
Hello,

I'm trying to join 2 XML documents via XSLT.
1. documents contains product information and the 2nd document contains the prices for each product.

The problem is that the prices.xml file is a 3MB file and the products.xml contains about 500 product entries.
It takes about 90 seconds to transform on my machine.
I'm looking for away to reduce the time and would appreciate any input from the XSL gurus. :-)

TIA
Stefan

XSL:

<xsl:stylesheet exclude-result-prefixes="xsl" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no" encoding="UTF-8"/>

<xsl:param name="prices" select="document('prices.xml')"/>

<xsl:template match="/">
<SPRA>
<xsl:call-template name="Header"/>
<Records>
<xsl:apply-templates select="txt2xml/line"/>
</Records>
</SPRA>
</xsl:template>

<!-- only run thi stemplate if the PNR element contains a number-->
<xsl:template match="line[number(PNr)=number(PNr)]">
<xsl:variable name="selector" select="./PNr"/>
<xsl:variable name="priceline" select="$prices/txt2xml/line[PNr=$selector]"/>

<Record>
<Description1>
<xsl:value-of select="PTxt"/>
</Description1>
<Description2>
<xsl:value-of select="STxt"/>
</Description2>
<SupplierItemID>
<xsl:value-of select="PNr"/>
</SupplierItemID>
<ProducerName>
<xsl:value-of select="Man"/>
</ProducerName>
<ProducerItemID>
<xsl:value-of select="MPNr"/>
</ProducerItemID>
<Currency>
<xsl:value-of select="$priceline/Cur"/>
</Currency>
<BuyingUnitPrice>
<xsl:value-of select="$priceline/Cpr"/>
</BuyingUnitPrice>
<GrossSellingPrice>
<xsl:value-of select="$priceline/Lpr"/>
</GrossSellingPrice>
<Stock>
<xsl:value-of select="Avl"/>
</Stock>
<Promotion>0</Promotion>
</Record>-->
</xsl:template>

<xsl:template name="Header">
<Header>
<Company>001</Company>
<Division>001</Division>
<SupplierID>0905</SupplierID>
</Header>
</xsl:template>


<xsl:template match="*"/>

</xsl:stylesheet>

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

Product XML:

<?xml version="1.0"?>
<txt2xml>
<line>
<PNr>101425</PNr>
<ccode>11</ccode>
<LC>D</LC>
<MPNr>C3906A</MPNr>
<EPNr>0088698067819</EPNr>
<Man>HP</Man>
<PTxt>HP Toner LJ 5L/6L/31xx f ca 2500 Seiten</PTxt>
<STxt>Toner EP-A schwarz 2500pgs 5% deckung</STxt>
<Avl>349</Avl>
<Wght>1.000</Wght>
<Gr>Zubeh&#xF6;r</Gr>
<Fam>Druckerzubeh&#xF6;r</Fam>
<Cl>Toner</Cl>
<SCl>A</SCl>
<ABC>Y</ABC>
<MFlag>N</MFlag>
<OHFlag>HP</OHFlag>
<ASTxt>0</ASTxt>
<AFlag>P</AFlag>
<TCode>00</TCode>
<LCode>N</LCode>
</line>

.....
</txt2xml>

Prices XML:
<?xml version="1.0"?>
<txt2xml>
<line>
<PNr>101425</PNr>
<Cpr>63.30</Cpr>
<Lpr>104.90</Lpr>
<Spr>.00</Spr>
<Spv/>
<Cur>CHF</Cur>
<Taxc>1</Taxc>
<Cr/>
<Swico/>
<PCF>N&#xD;</PCF>
</line>

....

</txt2xml>


Posttop
Tony LavinioSubject: Joining 2 documents lasts too long
Author: Tony Lavinio
Date: 15 Aug 2005 11:37 AM
1. Use the XSLT Profiler to determine exactly where the slowdown is.
2. Most likely, using a key will speed the join.
See http://www.w3.org/TR/xslt#key

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.