Caching xsl:key with document Source

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top