cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: AW: Questrion about the pipelining
Date Thu, 01 Nov 2001 15:57:12 GMT
Jörn Heid wrote:
> 
> There's no buffering inside the serializer.

The Serializer is given a BufferedOutputStream--so it is the stream that is
doing the buffering.

> The serializer gets the SAX events after the xslt processing. You can test
> that by adding a System.out to the startElement method of the serializer.
> This method is called to late.

Have you tested to ensure that the Transformer's last endElement has been
called before the Serializer's startElement has been called?  It is curious.
Also, is it only the XSLT Transformer?

> It seems there's a huge bug.

I think it is premature to call it a _bug_.  Keep in mind that the markup of
your XSLT can bear alot of wieght on how the thing gets processed.  For instance,
if you have an input XML like this:

<root>
  <element1>
    <element2>
      <element3 foo="bar"/>
    </element2>
  </element1>
  <element4>Some Text</element4>
</root>

and you have an XSL directive like this:

<xsl:template match="/">
  <root>
    <foo><xsl:value-of select="/root/element1/element2/element3/@foo"/></foo>
    <bar><xsl:value-of select="/root/element4"/></bar>
  </root>
</xsl:template>

Then the XSLT engine has to cache all the events until it reaches the desired
element.  That means it has cached elements 1-3 before it could possibly react.

The most efficient transformers will react to the current context alone.  IOW,
I will react to element1 and it's attributes when my template gets hit, and I
won't reference anything else from that template.

A more efficient XSLT markup would be like this:

<xsl:template match="root">
  <root><xsl:apply-templates/></root>
</xsl:template>

<xsl:template match="element3">
  <foo><xsl:value-of select="@foo"/></foo>
</xsl:template>

<xsl:template match="element4">
  <bar><xsl:apply-templates/></bar>
</xsl:template>

<xsl:template match="element1|element2">
  <xsl:apply-templates/>
</xsl:template>

It is a bit more verbose for the same thing, but apply-templates
without any kind of scoping is quicker.

> -----Ursprüngliche Nachricht-----
> Von: Berin Loritsch [mailto:bloritsch@apache.org]
> Gesendet: Donnerstag, 1. November 2001 16:29
> An: cocoon-dev@xml.apache.org
> Betreff: Re: Questrion about the pipelining
> 
> Jörn Heid wrote:
> >
> > As far as I tested my my idea of C2 seems to be wrong.
> >
> > Instead of an contious processing of XML->XSLT->HTML I found about that
> the
> > serializer starts working if all of the xslt processing has finished.
> > Is this right?
> 
> No.  It may seem like that, because the output of the serializer is
> buffered.
> For small pages, it is possible for the entire page to be buffered before
> the buffer fills up.
> 
> --
> 
> "Those who would trade liberty for
>  temporary security deserve neither"
>                 - Benjamin Franklin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


-- 

"Those who would trade liberty for
 temporary security deserve neither"
                - Benjamin Franklin

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message