keys vs templates

A

Andy Chambers

Hi,

I'm generating a stylesheet that will transform all instances of

<xref ref="001"/>

in a document into a fragment like

<ul>
<li>one</li>
<li>two</li>
</ul>

I see two ways of doing this....

1. Define the expansions in a result tree fragment and use a key to
get fast access to the correct expansion Then a single xref match
template looks up the variable using the key to get the appropriate
expansion

<xsl:key name="xdefs" match="xdef" use="id"/>

<xsl:variable name="expansions">
<expansions>
<xdef id="001">
<ul>
<li>one</li>
<li>two</li>
</ul>
</xdef>
</expansions>
</xsl:variable>

2. Define a match template for each expansion

<xsl:template match="xref[@ref='001']">
...
</xsl>

<xsl:template match="xref[@ref='002']">
..
</xsl>


Is one of these approaches better in terms of performance than the
other? Does it make a difference which processor is used?

Cheers,
Andy
 

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,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top