D
Darren Gilroy
I was wondering if there was a way to cache a built xsl:key?
I have a custom resolver that returns a DOM when
"document('Assets.xml')" is requested, but the stylesheet takes some
amount of time to generate the key. If we could cache the built key
(along with the DOM?) then we would be one step ahead. I'm using
Xalan 2.5.1.
Note the key is built on the document referenced by the document()
call, NOT the main source document.
I have a stylesheet similar to the following:
<xsl:stylesheet>
<xsl:key name="kAssetById" match="Asset" use="id"/>
<xsl:variable name="assetDoc" select="document('Assets.xml')/Assets"/>
<xsl:template match="Fragment">
<xsl:variable name="assetId" select="@parentAssetId">
<xsl:for-each select="$assetDoc">
<xsl:apply-templates select="key( 'kAssetById', $assetId )">
</xsl:for-each>
</xsl:template>
<xsl:template match="Asset">
[some pretty output]
</xsl:template>
</xsl:stylesheet>
and the input:
<Page>
<Fragment parentAssetId="abc"/>
<Fragment parentAssetId="def"/>
<Fragment parentAssetId="ghi"/>
<Fragment parentAssetId="jkl"/>
</Page>
Thanks,
Darren
I have a custom resolver that returns a DOM when
"document('Assets.xml')" is requested, but the stylesheet takes some
amount of time to generate the key. If we could cache the built key
(along with the DOM?) then we would be one step ahead. I'm using
Xalan 2.5.1.
Note the key is built on the document referenced by the document()
call, NOT the main source document.
I have a stylesheet similar to the following:
<xsl:stylesheet>
<xsl:key name="kAssetById" match="Asset" use="id"/>
<xsl:variable name="assetDoc" select="document('Assets.xml')/Assets"/>
<xsl:template match="Fragment">
<xsl:variable name="assetId" select="@parentAssetId">
<xsl:for-each select="$assetDoc">
<xsl:apply-templates select="key( 'kAssetById', $assetId )">
</xsl:for-each>
</xsl:template>
<xsl:template match="Asset">
[some pretty output]
</xsl:template>
</xsl:stylesheet>
and the input:
<Page>
<Fragment parentAssetId="abc"/>
<Fragment parentAssetId="def"/>
<Fragment parentAssetId="ghi"/>
<Fragment parentAssetId="jkl"/>
</Page>
Thanks,
Darren