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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1026)
+ Stylus Studio Technical Forum (12470)
+ Website Feedback (207)
- XSLT Help and Discussion (7042)
-> + Little Help (2)
-> + how do I merge nodes to one sc... (2)
-> - beginner help xslt and xpath (1)
-> - Convert XML Feed to CSV/SQL/XL... (1)
-> - Working with text node. (1)
-> - No Topic (1)
-> - API for XSLT Converter for .NE... (1)
-> - Getting started (1)
-> + saxon sql extensions - mysql a... (2)
-> - How do I copy and create new e... (1)
-> + substring-before and sums (3)
-> + Parsing special characters in ... (2)
-> + Schema - Require attribute in ... (2)
-> - Edit existing XSL files when n... (1)
-> + How can I use one single XSLT ... (2)
-> - Default selection of value in ... (1)
-> - Problem with watermark in pdf ... (1)
-> + XSLT Parameter Values dialog n... (3)
-> + Value of File Name is not acce... (9)
-> - Need help with a complex table... (1)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (1648)
+ Stylus Studio FAQs (158)
+ Stylus Studio Code Samples & Utilities (348)
+ Stylus Studio Announcements (111)
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

   
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-2007 All Rights Reserved.