You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Hiranya Jayathilaka <hi...@gmail.com> on 2010/05/01 11:35:38 UTC

Re: Local Entires with CDATA Elements

Hi Indika,

On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>wrote:

> Hiranya ... it seems that as Andreas pointed out in ws commons list, the
> working with Axiom in non coalescing can be a risk.
>

Yes. Actually that discussion helped me understand a lot. It seems the
existing logic in Synapse+Axiom for handling local entries with CDATA
elements is correct after all. The problem with serialization I pointed out
in my previous mail is to be expected. Even though the serialized XML is
lexically different from the input XML, their XML infosets are equal. Even
though AXIOM has removed CDATA tags, the text has been encoded to escape any
invalid characters like '<'.

All in all I think we can live with the existing logic. We can resolve
SYNAPSE-624 as 'not a bug'. However there are few things that need be
properly communicated to the users through our docs.

1. If a local entry text contains any XML markup the whole text must be
wrapped in CDATA tags

eg: <localEntry
key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>

2. If a local entry text contains XML markup and CDATA tags then we should
properly escape the CDATA tags to avoid having nested CDATA elements.
(Nested CDATA elements cause XML parser to throw a parse exception)

eg: <localEntry
key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>

3. XML local entries with CDATA elements will not have the CDATA tags in the
serialized version

I have updated the test cases to cover all these scenarios and the expected
behavior.

Thanks,
Hiranya


>
> is the 'coalescing' off/on a system property ?  and if  not  , is there any
> way to create a new parser instance in non coalescing mode only for synapse
> configuration parsing ?
>
> Thanks
>
> Indika
>
> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka <hiranya911@gmail.com
> > wrote:
>
>> Hi Folks,
>>
>> While doing some work on SYNAPSE-624, I have realized that Synapse does
>> not handle local entry values with CDATA elements properly. Axiom seems to
>> drop CDATA elements while parsing XML. For an example given the following
>> local entry configuration:
>>
>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
>>
>> the serialized XML would be as follows:
>>
>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
>>
>> Note that the CDATA element is gone, and its value has been partially
>> encoded. The way out of this issue is to disable coalescing in the parser.
>> But that would be globally applied to all XML parsing logic in Synapse
>> (unless we somehow use a separate OM builder for parsing local entries). So
>> how do you think we should handle this scenario?
>>
>> Thanks
>> --
>> Hiranya Jayathilaka
>> Software Engineer;
>> WSO2 Inc.;  http://wso2.org
>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>> Blog: http://techfeast-hiranya.blogspot.com
>>
>
>


-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Local Entires with CDATA Elements

Posted by Kasun Indrasiri <ka...@gmail.com>.
On Sun, May 2, 2010 at 7:00 PM, Andreas Veithen
<an...@gmail.com>wrote:

> On Sun, May 2, 2010 at 05:58, Kasun Indrasiri <ka...@gmail.com> wrote:
> > Hi all,
> > So, are we going to live with coalescing parsing in Synapse? As
> > per SYNAPSE-280 which is pointed out by Andreas what are the benefits
> that
> > we can get from using non-coalescing mode in Synapse and in that case are
> we
> > planning to move to non-coalescing in the future?
> > And even though we resolve SYNAPSE-624 as 'not-a but', I guess
> > replacing OMText#getText by OMElement#getText() is still applicable.
>
> I don't see any reason why we should not fix the code to make proper
> use of OMElement#getText().
>
That was my initial thought too. :) . Anyway, I agree with Hiranya on that
changing the parser configuration is not the ideal solution at the moment.

>
>
> Thanks,
> > Kasun
> >
> > On Sat, May 1, 2010 at 3:05 PM, Hiranya Jayathilaka <
> hiranya911@gmail.com>
> > wrote:
> >>
> >> Hi Indika,
> >>
> >> On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>
> >> wrote:
> >>>
> >>> Hiranya ... it seems that as Andreas pointed out in ws commons list,
> the
> >>> working with Axiom in non coalescing can be a risk.
> >>
> >> Yes. Actually that discussion helped me understand a lot. It seems the
> >> existing logic in Synapse+Axiom for handling local entries with CDATA
> >> elements is correct after all. The problem with serialization I pointed
> out
> >> in my previous mail is to be expected. Even though the serialized XML is
> >> lexically different from the input XML, their XML infosets are equal.
> Even
> >> though AXIOM has removed CDATA tags, the text has been encoded to escape
> any
> >> invalid characters like '<'.
> >> All in all I think we can live with the existing logic. We can resolve
> >> SYNAPSE-624 as 'not a bug'. However there are few things that need be
> >> properly communicated to the users through our docs.
> >> 1. If a local entry text contains any XML markup the whole text must be
> >> wrapped in CDATA tags
> >> eg: <localEntry
> >> key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>
> >> 2. If a local entry text contains XML markup and CDATA tags then we
> should
> >> properly escape the CDATA tags to avoid having nested CDATA elements.
> >> (Nested CDATA elements cause XML parser to throw a parse exception)
> >> eg: <localEntry
> >>
> key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>
> >> 3. XML local entries with CDATA elements will not have the CDATA tags in
> >> the serialized version
> >> I have updated the test cases to cover all these scenarios and the
> >> expected behavior.
> >> Thanks,
> >> Hiranya
> >>
> >>>
> >>> is the 'coalescing' off/on a system property ?  and if  not  , is there
> >>> any way to create a new parser instance in non coalescing mode only for
> >>> synapse configuration parsing ?
> >>>
> >>> Thanks
> >>>
> >>> Indika
> >>>
> >>> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka
> >>> <hi...@gmail.com> wrote:
> >>>>
> >>>> Hi Folks,
> >>>> While doing some work on SYNAPSE-624, I have realized that Synapse
> does
> >>>> not handle local entry values with CDATA elements properly. Axiom
> seems to
> >>>> drop CDATA elements while parsing XML. For an example given the
> following
> >>>> local entry configuration:
> >>>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
> >>>> the serialized XML would be as follows:
> >>>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
> >>>>
> >>>> Note that the CDATA element is gone, and its value has been partially
> >>>> encoded. The way out of this issue is to disable coalescing in the
> parser.
> >>>> But that would be globally applied to all XML parsing logic in Synapse
> >>>> (unless we somehow use a separate OM builder for parsing local
> entries). So
> >>>> how do you think we should handle this scenario?
> >>>> Thanks
> >>>> --
> >>>> Hiranya Jayathilaka
> >>>> Software Engineer;
> >>>> WSO2 Inc.;  http://wso2.org
> >>>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> >>>> Blog: http://techfeast-hiranya.blogspot.com
> >>>
> >>
> >>
> >>
> >> --
> >> Hiranya Jayathilaka
> >> Software Engineer;
> >> WSO2 Inc.;  http://wso2.org
> >> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> >> Blog: http://techfeast-hiranya.blogspot.com
> >
> >
> >
> > --
> > Kasun Indrasiri
> > Senior Software Engineer,
> > WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
> > Blog : http://kasunpanorama.blogspot.com/
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>


-- 
Kasun Indrasiri
Senior Software Engineer,
WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
Blog : http://kasunpanorama.blogspot.com/

Re: Local Entires with CDATA Elements

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
Hi Andreas,

On Sun, May 2, 2010 at 7:00 PM, Andreas Veithen
<an...@gmail.com>wrote:

> On Sun, May 2, 2010 at 05:58, Kasun Indrasiri <ka...@gmail.com> wrote:
> > Hi all,
> > So, are we going to live with coalescing parsing in Synapse? As
> > per SYNAPSE-280 which is pointed out by Andreas what are the benefits
> that
> > we can get from using non-coalescing mode in Synapse and in that case are
> we
> > planning to move to non-coalescing in the future?
> > And even though we resolve SYNAPSE-624 as 'not-a but', I guess
> > replacing OMText#getText by OMElement#getText() is still applicable.
>
> I don't see any reason why we should not fix the code to make proper
> use of OMElement#getText().
>

Yes. Actually I did a bit more research into this. As per WSCOMMONS-461
users can now enable non-coalesced parsing for Synapse if required.
Therefore that scenario needs to be supported. I'll get Kasun's patch
checked into the code base.

Thanks,
Hiranya


>
> > Thanks,
> > Kasun
> >
> > On Sat, May 1, 2010 at 3:05 PM, Hiranya Jayathilaka <
> hiranya911@gmail.com>
> > wrote:
> >>
> >> Hi Indika,
> >>
> >> On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>
> >> wrote:
> >>>
> >>> Hiranya ... it seems that as Andreas pointed out in ws commons list,
> the
> >>> working with Axiom in non coalescing can be a risk.
> >>
> >> Yes. Actually that discussion helped me understand a lot. It seems the
> >> existing logic in Synapse+Axiom for handling local entries with CDATA
> >> elements is correct after all. The problem with serialization I pointed
> out
> >> in my previous mail is to be expected. Even though the serialized XML is
> >> lexically different from the input XML, their XML infosets are equal.
> Even
> >> though AXIOM has removed CDATA tags, the text has been encoded to escape
> any
> >> invalid characters like '<'.
> >> All in all I think we can live with the existing logic. We can resolve
> >> SYNAPSE-624 as 'not a bug'. However there are few things that need be
> >> properly communicated to the users through our docs.
> >> 1. If a local entry text contains any XML markup the whole text must be
> >> wrapped in CDATA tags
> >> eg: <localEntry
> >> key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>
> >> 2. If a local entry text contains XML markup and CDATA tags then we
> should
> >> properly escape the CDATA tags to avoid having nested CDATA elements.
> >> (Nested CDATA elements cause XML parser to throw a parse exception)
> >> eg: <localEntry
> >>
> key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>
> >> 3. XML local entries with CDATA elements will not have the CDATA tags in
> >> the serialized version
> >> I have updated the test cases to cover all these scenarios and the
> >> expected behavior.
> >> Thanks,
> >> Hiranya
> >>
> >>>
> >>> is the 'coalescing' off/on a system property ?  and if  not  , is there
> >>> any way to create a new parser instance in non coalescing mode only for
> >>> synapse configuration parsing ?
> >>>
> >>> Thanks
> >>>
> >>> Indika
> >>>
> >>> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka
> >>> <hi...@gmail.com> wrote:
> >>>>
> >>>> Hi Folks,
> >>>> While doing some work on SYNAPSE-624, I have realized that Synapse
> does
> >>>> not handle local entry values with CDATA elements properly. Axiom
> seems to
> >>>> drop CDATA elements while parsing XML. For an example given the
> following
> >>>> local entry configuration:
> >>>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
> >>>> the serialized XML would be as follows:
> >>>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
> >>>>
> >>>> Note that the CDATA element is gone, and its value has been partially
> >>>> encoded. The way out of this issue is to disable coalescing in the
> parser.
> >>>> But that would be globally applied to all XML parsing logic in Synapse
> >>>> (unless we somehow use a separate OM builder for parsing local
> entries). So
> >>>> how do you think we should handle this scenario?
> >>>> Thanks
> >>>> --
> >>>> Hiranya Jayathilaka
> >>>> Software Engineer;
> >>>> WSO2 Inc.;  http://wso2.org
> >>>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> >>>> Blog: http://techfeast-hiranya.blogspot.com
> >>>
> >>
> >>
> >>
> >> --
> >> Hiranya Jayathilaka
> >> Software Engineer;
> >> WSO2 Inc.;  http://wso2.org
> >> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> >> Blog: http://techfeast-hiranya.blogspot.com
> >
> >
> >
> > --
> > Kasun Indrasiri
> > Senior Software Engineer,
> > WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
> > Blog : http://kasunpanorama.blogspot.com/
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>


-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Local Entires with CDATA Elements

Posted by Andreas Veithen <an...@gmail.com>.
On Sun, May 2, 2010 at 05:58, Kasun Indrasiri <ka...@gmail.com> wrote:
> Hi all,
> So, are we going to live with coalescing parsing in Synapse? As
> per SYNAPSE-280 which is pointed out by Andreas what are the benefits that
> we can get from using non-coalescing mode in Synapse and in that case are we
> planning to move to non-coalescing in the future?
> And even though we resolve SYNAPSE-624 as 'not-a but', I guess
> replacing OMText#getText by OMElement#getText() is still applicable.

I don't see any reason why we should not fix the code to make proper
use of OMElement#getText().

> Thanks,
> Kasun
>
> On Sat, May 1, 2010 at 3:05 PM, Hiranya Jayathilaka <hi...@gmail.com>
> wrote:
>>
>> Hi Indika,
>>
>> On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>
>> wrote:
>>>
>>> Hiranya ... it seems that as Andreas pointed out in ws commons list, the
>>> working with Axiom in non coalescing can be a risk.
>>
>> Yes. Actually that discussion helped me understand a lot. It seems the
>> existing logic in Synapse+Axiom for handling local entries with CDATA
>> elements is correct after all. The problem with serialization I pointed out
>> in my previous mail is to be expected. Even though the serialized XML is
>> lexically different from the input XML, their XML infosets are equal. Even
>> though AXIOM has removed CDATA tags, the text has been encoded to escape any
>> invalid characters like '<'.
>> All in all I think we can live with the existing logic. We can resolve
>> SYNAPSE-624 as 'not a bug'. However there are few things that need be
>> properly communicated to the users through our docs.
>> 1. If a local entry text contains any XML markup the whole text must be
>> wrapped in CDATA tags
>> eg: <localEntry
>> key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>
>> 2. If a local entry text contains XML markup and CDATA tags then we should
>> properly escape the CDATA tags to avoid having nested CDATA elements.
>> (Nested CDATA elements cause XML parser to throw a parse exception)
>> eg: <localEntry
>> key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>
>> 3. XML local entries with CDATA elements will not have the CDATA tags in
>> the serialized version
>> I have updated the test cases to cover all these scenarios and the
>> expected behavior.
>> Thanks,
>> Hiranya
>>
>>>
>>> is the 'coalescing' off/on a system property ?  and if  not  , is there
>>> any way to create a new parser instance in non coalescing mode only for
>>> synapse configuration parsing ?
>>>
>>> Thanks
>>>
>>> Indika
>>>
>>> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka
>>> <hi...@gmail.com> wrote:
>>>>
>>>> Hi Folks,
>>>> While doing some work on SYNAPSE-624, I have realized that Synapse does
>>>> not handle local entry values with CDATA elements properly. Axiom seems to
>>>> drop CDATA elements while parsing XML. For an example given the following
>>>> local entry configuration:
>>>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
>>>> the serialized XML would be as follows:
>>>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
>>>>
>>>> Note that the CDATA element is gone, and its value has been partially
>>>> encoded. The way out of this issue is to disable coalescing in the parser.
>>>> But that would be globally applied to all XML parsing logic in Synapse
>>>> (unless we somehow use a separate OM builder for parsing local entries). So
>>>> how do you think we should handle this scenario?
>>>> Thanks
>>>> --
>>>> Hiranya Jayathilaka
>>>> Software Engineer;
>>>> WSO2 Inc.;  http://wso2.org
>>>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>>>> Blog: http://techfeast-hiranya.blogspot.com
>>>
>>
>>
>>
>> --
>> Hiranya Jayathilaka
>> Software Engineer;
>> WSO2 Inc.;  http://wso2.org
>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>> Blog: http://techfeast-hiranya.blogspot.com
>
>
>
> --
> Kasun Indrasiri
> Senior Software Engineer,
> WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
> Blog : http://kasunpanorama.blogspot.com/
>
>

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


Re: Local Entires with CDATA Elements

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
Hi Kasun,

On Sun, May 2, 2010 at 9:28 AM, Kasun Indrasiri <ka...@gmail.com> wrote:

> Hi all,
>
> So, are we going to live with coalescing parsing in Synapse?
>

I think we should stick to the coalesced parsing at least for the moment.
The entire Synapse code base is developed under the assumption that
coalesced parsing would be used throughout. Changing the parser behavior may
have some unexpected effects. Note that this not only effects how XML
configurations are read, but also how incoming messages are parsed as well.


> As per SYNAPSE-280 <https://issues.apache.org/jira/browse/SYNAPSE-280> which
> is pointed out by Andreas what are the benefits that we can get from using
> non-coalescing mode in Synapse and in that case are we planning to move to
> non-coalescing in the future?
>

May be. But in that case we should plan well ahead. We should start the
transition well before a release so we have enough time to test and verify.


> And even though we resolve SYNAPSE-624 as 'not-a but', I guess replacing OMText#getText
> by OMElement#getText() is still applicable.
>

Given the circumstances I'd leave the code as it is. Why fix something that
is not broken? ;) But if you do feel there are any potential issues with the
current logic please do let us know.

Thanks,
Hiranya


>
>
> Thanks,
> Kasun
>
>
> On Sat, May 1, 2010 at 3:05 PM, Hiranya Jayathilaka <hi...@gmail.com>
>  wrote:
>
>> Hi Indika,
>>
>> On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>
>>  wrote:
>>
>>> Hiranya ... it seems that as Andreas pointed out in ws commons list, the
>>> working with Axiom in non coalescing can be a risk.
>>>
>>
>> Yes. Actually that discussion helped me understand a lot. It seems the
>> existing logic in Synapse+Axiom for handling local entries with CDATA
>> elements is correct after all. The problem with serialization I pointed out
>> in my previous mail is to be expected. Even though the serialized XML is
>> lexically different from the input XML, their XML infosets are equal. Even
>> though AXIOM has removed CDATA tags, the text has been encoded to escape any
>> invalid characters like '<'.
>>
>> All in all I think we can live with the existing logic. We can resolve
>> SYNAPSE-624 as 'not a bug'. However there are few things that need be
>> properly communicated to the users through our docs.
>>
>> 1. If a local entry text contains any XML markup the whole text must be
>> wrapped in CDATA tags
>>
>> eg: <localEntry
>> key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>
>>
>> 2. If a local entry text contains XML markup and CDATA tags then we should
>> properly escape the CDATA tags to avoid having nested CDATA elements.
>> (Nested CDATA elements cause XML parser to throw a parse exception)
>>
>> eg: <localEntry
>> key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>
>>
>> 3. XML local entries with CDATA elements will not have the CDATA tags in
>> the serialized version
>>
>> I have updated the test cases to cover all these scenarios and the
>> expected behavior.
>>
>> Thanks,
>> Hiranya
>>
>>
>>>
>>> is the 'coalescing' off/on a system property ?  and if  not  , is there
>>> any way to create a new parser instance in non coalescing mode only for
>>> synapse configuration parsing ?
>>>
>>> Thanks
>>>
>>> Indika
>>>
>>> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka <
>>> hiranya911@gmail.com> wrote:
>>>
>>>> Hi Folks,
>>>>
>>>> While doing some work on SYNAPSE-624, I have realized that Synapse does
>>>> not handle local entry values with CDATA elements properly. Axiom seems to
>>>> drop CDATA elements while parsing XML. For an example given the following
>>>> local entry configuration:
>>>>
>>>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
>>>>
>>>> the serialized XML would be as follows:
>>>>
>>>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
>>>>
>>>> Note that the CDATA element is gone, and its value has been partially
>>>> encoded. The way out of this issue is to disable coalescing in the parser.
>>>> But that would be globally applied to all XML parsing logic in Synapse
>>>> (unless we somehow use a separate OM builder for parsing local entries). So
>>>> how do you think we should handle this scenario?
>>>>
>>>> Thanks
>>>> --
>>>> Hiranya Jayathilaka
>>>> Software Engineer;
>>>> WSO2 Inc.;  http://wso2.org
>>>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>>>> Blog: http://techfeast-hiranya.blogspot.com
>>>>
>>>
>>>
>>
>>
>> --
>> Hiranya Jayathilaka
>> Software Engineer;
>> WSO2 Inc.;  http://wso2.org
>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>> Blog: http://techfeast-hiranya.blogspot.com
>>
>
>
>
> --
> Kasun Indrasiri
> Senior Software Engineer,
> WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
> Blog : http://kasunpanorama.blogspot.com/
>
>


-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Local Entires with CDATA Elements

Posted by Kasun Indrasiri <ka...@gmail.com>.
Hi all,

So, are we going to live with coalescing parsing in Synapse? As per
SYNAPSE-280 <https://issues.apache.org/jira/browse/SYNAPSE-280> which is
pointed out by Andreas what are the benefits that we can get from using
non-coalescing mode in Synapse and in that case are we planning to move to
non-coalescing in the future?
And even though we resolve SYNAPSE-624 as 'not-a but', I guess
replacing OMText#getText
by OMElement#getText() is still applicable.

Thanks,
Kasun


On Sat, May 1, 2010 at 3:05 PM, Hiranya Jayathilaka <hi...@gmail.com>wrote:

> Hi Indika,
>
> On Fri, Apr 30, 2010 at 10:23 PM, indika kumara <in...@gmail.com>wrote:
>
>> Hiranya ... it seems that as Andreas pointed out in ws commons list, the
>> working with Axiom in non coalescing can be a risk.
>>
>
> Yes. Actually that discussion helped me understand a lot. It seems the
> existing logic in Synapse+Axiom for handling local entries with CDATA
> elements is correct after all. The problem with serialization I pointed out
> in my previous mail is to be expected. Even though the serialized XML is
> lexically different from the input XML, their XML infosets are equal. Even
> though AXIOM has removed CDATA tags, the text has been encoded to escape any
> invalid characters like '<'.
>
> All in all I think we can live with the existing logic. We can resolve
> SYNAPSE-624 as 'not a bug'. However there are few things that need be
> properly communicated to the users through our docs.
>
> 1. If a local entry text contains any XML markup the whole text must be
> wrapped in CDATA tags
>
> eg: <localEntry
> key="foo"><![CDATA[mc.setPayloadXML(<xml>data</xml>);]]></localEntry>
>
> 2. If a local entry text contains XML markup and CDATA tags then we should
> properly escape the CDATA tags to avoid having nested CDATA elements.
> (Nested CDATA elements cause XML parser to throw a parse exception)
>
> eg: <localEntry
> key="foo"><![CDATA[mc.setPayloadXML(<xml><![CDATA[data]]]]><![CDATA[></xml>);]]></localEntry>
>
> 3. XML local entries with CDATA elements will not have the CDATA tags in
> the serialized version
>
> I have updated the test cases to cover all these scenarios and the expected
> behavior.
>
> Thanks,
> Hiranya
>
>
>>
>> is the 'coalescing' off/on a system property ?  and if  not  , is there
>> any way to create a new parser instance in non coalescing mode only for
>> synapse configuration parsing ?
>>
>> Thanks
>>
>> Indika
>>
>> On Fri, Apr 30, 2010 at 6:41 PM, Hiranya Jayathilaka <
>> hiranya911@gmail.com> wrote:
>>
>>> Hi Folks,
>>>
>>> While doing some work on SYNAPSE-624, I have realized that Synapse does
>>> not handle local entry values with CDATA elements properly. Axiom seems to
>>> drop CDATA elements while parsing XML. For an example given the following
>>> local entry configuration:
>>>
>>> <localEntry key="foo"><test><![CDATA[<SomeXML/>]]></test></localEntry>
>>>
>>> the serialized XML would be as follows:
>>>
>>> <localEntry key="foo"><test>&lt;SomeXML/></test></localEntry>
>>>
>>> Note that the CDATA element is gone, and its value has been partially
>>> encoded. The way out of this issue is to disable coalescing in the parser.
>>> But that would be globally applied to all XML parsing logic in Synapse
>>> (unless we somehow use a separate OM builder for parsing local entries). So
>>> how do you think we should handle this scenario?
>>>
>>> Thanks
>>> --
>>> Hiranya Jayathilaka
>>> Software Engineer;
>>> WSO2 Inc.;  http://wso2.org
>>> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
>>> Blog: http://techfeast-hiranya.blogspot.com
>>>
>>
>>
>
>
> --
> Hiranya Jayathilaka
> Software Engineer;
> WSO2 Inc.;  http://wso2.org
> E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
> Blog: http://techfeast-hiranya.blogspot.com
>



-- 
Kasun Indrasiri
Senior Software Engineer,
WSO2 Inc. - "Lean . Enterprise . Middleware" - http://www.wso2.com/
Blog : http://kasunpanorama.blogspot.com/

Re: Local Entires with CDATA Elements

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
Indika,

On Mon, May 3, 2010 at 7:48 PM, indika kumara <in...@gmail.com> wrote:

>
>> 3. XML local entries with CDATA elements will not have the CDATA tags in
>> the serialized version
>>
>
> This means , second and sub sequence reading will trouble...


Not really. The CDATA content is properly encoded so the subsequent reads do
not fail.


> BTW ,  this will not cause issues for synapse as the synapse configuration
> serialization is not used in the synapse.
>
> BTW if there is  any way to create a  parser instance in non coalescing
> mode only for synapse configuration parsing , it will solve the issue.
>

I think this behavior is something to do with the XML serializer side, not
the parser side. Anyway since the content is properly encoded we don't have
any issues with the existing behavior.

Thanks,
Hiranya


>
> Thanks
>
> Indika
>



-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hiranya@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Re: Local Entires with CDATA Elements

Posted by indika kumara <in...@gmail.com>.
>
>
> 3. XML local entries with CDATA elements will not have the CDATA tags in
> the serialized version
>

This means , second and sub sequence reading will trouble... BTW ,  this
will not cause issues for synapse as the synapse configuration serialization
is not used in the synapse.

BTW if there is  any way to create a  parser instance in non coalescing mode
only for synapse configuration parsing , it will solve the issue.

Thanks

Indika