You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <u....@cbim.it> on 2002/10/16 21:30:30 UTC

Re: Source vs. Generator

A long long time ago Carsten Ziegeler wrote:
> Nearly all generators could be rewritten as sources, for
> example the RequestGenerator could be written as a "request:"
> protocol. But does this make sense - I would say: "No". I 
> think a protocol makes sense if several, different sources
> (documents, pieces of information) can be obtained using this
> protocol. For example using an FTP protocol you can fetch
> several files from the FTP server.
> A request protocol for example addresses only one piece of
> information, the request.

After more than three months, I incurred in a scenario that might 
justify the implementation of a RequestSource.

Say you have an HTML form with a textarea field, where the user is 
allowed to paste an HTML (not XHTML) fragment, maybe because he is using 
some rich text editor that outputs a bunch of invalid HTML, like the MS 
rich text editor for IE or Mozilla's ComposIte [1].

Moreover, say that you want to take this text and convert it to 
well-formed XML with JTidy. You could do it all with some custom action 
or XSP page or custom generator. But wouldn't it be much easier to just 
write something like:

<map:generate type="html" src="request://parameters/parametername"/>

?

Is there's an easier and more elegant alternative? And if there isn't 
one, if I wrote this kind of Source, would it be useful to someone else 
beside me?

	Ugo

[1]: http://composite.mozdev.org/index.html

-- 
Ugo Cei - http://www.beblogging.com/blog/


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


Re: Source vs. Generator

Posted by Vadim Gritsenko <va...@verizon.net>.
Ugo Cei wrote:

> A long long time ago Carsten Ziegeler wrote:
>
>> Nearly all generators could be rewritten as sources, for
>> example the RequestGenerator could be written as a "request:"
>> protocol. But does this make sense - I would say: "No". I think a 
>> protocol makes sense if several, different sources
>> (documents, pieces of information) can be obtained using this
>> protocol. For example using an FTP protocol you can fetch
>> several files from the FTP server.
>> A request protocol for example addresses only one piece of
>> information, the request.
>
>
> After more than three months, I incurred in a scenario that might 
> justify the implementation of a RequestSource.
>
> Say you have an HTML form with a textarea field, where the user is 
> allowed to paste an HTML (not XHTML) fragment, maybe because he is 
> using some rich text editor that outputs a bunch of invalid HTML, like 
> the MS rich text editor for IE or Mozilla's ComposIte [1].
>
> Moreover, say that you want to take this text and convert it to 
> well-formed XML with JTidy. You could do it all with some custom 
> action or XSP page or custom generator. But wouldn't it be much easier 
> to just write something like:
>
> <map:generate type="html" src="request://parameters/parametername"/>
>
> ?
>
> Is there's an easier and more elegant alternative? And if there isn't 
> one, if I wrote this kind of Source, would it be useful to someone 
> else beside me?


I was planning for something similar, but working on 
request/session/application parameters/attributes, with integration with 
xscript variables and webapps.contexts, and (possibly) with JXPath support.

PS These ideas go back to 
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102760517302812&w=2

Vadim


>     Ugo
>
> [1]: http://composite.mozdev.org/index.html



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


Re: Source vs. Generator

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> A long long time ago Carsten Ziegeler wrote:
> 
>> Nearly all generators could be rewritten as sources, for
>> example the RequestGenerator could be written as a "request:"
>> protocol. But does this make sense - I would say: "No". I think a 
>> protocol makes sense if several, different sources
>> (documents, pieces of information) can be obtained using this
>> protocol. For example using an FTP protocol you can fetch
>> several files from the FTP server.
>> A request protocol for example addresses only one piece of
>> information, the request.
> 
> 
> After more than three months, I incurred in a scenario that might 
> justify the implementation of a RequestSource.
> 
> Say you have an HTML form with a textarea field, where the user is 
> allowed to paste an HTML (not XHTML) fragment, maybe because he is using 
> some rich text editor that outputs a bunch of invalid HTML, like the MS 
> rich text editor for IE or Mozilla's ComposIte [1].
> 
> Moreover, say that you want to take this text and convert it to 
> well-formed XML with JTidy. You could do it all with some custom action 
> or XSP page or custom generator. But wouldn't it be much easier to just 
> write something like:
> 
> <map:generate type="html" src="request://parameters/parametername"/>
> 
> ?
> 
> Is there's an easier and more elegant alternative? And if there isn't 
> one, if I wrote this kind of Source, would it be useful to someone else 
> beside me?

A Source is a way of obtaining a piece of information.
A Generator is a way of converting it to XML.

Since all Generators need to obtain a piece of information first, it's 
only logical that every Generator should work from data gotten from a 
Source.

Sometimes it won't be practical, but conceptually it stands, and it adds 
a great deal of flexibility.

As for the Request, we are used to it being an Object per se, but it's 
really an Object *holder*, a reference.
So it's a way of obtaining Objects, not only an Object itself, so it 
should be repackaged as a Source.

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


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


Re: Source vs. Generator

Posted by Andy Lewis <aj...@ascii27.net>.
I could see uses for it - very similar to what you suggest. However I was instead looking into
achiving the same thing with the Request Generator, the Fragment Extractor and internal
pipelines...
> A long long time ago Carsten Ziegeler wrote:
>> Nearly all generators could be rewritten as sources, for
>> example the RequestGenerator could be written as a "request:"
>> protocol. But does this make sense - I would say: "No". I
>> think a protocol makes sense if several, different sources
>> (documents, pieces of information) can be obtained using this
>> protocol. For example using an FTP protocol you can fetch
>> several files from the FTP server.
>> A request protocol for example addresses only one piece of
>> information, the request.
>
> After more than three months, I incurred in a scenario that might  justify the implementation
> of a RequestSource.
>
> Say you have an HTML form with a textarea field, where the user is  allowed to paste an HTML
> (not XHTML) fragment, maybe because he is using  some rich text editor that outputs a bunch of
> invalid HTML, like the MS  rich text editor for IE or Mozilla's ComposIte [1].
>
> Moreover, say that you want to take this text and convert it to
> well-formed XML with JTidy. You could do it all with some custom action  or XSP page or custom
> generator. But wouldn't it be much easier to just  write something like:
>
> <map:generate type="html" src="request://parameters/parametername"/>
>
> ?
>
> Is there's an easier and more elegant alternative? And if there isn't  one, if I wrote this
> kind of Source, would it be useful to someone else  beside me?
>
> 	Ugo
>
> [1]: http://composite.mozdev.org/index.html
>
> --
> Ugo Cei - http://www.beblogging.com/blog/
>
>
> --------------------------------------------------------------------- To unsubscribe, e-mail:
> cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


-- 
"The heights of genius are only measurable by the depths of stupidity."



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