A naive implementation of the document() function is likely
to do this. However happily, by implementing the
javax.xml.transform.URIResolver interface [1], and setting
this on the Tranformer using setURIResolver [2] you can easily
plug in a simple cache (e.g. hash of URL versus retrieved content)
that avoid multiple network overheads.

I have a sample implementation and simple test harness
if anyone wants it.

Cheers,

L.


[1]. http://java.sun.com/j2se/1.4/docs/api/javax/xml/transform/URIResolver.html
[2].
http://java.sun.com/j2se/1.4/docs/api/javax/xml/transform/Transformer.html#setURIResolver(javax.xml.
transform.URIResolver)

> -----Original Message-----
> From: Ilya A. Kriveshko [mailto:ilya@;kaon.com]
> Sent: 05 November 2002 14:33
> To: [EMAIL PROTECTED]
> Subject: Poor performance of document() in XSL [Was: Re: simpel cocoon
> question]
>
>
> SAXESS - Hussayn Dabbous wrote:
>
> > <snip/>
> > But you also could do it directly within the xslt context:
> > You can use the document() function in your XSLT-file.
> > This function allows you to refer to data contained within
> > another XML-file. This is completely decoupled from cocoon
> > though. It's more about how to work with XSLT:
> > <snip/>
>
>
> In the past I have encountered a nasty performance problem with document().
> For example, when you declare an xsl variable that gets its value from a
> document(),
> and then use its value several times throughout the stylesheet, the URI
> of the document
> gets hist as many times as there are references to that variable. I.e.
> the xsl variable
> does not store the XML fragment it was given at the variable definition
> time, but
> merely stores the XPath string and then resolves it every time it's
> referenced.
> This may or may not be true for XPath expressions that do not contain
> document()
> as well. Does anyone know for sure?
>
> Example:
>
> <xsl:variable name="test-me"
> select="document('cocoon:/gimme-sumthn')/sumthn/in/@there"/>
>
> <xsl:template match="/">
>   <this-is-just-a-test>
>     <xsl:value-of select="$test-me"/>
>     <xsl:value-of select="$test-me"/>
>     <xsl:value-of select="$test-me"/>
>   </this-is-just-a-test>
> </xsl:template>
>
> When using Xalan, this example will cause the Cocoon pipeline that
> is responsible for "gimme-sumthn" to be hit three times. I say,
> document() is good for rapid prototyping, but is a poor choice for final
> deployment for performance reasons. Use aggregation instead.
>
> +2c
> --
> Ilya
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to