You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jorg Heymans <jh...@coeno.com> on 2003/05/11 18:50:40 UTC
roll your own serializer
Hi,
I have the following pipeline in sitemap.xmap, added numbers for easy
reference ;)
<map:pipeline>
1)<map:match pattern="/specialrequest"/>
2)<map:generate type="request"/>
3)<map:transform src="specialrequest.xsl"/>
4)<map:serialize type="customserializer"/>
</map:pipeline>
The serializer i wrote implements the "Serializer" interface. I am
writing it because i need to stream back a content type that is not
covered by the existing serializers.
The mechanism generally works...
*but*
The output of the XSL transformation in 3) is an XML document, this
document needs to be used entirely as a parameter format structure for a
service within the serializer in 4). The serializer class receives the
XML as SAX events however, so I need to reconstruct the full XML
document from these events. I was hoping to avoid this.
Is there a way to access the full XML document from the serializer class?
Kind Regards
Jorg Heymans
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: roll your own serializer
Posted by Charles Yates <ce...@stanford.edu>.
OK, I see what you are talking about. My guess is the way you are
doing it is the best. If you want to try something different have a
look at AbstractDOMTransformer. There you have access to the full XML
document by implementing
public Document transform(Document doc)
The way you are doing it now saves you from converting the other
service's output into a Document. And really, as to your original
question, the 'full XML document' never really exists until you put it
together the events in your serializer anyway.
Charles
Jorg Heymans wrote:
> Well the transformer would transform request
> "http://myhost/specialrequest?param1=test1¶m2=test2"
> into something like
>
> <specialrequest>
> <param1 value="test1"/>
> <param2 value="test2"/>
> </specialrequest>
> using the information from the request generator.
>
> this block of XML would then be sent to another service that accepts
> this XML data as a request , does something with it, and streams the
> response back. So i would like to keep the transformed xml as a whole
> and just pass it onto my helper service.
>
> My understanding of the transformer concept is that it accepts SAX
> events and emits SAX events.
>
> Maybe a serializer is not the right place to do this, but somewhere
> within the pipeline i need to generate custom binary data depending on
> the request that comes in.
>
> Hope this clarifies things a bit.
> Jorg
>
> Charles Yates wrote:
>
>> I'm not sure what you mean by 'used entirely as a parameter format
>> structure'. Could you explain that more? Anyway, unless I am
>> mistaken the answer to your question is no. As I understand it
>> serializers contract is just to turn SAX events into a character
>> stream and set a mime type. Any tweaking of the events should be
>> occuring in a transformer. Maybe you should roll your own transformer?
>>
>> Charles
>>
>> Jorg Heymans wrote:
>>
>>> Hi,
>>>
>>> I have the following pipeline in sitemap.xmap, added numbers for
>>> easy reference ;)
>>>
>>> <map:pipeline>
>>> 1)<map:match pattern="/specialrequest"/>
>>> 2)<map:generate type="request"/>
>>> 3)<map:transform src="specialrequest.xsl"/>
>>> 4)<map:serialize type="customserializer"/>
>>> </map:pipeline>
>>>
>>> The serializer i wrote implements the "Serializer" interface. I am
>>> writing it because i need to stream back a content type that is not
>>> covered by the existing serializers.
>>> The mechanism generally works...
>>>
>>> *but*
>>>
>>> The output of the XSL transformation in 3) is an XML document, this
>>> document needs to be used entirely as a parameter format structure
>>> for a service within the serializer in 4). The serializer class
>>> receives the XML as SAX events however, so I need to reconstruct the
>>> full XML document from these events. I was hoping to avoid this.
>>>
>>> Is there a way to access the full XML document from the serializer
>>> class?
>>>
>>>
>>>
>>> Kind Regards
>>> Jorg Heymans
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>>> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: roll your own serializer
Posted by Jorg Heymans <jh...@coeno.com>.
Well the transformer would transform request
"http://myhost/specialrequest?param1=test1¶m2=test2"
into something like
<specialrequest>
<param1 value="test1"/>
<param2 value="test2"/>
</specialrequest>
using the information from the request generator.
this block of XML would then be sent to another service that accepts
this XML data as a request , does something with it, and streams the
response back. So i would like to keep the transformed xml as a whole
and just pass it onto my helper service.
My understanding of the transformer concept is that it accepts SAX
events and emits SAX events.
Maybe a serializer is not the right place to do this, but somewhere
within the pipeline i need to generate custom binary data depending on
the request that comes in.
Hope this clarifies things a bit.
Jorg
Charles Yates wrote:
> I'm not sure what you mean by 'used entirely as a parameter format
> structure'. Could you explain that more? Anyway, unless I am
> mistaken the answer to your question is no. As I understand it
> serializers contract is just to turn SAX events into a character
> stream and set a mime type. Any tweaking of the events should be
> occuring in a transformer. Maybe you should roll your own transformer?
>
> Charles
>
> Jorg Heymans wrote:
>
>> Hi,
>>
>> I have the following pipeline in sitemap.xmap, added numbers for easy
>> reference ;)
>>
>> <map:pipeline>
>> 1)<map:match pattern="/specialrequest"/>
>> 2)<map:generate type="request"/>
>> 3)<map:transform src="specialrequest.xsl"/>
>> 4)<map:serialize type="customserializer"/>
>> </map:pipeline>
>>
>> The serializer i wrote implements the "Serializer" interface. I am
>> writing it because i need to stream back a content type that is not
>> covered by the existing serializers.
>> The mechanism generally works...
>>
>> *but*
>>
>> The output of the XSL transformation in 3) is an XML document, this
>> document needs to be used entirely as a parameter format structure
>> for a service within the serializer in 4). The serializer class
>> receives the XML as SAX events however, so I need to reconstruct the
>> full XML document from these events. I was hoping to avoid this.
>>
>> Is there a way to access the full XML document from the serializer
>> class?
>>
>>
>>
>> Kind Regards
>> Jorg Heymans
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: roll your own serializer
Posted by Charles Yates <ce...@stanford.edu>.
I'm not sure what you mean by 'used entirely as a parameter format
structure'. Could you explain that more? Anyway, unless I am mistaken
the answer to your question is no. As I understand it serializers
contract is just to turn SAX events into a character stream and set a
mime type. Any tweaking of the events should be occuring in a
transformer. Maybe you should roll your own transformer?
Charles
Jorg Heymans wrote:
> Hi,
>
> I have the following pipeline in sitemap.xmap, added numbers for easy
> reference ;)
>
> <map:pipeline>
> 1)<map:match pattern="/specialrequest"/>
> 2)<map:generate type="request"/>
> 3)<map:transform src="specialrequest.xsl"/>
> 4)<map:serialize type="customserializer"/>
> </map:pipeline>
>
> The serializer i wrote implements the "Serializer" interface. I am
> writing it because i need to stream back a content type that is not
> covered by the existing serializers.
> The mechanism generally works...
>
> *but*
>
> The output of the XSL transformation in 3) is an XML document, this
> document needs to be used entirely as a parameter format structure for
> a service within the serializer in 4). The serializer class receives
> the XML as SAX events however, so I need to reconstruct the full XML
> document from these events. I was hoping to avoid this.
>
> Is there a way to access the full XML document from the serializer class?
>
>
>
> Kind Regards
> Jorg Heymans
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org