cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject Re: Redirect in XSP
Date Sat, 09 Nov 2002 02:31:49 GMT
What causes </HEAD> to be sent? Let's assume you have a pipe consisting 
of a generator, a transformer and a serializer. Normally the XSP creates 
SAX events for a XML like this:

   <title>test page</title>
   <paragraph>A short sentence.</paragraph>

But in some special cases a redirect shoud happen:

   <redirect url=""/>

And the transformer can look like:

<xsl:template match="page">
       <xsl:apply-templates select="title | redirect"/>
       <xsl:apply-templates select="paragraph"/>

<xsl:template match="title">
   <xsl:copy-of select="."/>

<xsl:template match="redirect">
   <meta http-equiv="Refresh" content="0; URL={@url}"/>

<xsl:template match="paragraph">

Who should close the <head/> element? The transformer can not send an 
endElement() until everything inside is processed. Of course you have to 
process <redirect/> in <head/> independent where it was written in the 
original XML.

Even if the generated XML is much more complex and the <redirect/> 
element is created as last beneath thousands of other elements, if you 
use a stylesheet similar to the above one, which says "process this 
<redirect/> now, because I want to have it as child of <head/>", the SAX 
event for endElement() of <head/> can't be sent to the serializer.

I don't want to say something wrong, but let me speak in pictures: A 
pipe is not a single lane tube, where the first car, which gets in, is 
the first car, which must get out. A transformer can disturb this 
perfect organisation. Let it be a car park, where everything can get 
mixed up: If all the cars come out of the tube and have to wait at the 
car park until the last car comes also out, because this one must be the 
first, which gets into the next tube, it will be obviously bad, but not 
impossible. (If the car park is full, you will have an OutOfMemoryError 
or a NoMoreDTMIdsException. ;-) Furthermore this shows, how important 
well structured XML and good stylesheets are. Especially the usage of 
"//redCars" has to search all cars for red ones.

Does this make it a bit clearer? Everybody can of course improve my 
"model" ;-) What about structured car transports or child cars?



Artur Bialecki wrote:
> Hi Joerg,
> I was under the impression that once generation started
> sax events go through tarnsformers and a serializer and
> data is sent back to the browser. So if the <redirect url="any"/>
> is emitted after the tags that caused </HEAD> to be sent
> to the browser this would not work.
> Would it?
> Artur...
>>-----Original Message-----
>>From: Joerg Heinicke [] 
>>Sent: November 8, 2002 7:42 PM
>>Subject: Re: Redirect in XSP
>>Hi Artur,
>>where is the problem?
>>Instead of <xsp-response:send-redirect url="any"/> you create a own 
>>element like <redirect url="any"/> in the XML. This is processed by a 
>>transformer to <meta http-equiv="Refresh" content="0; URL=any"/> and 
>>sent to the browser. Even if it's a very poor solution, there 
>>shell be 
>>no problem with it. I prefer the test while setting up the pipeline.
>>Artur Bialecki wrote:
>>>>-----Original Message-----
>>>>From: Ilya A. Kriveshko [] 
>>>>Sent: November 8, 2002 10:41 AM
>>>>Subject: Re: Redirect in XSP
>>>>If you want to redirect the browser to a new URL after the
>>>>pipeline has been constructed and the generation has (possibly)
>>>>started, you can do that by outputting the <META> tag in the
>>>>output HTML.
>>>><meta http-equiv="Refresh" content="0; URL=/some/local/url"/>
>>>><meta http-equiv="Refresh" content="0; 
>>>>"0" means no delay.
>>>How would this work if half of my page has already been
>>>sent to the browser including the </HEAD> tag?
>>>Please clarify.

Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message