xsl-list
[Top] [All Lists]

Re: [xsl] External XML Document Caching

2008-11-21 15:56:58
  - 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(_dot_)soa(_at_)gmail(_dot_)com> 
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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>