[xsl] Newbie Key Function issue

Subject: [xsl] Newbie Key Function issue
From: Kurt Geiger <kgeiger@xxxxxxxxxxxxxx>
Date: Fri, 6 Jul 2001 10:29:31 -0400
I am using a stylsheet to produce a new XML file from a source file and
during the transformation lookup nodes in an external document.  The Key
function works well but it is so SLOWWWWWWWW.  Can anyone take a look below
and see if there is anyway to refine or filter my lookup in order to speed
this process up??  
Any help would be great.

I have the following key and reference document in my StyleSheet.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:key name="ODCust" match="Entity" use="//Entity/EntityId/@value" />
<xsl:variable name="CustFile" select="document('ODCust.xml')" />
<xsl:output omit-xml-declaration="yes" />.......


I supply the function with a value and change the context using
<xsl:for-each .....>.  


<xsl:template name="Entities">
<xsl:variable name = "keyValue" select="//Entity/EntityId" />
<xsl:for-each select="$CustFile"> 			
				<xsl:variable name="EntNode"
select="key('ODCust', $keyValue[position()=1])" />
					<xsl:element name="EntityType" >
						<xsl:attribute
name="value"><xsl:value-of
select="$EntNode/EntityType/@value"/></xsl:attribute>
						<xsl:attribute
name="type"><xsl:value-of
select="$EntNode/EntityType/@type"/></xsl:attribute>
						<xsl:attribute
name="id"><xsl:value-of select="$EntNode/EntityType/@id"/></xsl:attribute>
						<xsl:attribute
name="label"><xsl:value-of
select="$EntNode/EntityType/@label"/></xsl:attribute>
						<xsl:attribute
name="turnaround"><xsl:value-of
select="$EntNode/EntityType/@turnaround"/></xsl:attribute>
						<xsl:attribute name="min"
><xsl:value-of select="$EntNode/EntityType/@min"/></xsl:attribute>
						<xsl:attribute name="max"
><xsl:value-of select="$EntNode/EntityType/@max"/></xsl:attribute>
						<xsl:attribute
name="elementid">0098</xsl:attribute>
					</xsl:element>
				<!---Bunch More Element Declarations Similar
to Above etc... -->
		</xsl:for-each>
</xsl:template>
	
This is an example of what the $CustFile contains (There are about ten
thousand entity Nodes in that doc)

<Entity>
   <EntityType value="ST" type="code" label="" id="n1_entitytype_1"
turnaround="yes" min="1" max="17" elementid="0098">
   </EntityType>

   <EntityName value="OFFICE DEPOT" type="tabledata" label=""
id="n1_entityname_1" turnaround="yes" min="1" max="60" elementid="0093">
   </EntityName>

   <EntityIdType value="93" type="code" label="" id="n1_entityidtype_2"
turnaround="yes" min="1" max="17" elementid="0066">
   </EntityIdType>

   <EntityId value="0001" type="tabledata" label="" id="n1_entityid_2"
turnaround="yes" min="1" max="80" elementid="0067">
   </EntityId>

   <Address1 value="3301 NORTH STATE ROAD #7" type="" label="Street Address"
id="n3_address1_1" turnaround="yes" min="1" max="55" elementid="0166">
   </Address1>

   <City value="LAUDERDALE LAKE" type="tabledata" label="" id="n4_city_1"
turnaround="yes" min="1" max="30" elementid="0019">
   </City>

   <State value="FL" type="tabledata" label="" id="n4_state_1"
turnaround="n1_entityidtype_1" min="1" max="2" elementid="0166">
   </State>

   <PostalCode value="33319" type="tabledata" label="" id="n4_postalcode_1"
turnaround="yes" min="1" max="15" elementid="0116">
   </PostalCode>
</Entity>

Kurt G.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread