cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: taking output of XSP
Date Sat, 02 Sep 2000 19:22:39 GMT
Jeremy Quinn <jermq@media.demon.co.uk> wrote:
>Hi All,
>
>What with the talk of a new dynamic <xsp:element/> tag, I'd like to bring
>up another possible modification to XSP.
>
>
>The FP TagLib has a Tag that directs it's contents to an external file as
>opposed to the output document.
>
>	<fp:write to="file" as="node" select="blah">
>		<request:get-parameter name="blah"/>
>	</fp:write>
>
>This works fine, request:get-parameter outputs an Element to fp:write.
>
>But if someone wants to do this:
>
>	<fp:write to="file" as="node" select="." mode="insert-after">
>		<blah>
>			<title><request:get-parameter name="title"/></title>
>			<body><request:get-parameter name="body"/></body>
>			<flag><request:get-parameter name="checkbox" default="false"/></flag>
>		</blah>
>	</fp:write>
>
>It all becomes rather complicated (or do I misunderstand?).
>
>The fp:write Tag would have to take over xspCurrentNode and probably muck
>around with the Node Stack, both of which I understand are not recommended!
>
>Can I safely take over xspCurrentNode etc. or do we need a new mechanism
>for this?
>

I think we could use a new mechanism. It would be quite useful to have a 
clean "redirect output" solution - at the moment, to mail some XML or write 
out some XML, or whatever, is a bit hacky.

First I thought in terms of DOM only. How about not adding elements to the 
tree until the close tag is reached - so that xspCurrentNode can be 
redirected somewhere else by a taglib, and then reassigned to stop it  being 
added to the document? But this would not work with SAX, and it also breaks 
any code that relies on walking up the tree via the DOM (because then you 
would not be able to walk up the tree via DOM from the current node at all, 
whether you were redirecting output or not!).

So how about a <xsp:redirect-output> tag? With SAX in C2 you could specify a 
DocumentHandler:

  <xsp:redirect-output to="org.greenrd.MyMailHandler"/>
    <to>greenrd@hotmail.com</to>
    <message>Dinner's ready, dear</message>
  </xsp:redirect-output>

Whereas with DOM in C1 the "to" attribute could be ignored for some weak 
semblance of "forward-compatibility", and

(a) The generated code would not add any of xsp:redirect-output's direct 
children to the tree
(b) The specific taglib involved would be responsible for shipping off the 
xspCurrentNode to its new destination at the end.

Obviously this is not compatible between C1 and C2. But changing one or two 
templates from DOM to SAX like this shouldn't be too hard.

Any better ideas?



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Mime
View raw message