Incorrect use of namespace prefixes when namespace-prefix is overridden in an xsd:any element [message #550263] |
Thu, 29 July 2010 16:13 |
Vasanth Velusamy Messages: 31 Registered: July 2009 |
Member |
|
|
Hi,
I believe I've come across a bug in how namespace prefixes are handled
during deserialization of an xml document. The issue seems to be with a
specific scenario of prefixes being overridden in child elements where
the child element is an xsd:any (deserialized as AnyType).
Here are the details:
I have a scenario where 'firstElement' and 'secondElement' are mapped in
ecore, and 'secondElement' is allowed to have xsd:any content. So, in
the sample below, 'thirdElement' and its child are deserialized as AnyType.
--------
Sample 1:
--------
<a:firstElement xmlns:a="http://a" xmlns:c="http://b">
<a:secondElement>
<b:thirdElement xmlns:b="http://b" xmlns:c="http://c">
<c:fourthElement/>
</b:thirdElement>
</a:secondElement>
</a:firstElement>
When this is deserialized as an EMF resource and subsequently
serialized, I get back something like this:
<a:firstElement xmlns:a="http://a" xmlns:c="http://b">
<a:secondElement>
<c:thirdElement xmlns:b="http://b" xmlns:c="http://c">
<c:fourthElement/>
</c:thirdElement>
</a:secondElement>
</a:firstElement>
The output is different from the input: difference being, 'thirdElement'
now has a prefix of 'c' and none of the namespace-prefix declarations
have changed.
--------
Sample 2:
--------
Interestingly, if my original xml document was
<a:firstElement xmlns:a="http://a" xmlns:c="http://b">
<a:secondElement xmlns:b="http://b" xmlns:c="http://c">
<b:thirdElement>
<c:fourthElement/>
</b:thirdElement>
</a:secondElement>
</a:firstElement>
I get back something like this after deserializing & serializing:
<a:firstElement xmlns:a="http://a" xmlns:c="http://b" xmlns:b="http://b"
xmlns:c_1="http://c">
<a:secondElement>
<c:thirdElement>
<c_1:fourthElement/>
</c:thirdElement>
</a:secondElement>
</a:firstElement>
Even though the changes in the prefixes are not to my liking (I would
have preferred that the prefixes could have been preserved and I dont
see why not. But that is a different topic.), the output is the same as
the input, and this is fine.
The difference between samples 1 and 2 is that in the former case, the
namespace-prefix overriding happens in an xsd:any element. I hope my
description is clear. If you cannot reproduce the issue, please let me
know and I can provide a more detailed sample.
Thanks,
Vasanth
|
|
|
Re: Incorrect use of namespace prefixes when namespace-prefix is overridden in an xsd:any element [message #550273 is a reply to message #550263] |
Thu, 29 July 2010 16:56 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Vasanth,
Comments below.
Vasanth Velusamy wrote:
>
> Hi,
>
> I believe I've come across a bug in how namespace prefixes are handled
> during deserialization of an xml document. The issue seems to be with
> a specific scenario of prefixes being overridden in child elements
> where the child element is an xsd:any (deserialized as AnyType).
>
> Here are the details:
>
> I have a scenario where 'firstElement' and 'secondElement' are mapped
> in ecore, and 'secondElement' is allowed to have xsd:any content. So,
> in the sample below, 'thirdElement' and its child are deserialized as
> AnyType.
>
> --------
> Sample 1:
> --------
> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
> <a:secondElement>
> <b:thirdElement xmlns:b="http://b" xmlns:c="http://c">
> <c:fourthElement/>
> </b:thirdElement>
> </a:secondElement>
> </a:firstElement>
>
> When this is deserialized as an EMF resource and subsequently
> serialized, I get back something like this:
>
> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
> <a:secondElement>
> <c:thirdElement xmlns:b="http://b" xmlns:c="http://c">
> <c:fourthElement/>
> </c:thirdElement>
> </a:secondElement>
> </a:firstElement>
>
> The output is different from the input: difference being,
> 'thirdElement' now has a prefix of 'c' and none of the
> namespace-prefix declarations have changed.
Interesting.
>
> --------
> Sample 2:
> --------
>
> Interestingly, if my original xml document was
>
> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
> <a:secondElement xmlns:b="http://b" xmlns:c="http://c">
> <b:thirdElement>
> <c:fourthElement/>
> </b:thirdElement>
> </a:secondElement>
> </a:firstElement>
>
> I get back something like this after deserializing & serializing:
>
> <a:firstElement xmlns:a="http://a" xmlns:c="http://b"
> xmlns:b="http://b" xmlns:c_1="http://c">
> <a:secondElement>
> <c:thirdElement>
> <c_1:fourthElement/>
> </c:thirdElement>
> </a:secondElement>
> </a:firstElement>
>
> Even though the changes in the prefixes are not to my liking (I would
> have preferred that the prefixes could have been preserved and I dont
> see why not. But that is a different topic.), the output is the same
> as the input, and this is fine.
We simply don't keep enough information in the model to know what
prefixes appear on secondElement.
>
>
> The difference between samples 1 and 2 is that in the former case, the
> namespace-prefix overriding happens in an xsd:any element. I hope my
> description is clear. If you cannot reproduce the issue, please let me
> know and I can provide a more detailed sample.
It sounds like a subtle problem. Please open a bugzilla with a
reproducible test case so I can track down the cause. Do doubt we need
to consider the local prefixes in the AnyType for thirdElement before
using something that's in scope from the parent, given that the local
prefixes can override those of the parent.
>
> Thanks,
> Vasanth
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Incorrect use of namespace prefixes when namespace-prefix is overridden in an xsd:any element [message #630179 is a reply to message #550273] |
Thu, 30 September 2010 22:02 |
Vasanth Velusamy Messages: 31 Registered: July 2009 |
Member |
|
|
Created a bug report, including a test project and reproducible steps -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=326724
On 7/29/2010 12:56 PM, Ed Merks wrote:
> Vasanth,
>
> Comments below.
>
>
> Vasanth Velusamy wrote:
>>
>> Hi,
>>
>> I believe I've come across a bug in how namespace prefixes are handled
>> during deserialization of an xml document. The issue seems to be with
>> a specific scenario of prefixes being overridden in child elements
>> where the child element is an xsd:any (deserialized as AnyType).
>>
>> Here are the details:
>>
>> I have a scenario where 'firstElement' and 'secondElement' are mapped
>> in ecore, and 'secondElement' is allowed to have xsd:any content. So,
>> in the sample below, 'thirdElement' and its child are deserialized as
>> AnyType.
>>
>> --------
>> Sample 1:
>> --------
>> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
>> <a:secondElement>
>> <b:thirdElement xmlns:b="http://b" xmlns:c="http://c">
>> <c:fourthElement/>
>> </b:thirdElement>
>> </a:secondElement>
>> </a:firstElement>
>>
>> When this is deserialized as an EMF resource and subsequently
>> serialized, I get back something like this:
>>
>> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
>> <a:secondElement>
>> <c:thirdElement xmlns:b="http://b" xmlns:c="http://c">
>> <c:fourthElement/>
>> </c:thirdElement>
>> </a:secondElement>
>> </a:firstElement>
>>
>> The output is different from the input: difference being,
>> 'thirdElement' now has a prefix of 'c' and none of the
>> namespace-prefix declarations have changed.
> Interesting.
>>
>> --------
>> Sample 2:
>> --------
>>
>> Interestingly, if my original xml document was
>>
>> <a:firstElement xmlns:a="http://a" xmlns:c="http://b">
>> <a:secondElement xmlns:b="http://b" xmlns:c="http://c">
>> <b:thirdElement>
>> <c:fourthElement/>
>> </b:thirdElement>
>> </a:secondElement>
>> </a:firstElement>
>>
>> I get back something like this after deserializing & serializing:
>>
>> <a:firstElement xmlns:a="http://a" xmlns:c="http://b"
>> xmlns:b="http://b" xmlns:c_1="http://c">
>> <a:secondElement>
>> <c:thirdElement>
>> <c_1:fourthElement/>
>> </c:thirdElement>
>> </a:secondElement>
>> </a:firstElement>
>>
>> Even though the changes in the prefixes are not to my liking (I would
>> have preferred that the prefixes could have been preserved and I dont
>> see why not. But that is a different topic.), the output is the same
>> as the input, and this is fine.
> We simply don't keep enough information in the model to know what
> prefixes appear on secondElement.
>>
>>
>> The difference between samples 1 and 2 is that in the former case, the
>> namespace-prefix overriding happens in an xsd:any element. I hope my
>> description is clear. If you cannot reproduce the issue, please let me
>> know and I can provide a more detailed sample.
> It sounds like a subtle problem. Please open a bugzilla with a
> reproducible test case so I can track down the cause. Do doubt we need
> to consider the local prefixes in the AnyType for thirdElement before
> using something that's in scope from the parent, given that the local
> prefixes can override those of the parent.
>>
>> Thanks,
>> Vasanth
|
|
|
Powered by
FUDForum. Page generated in 0.03255 seconds