Actions
Bug #2092
closedMultiple Definitions for the Same Key performs badly if the key contains duplicates
Start date:
2014-06-20
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Description
Maybe I got something completely wrong with XSLT key definitions, but for me both key definitions in the XSL are semantically the same resulting in finding nodes by either given a value of 'id17'
or '#id17'
When executing the attached stylesheet on a large (6MB) XML (also attached) it spends a long time in generating the @slowKey@.
This definition is fast
This definition is damn slow
<xsl:key name="SlowKey" match="*" use="@id"/>
Complete Stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<!-- This definition is fast -->
<xsl:key name="FastKey" match="*" use="@id,concat('#', @id)"/>
<!-- This definition is damn slow -->
<xsl:key name="SlowKey" match="*" use="@id"/>
<xsl:key name="SlowKey" match="*" use="concat('#', @id)"/>
<!-- start with the /PLMXML export root -->
<xsl:template match="/PLMXML">
<REPORT>
<xsl:message select="'DIRECT SEARCH: ',ProductRevision[@id eq 'id2']/@id"/>
<xsl:message select="'DIRECT SEARCH: ',ProductRevision[concat('#',@id) eq '#id2']/@id"/>
<xsl:message select="'KEY SEARCH no#: ',key('FastKey', 'id2')/@id"/>
<xsl:message select="'KEY SEARCH with#: ',key('FastKey', '#id2')/@id"/>
<!-- before the next line is printed it takes a long long time -->
<xsl:message select="'KEY SEARCH no#: ',key('SlowKey', 'id2')/@id"/>
<xsl:message select="'KEY SEARCH with#: ',key('SlowKey', '#id2')/@id"/>
</REPORT>
</xsl:template>
</xsl:stylesheet>
Sample lines from source XML
<Header id="id1"/>
<ProductRevision id="id2">
<ApplicationRef/>
<UserData id="id7490">
<UserValue/>
...
<UserValue>
<UserList id="id7486">
<Item/>
<Item/>
<Item/>
...
<Item/>
</UserList>
</UserValue>
<UserValue/>
<UserValue>
<UserList id="id7487"/>
</UserValue>
<UserValue>
<UserList id="id7488"/>
</UserValue>
<UserValue>
<UserList id="id7489"/>
</UserValue>
<UserValue/>
</UserData>
<AssociatedForm id="id39388"/>
</ProductRevision>
<ProductRevision id="id31">
<ApplicationRef/>
<UserData id="id33">
<UserValue/>
<UserValue/>
<UserValue/>
<UserValue/>
<UserValue/>
<UserValue/>
<UserValue/>
<UserValue/>
</UserData>
</ProductRevision>
<ProductRevision id="id36">
<ApplicationRef/>
...
Files
Please register to edit this issue
Actions