Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] More Efficient way of mathching ID's

From: "Spencer Tickner" <spencertickner@--------->
To:
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent