Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - >Thread Next - Re: [xsl] More Efficient way of mathching ID's [xsl] More Efficient way of mathching ID'sTo: Date: 4/3/2006 8:24:00 PM Hi Everyone, thanks in advance for the help.
I have an xsl file that looks up elements in one xml file, and inserts
them into another. Pretty common problem on the web and on this list.
I was able to get it working, however the processing is excruciatingly
slow. Was wondering if anyone had some thoughts on speeding up
performance?
*** Combine.xsl ***
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="fIntents" select="document('Reference.xml')"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="sentence">
<xsl:variable name="mykey" select="@qpid"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="$fIntents//sentence[@qpid =
$mykey]/intentref"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
*** Without.xml ***
<?xml version="1.0"?>
<document>
<article qpid="004243">
<title>Test test Test Test Test</title>
<sentence qpid="007309">
<text>
Test test Test Test Test</text>
</sentence>
</article>
<change-begin/>
<article qpid="004244">
<title>Test test Test Test Test</title>
<sentence qpid="007310">
<text>Test test Test Test Test</text>
</sentence>
<sentence qpid="007311">
<text>Test test Test Test Test</text>
</sentence>
</article>
</document>
*** Reference.xml ***
<?xml version="1.0"?>
<document>
<article qpid="004243">
<title>Test2 Test2 Test2 Test2 Test2</title>
<sentence qpid="007309"><intentref ref="int1"/>
<text>Test2 Test2 Test2 Test2 Test2</text>
</sentence>
</article>
<change-begin/>
<article qpid="004244">
<title>Test2 Test2 Test2 Test2 Test2</title>
<sentence qpid="007310"><intentref ref="int2"/>
<text>Test2 Test2 Test2 Test2 Test2</text>
</sentence>
<sentence qpid="007311"><intentref ref="int3"/>
<text>Test2 Test2 Test2 Test2 Test2</text>
</sentence>
</article>
</document>
*** With.xml (My Output, Exactly what I need) ***
<?xml version='1.0' ?>
<document>
<article qpid="004243">
<title>Test test Test Test Test</title>
<sentence qpid="007309"><intentref ref="int1"/>
<text>
Test test Test Test Test</text>
</sentence>
</article>
<change-begin/>
<article qpid="004244">
<title>Test test Test Test Test</title>
<sentence qpid="007310"><intentref ref="int2"/>
<text>Test test Test Test Test</text>
</sentence>
<sentence qpid="007311"><intentref ref="int3"/>
<text>Test test Test Test Test</text>
</sentence>
</article>
</document>
As a note, reference.xml is much much bigger than this small test and
will have all the qpid's I need to deal with the qpid's in without.xml
file,, as well as a bunch more that will not be needed. I hope this
illustrates what I' trying to do.
Spencer | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
