Re: [xsl] External XML Document Caching

Subject: Re: [xsl] External XML Document Caching
From: "Vasu Chakkera" <vasucv@xxxxxxxxx>
Date: Fri, 21 Nov 2008 20:56:30 +0000
>   - Implement the lookup table in a XSL file, specifying the mappings
> outside the <xsl:templates> so that they are not rendered. The XSL


I have done some "Look Up Table" operation using the XSL Files. This
of course follows that this lookup table is bound to the XSL world and
not used anywhere else..

If you defined named templates that accepts a param , which would be a "key"
and a simple if then else logic in the template to check for the key
and return the value.

something like

<xsl:template name="hashtable">
		<xsl:param name="key"/>
		<xsl:choose>
			<xsl:when test="$key = 'foo'">
	 foo value
			</xsl:when>
			<xsl:when test="$key = 'bar'">
	 bar value
			</xsl:when>
		</xsl:choose>
	</xsl:template>
** OR ***
	<xsl:function name ="myns:hashtable">
		<xsl:param name="key"/>
		<xsl:value-of select="if($key = 'foo') then 'fooval' else if($key =
'bar') then 'barval' else()"/>
	</xsl:function>


and you can call the function myns:hashtable(key)

This may mean that you have to rearrange your  lookup XML to look like
these templates and you can not use the lookup xml as is.

There has been times when i had to decide about using external XML as
a look up Data source or simply define these templates... THe decision
is on the requirement really. Both work depending on the problem.
These templates will be a good choice if the data and lookup is not
too messy and it is fairly straight forward.

I havent seen your posting but this is similar to what I had done in past.

Vasu

On Fri, Nov 21, 2008 at 6:25 PM, raulvk <raulvk.soa@xxxxxxxxx> wrote:
> Hi everyone,
>
> We are using XSL to carry out XML-to-XML tranformation and one of the
> main functionalities we are using it for is to map specific values of
> the source message to predetermined values in the result message by
> using a lookup table implemented in XML. (Please check out
> http://www.stylusstudio.com/xsllist/200811/post40460.html for a more
> detailed explanation).
>
> In this case, the lookup table is implemented in an external XML file
> (not inside the stylesheet, as is in the referenced post).
>
> Since the external XML file is going to be accessed VERY frequently,
> and it will be accessed from multiple stylesheets (it is reusable), I
> really don't want the XML file being loaded from disk into memory and
> being parsed every single time it is accessed, since this can cause
> serious performance problems.
>
> The external file is accessed via the document('...') function.
>
> My question number 1: Do XSLT processors cache external referenced XML files?
>
> Question number 2: Do you recommend any strategies to optimise the
> query to the external XML file? I have considered the following, but I
> am unsure as how each of them can improve performance:
>   - Using the xsl:key + key function on the external document('...') file.
>   - Implement the lookup table in a XSL file, specifying the mappings
> outside the <xsl:templates> so that they are not rendered. The XSL
> file would offer a named template to recover the desired mapping. The
> stylesheets that want to obtain a mapping would <xsl:import> the
> appropriate mapping stylesheet and invoke the template at the point
> where the value should be inserted.
>
> Any clues?
>
> Many thanks in advance!
>
> Raul.
>
>



-- 
Vasu Chakkera
Numerical Algorithms Group Ltd.
Oxford
www.vasucv.com

Current Thread