Does xslt engine supports xml stream level transformations?

After xslt transformations users may want to do further processing with the
message. So in that case we can avoid building request Axiom object but may
required to create the transformed Axiom object.

thanks,
Amila.

On Sat, Sep 15, 2012 at 4:16 PM, Andun Sameera <an...@wso2.com> wrote:

> Hi All,
>
> My requirement is $Subject. Purpose of this is avoid using AXIOM to to
> XSLT transformation. Our plan was to do all the transformation using Input,
> Output Streams. javax.xml.transform.Transformer is used to do
> the transformation using streams. I developed the mediator using
> the following logic,
>
>
>    - In the Binary Relay We get the Message as a Data Handler in a Dummy
>    SOAP Message. From that we can get a Input Stream for the SOAP message
>    which needs to be transformed using XSLT.
>    - We can Get the input Stream for the XSLT file, which is in registry
>    or local.
>    - Using those two we can do the XSLT transformation. As a result we
>    get a stream for the transformed SOAP message.
>    - Finally I create a DataHandler using the stream and attached it to
>    the Relay's Dummy SOAP message replacing existing one.
>
> The output of the mediator follows this logic is given below. I used the 
> Sample
> 8<http://wso2.org/project/esb/java/4.0.3/docs/samples/message_mediation_samples.html#Sample8>of
>  ESB. I replaced the XSLT mediator with my custom mediator in the Binary
> Relay.
> But there is a major problem here. Because of the logic we used the
> original SOAP message,
>
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header
> xmlns:wsa="http://www.w3.org/2005/08/addressing";><wsa:To>
> http://localhost:9000/services/SimpleStockQuoteService</wsa:To><wsa:MessageID>urn:uuid:0f7403b4-c5bc-4347-8921-562f2736a2ab</wsa:MessageID><wsa:Action>urn:getQuote</wsa:Action></soapenv:Header><soapenv:Body><m0:CheckPriceRequest
> xmlns:m0="http://services.samples
> "><m0:Code>IBM</m0:Code></m0:CheckPriceRequest></soapenv:Body></soapenv:Envelope>
>
>  is now converted to.
>
> <m:getQuote xmlns:m="http://services.samples";>
>    <m:request>
>       <m:symbol>IBM</m:symbol>
>    </m:request>
> </m:getQuote>
>
> At the end Binary Relay Formatter will read the DataHandler and above SOAP
> message will be sent to the AXIS2 Server and It will crash, because this is
> not a valid SOAP message.
> This problem occurs because we are not using AXIOM anymore. In the normal
> XSLT mediator it uses org.apache.synapse.util.xpath.SourceXPathSupport
> class to find the part of the message which transformed using XSLT. So it
> can replace the transformed part of the original message. But here we cant
> use that kind of a logic. Because we use only streams. We cant build
> OMElements or etc.
>
> Need help to solve this problem. The custom mediator java files are
> attached here.
>
> Thanks
> AndunSLG
>
> References :
>
> [1] -
> http://wso2.org/project/esb/java/4.0.3/docs/samples/message_mediation_samples.html#Sample8
>
>
> Console Output for the Custom Mediator :
>
> .....................Original SOAP Envelop..........................
> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope";><soapenv:Body><ns:binary
> xmlns:ns="http://ws.apache.org/commons/ns/payload
> ">PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48c29hcGVudjpFbnZlbG9wZSB4bWxuczpzb2FwZW52PSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VudmVsb3BlLyI+PHNvYXBlbnY6SGVhZGVyIHhtbG5zOndzYT0iaHR0cDovL3d3dy53My5vcmcvMjAwNS8wOC9hZGRyZXNzaW5nIj48d3NhOlRvPmh0dHA6Ly9sb2NhbGhvc3Q6OTAwMC9zZXJ2aWNlcy9TaW1wbGVTdG9ja1F1b3RlU2VydmljZTwvd3NhOlRvPjx3c2E6TWVzc2FnZUlEPnVybjp1dWlkOjBmNzQwM2I0LWM1YmMtNDM0Ny04OTIxLTU2MmYyNzM2YTJhYjwvd3NhOk1lc3NhZ2VJRD48d3NhOkFjdGlvbj51cm46Z2V0UXVvdGU8L3dzYTpBY3Rpb24+PC9zb2FwZW52OkhlYWRlcj48c29hcGVudjpCb2R5PjxtMDpDaGVja1ByaWNlUmVxdWVzdCB4bWxuczptMD0iaHR0cDovL3NlcnZpY2VzLnNhbXBsZXMiPjxtMDpDb2RlPklCTTwvbTA6Q29kZT48L20wOkNoZWNrUHJpY2VSZXF1ZXN0Pjwvc29hcGVudjpCb2R5Pjwvc29hcGVudjpFbnZlbG9wZT4=</ns:binary></soapenv:Body></soapenv:Envelope>
>
> ................................................................................
>
> .....................Original SOAP Message........................
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header
> xmlns:wsa="http://www.w3.org/2005/08/addressing";><wsa:To>
> http://localhost:9000/services/SimpleStockQuoteService</wsa:To><wsa:MessageID>urn:uuid:0f7403b4-c5bc-4347-8921-562f2736a2ab</wsa:MessageID><wsa:Action>urn:getQuote</wsa:Action></soapenv:Header><soapenv:Body><m0:CheckPriceRequest
> xmlns:m0="http://services.samples
> "><m0:Code>IBM</m0:Code></m0:CheckPriceRequest></soapenv:Body></soapenv:Envelope>
>
> ................................................................................
>
> Transforming On Progress.....
>
> ...................Transformed SOAP Message...................
> <m:getQuote xmlns:m="http://services.samples";>
>    <m:request>
>       <m:symbol>IBM</m:symbol>
>    </m:request>
> </m:getQuote>
>
> ..............................................................................
>
> ...................Transformed SOAP Envelop..................
> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope";><soapenv:Body><ns:binary
> xmlns:ns="http://ws.apache.org/commons/ns/payload
> ">PG06Z2V0UXVvdGUgeG1sbnM6bT0iaHR0cDovL3NlcnZpY2VzLnNhbXBsZXMiPgogICA8bTpyZXF1ZXN0PgogICAgICA8bTpzeW1ib2w+SUJNPC9tOnN5bWJvbD4KICAgPC9tOnJlcXVlc3Q+CjwvbTpnZXRRdW90ZT4K</ns:binary></soapenv:Body></soapenv:Envelope>
>
> ..............................................................................
>
>


-- 
*Amila Suriarachchi*

Software Architect
WSO2 Inc. ; http://wso2.com
lean . enterprise . middleware

phone : +94 71 3082805
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to