[xsl] Merging 2 XML's in to 1 output XML (Performance Issue)

Subject: [xsl] Merging 2 XML's in to 1 output XML (Performance Issue)
From: "Kusunam, Srinivas" <SKusunam@xxxxxxxx>
Date: Wed, 12 Oct 2005 10:51:56 -0400
Hi Group,

         This is my first message in this group. Looks like group is
very active and helpful please suggest me something on this.


I have InputXSL1   & InputXML2 which needs to be combined in to
OutputXML based on some conditions say for each record in InputXSL1 with
Key match in InputXSL2 get all the  child elements in InputXSL2 and
append to InputXSL1's Node.

Size of Input Files can go up to 100MB (MAX).
Environment:   JDK-1.4.2_06   \   xalan-j_2_7_0

I have written simple Style sheet to do this but to process 10MB file it
is taking around 14mins and which is definitely not acceptable. Please
suggest me if this is common with XSLT (as everybody say that XSLT is
not efficient for Large Input files). What are the alternatives to do
this?

InputXSML1:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<st:VehicleTDoc>

	<st:VehicleTT>
		<xdd:DFFileId>213044</xdd:DFFileId>
		<xdd:RSNo>10</xdd:RSNo>
		<xdd:SNameAddGroup>
			<xdd:SAddRoleCode>P</xdd: SAddRoleCode >
		</xdd:SNameAddGroup>
	</st: VehicleTT >
</st: VehicleTDoc>

InputXML2:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<st:VehicleTDoc>

	<st:VehicleTT>
		<xdd:DFFileId>213044</xdd:DFFileId>
		<xdd:RSNo>10</xdd:RSNo>
		<xdd:SName>
			<xdd:RoleCode>Primary</xdd:RoleCode>
		</xdd:SName>
	</st: VehicleTT >
</st: VehicleTDoc>

XSL:
<xsl:stylesheet version="1.0">

<xsl:output method="xml" indent="yes" />

<xsl:variable name="aggregator" select="document('InputXML2.xml')" />

<xsl:template match="/">
	<st:VehicleTDoc>
  		<xsl:apply-templates/>
	</st:VehicleTDoc>
</xsl:template>

<xsl:template match="//st:VehicleTT">

    <st:VehicleTT>
	    <xsl:copy-of select="*"/>
    <xsl:apply-templates
select="$aggregator/st:VehicleTDoc/st:VehicleTT[xdd:DFFileId=current()/x
dd:DFFileId and xdd:RSNo=current()/xdd:RSNo][1]/xdd:SName" />
    </st:VehicleTT>
</xsl:template>

<xsl:template match="xdd:SName">
	<xsl:copy-of select="current()" />
</xsl:template>

</xsl:stylesheet>

Instead of hard coding some of the tags I can actually get it from the
current node but my main problem is performance of the main task. Looks
like this call is taking lot of time......
xsl:apply-templates
select="$aggregator/st:VehicleTDoc/st:VehicleTT[xdd:DFFileId=current()/x
dd:DFFileId and xdd:RSNo=current()/xdd:RSNo][1]/xdd:SName" />

I really appreciate any comments and suggestions.

Thanks,
Sree

Current Thread