cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Dolg <steven.d...@indoqa.com>
Subject Re: [Documentation] Develop a Generator
Date Wed, 14 Jan 2009 09:58:11 GMT
Carlos Tejo Alonso schrieb:
> [Sorry for the last empty email.]
>
> Hello,
>
>   
>>> I was looking for documentacion about "how to develop a 
>>>       
>> Generator" and
>>     
>>> "how to develop a serializer". This is the last documentation that I
>>> have found:  [1] and [2].
>>>
>>> Is this documentation the properly one to create generators for
>>> Cocoon-3? 
>>>   
>>>       
>> The documentation mentioned is specific for Cocoon 2.2.
>>     
>
> :-(
>  
>   
>> Unfortunately we have very little documentation for Cocoon 3 
>> as of this 
>> time and none of that contains anything about writing custom 
>> generators 
>> or serializers, I'm afraid.
>> So at this moment I can only suggest to have a look at the generators 
>> and serializers already available and come back with specific 
>> questions.
>>     
>
>   
>> The module "cocoon-optional" contains some custom generators and 
>> serializers contributed recently by Simone Tripodi - they all are 
>> compatible with the other SAX components from Cocoon 3.
>> So this may be a good starting point (I assume you intend to build 
>> generators/serializers for XML processed with SAX).
>>     
>
> That's the situation:
>
> I want to extract information using different "ways" (http, svn, cvs).
> This information is encoded using different formats (xml, .odt). The
> result of the generator or the generator+transformer should be the same
> information in an intermediate format.
> I would like to know if I have to develop a generator for the "way" and
> a transformer to the intermediate format or I just need to develop a
> transformer.
>
>   
The SAX generators currently available in Cocoon 3 retrieve data using 
URLs and connections opened on those URLs.
In most cases this mechanism allows to uniformly access different input 
sources as the protocol handling deals with the actuals transport 
mechanisms.
So reading directly from file:// or from http://... makes no difference 
to the generator.
As long as your protocol is already covered by the runtime, you should 
be fine (svn://... will require an additional library or 
URLStreamHandler implementation).

The other point is the actual format.
The SAX generators actually expect XML and cannot process .odt or .csv 
files directly.
That would require a new generator no matter which protocol is used to 
retrieve the data.

The general assumption is that a generator delivers the content of the 
source as is and that transformers perform the necessary changes.
However no one keeps you from creating a generator that produces the 
correct XML from the CSV directly.


To summarize my suggestion:
* If you can handle all required protocols with the URL resolution of 
Java, you don't need to care about the actual protocol.
* Produce a generator for each format you need to process: .odt, .csv; 
XML is already available
* Use either an existing Transformer (e.g. XSLTTransformer) or create a 
specialized transformer that handles the conversion to your intermediate 
format.

If you intent to do the transformation with a specialized transformer, 
StAX might be an interesting alternative as modifying the XML data is 
usually less complicated (but a bit slower than SAX)
Please keep in mind that the StAX components are pretty new and probably 
still need some refinement - they haven't seen as much action as their 
SAX counterparts... ;-)


Regards,
Steven

>> I am willing to offer as much assistance as my time schedule 
>> allows and 
>> answer any question that may arise.
>>     
>
> Thanks!
>
> Regards,
>
> Carlos Tejo
>
>   


Mime
View raw message