Hello,
1)
Consider following XML as an example:
<s:doc xmlns:s="urn:aaa:bbb:s"
xmlns:b="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="urn:aaa:bbb:p">
...
<s:item s:author="..." s:date="...">
<s:comment>My cool comment</s:comment>
</s:item>
...
It is parsed correctly, but when printed to console, it lacks 2 attributes: "s:author" and "s:date". So, it becomes looking like:
<s:item>
<s:comment>My cool comment</s:comment>
</s:item>
If I remove namespace "s:" prefix from the attributes, they appear on console. Is it correct behavior? Looks like it is probably OK as attributes are in the same namespace as item, but I am not sure.
2) Similar thing happens when attributes and elements are in different namespaces. Consider following XML:
<s:doc xmlns:s="urn:aaa:bbb:s"
xmlns:b="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="urn:aaa:bbb:p">
...
<p:my_element b:type="p:SomeType"/>
After it is parsed and printed on console, <p:my_element b:type="..."> looks like "<p:my_element>". The type attribute goes way.</p:my_element></p:my_element>
JFYI, if I replace in _buildAttributes method of generated code "xsi:type" to "b:type", output XML becomes looking like that:
<p:my_element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p:SomeType"/>
This seems more or less good as namespace is right, but still has some room for improvement as xsi namespace is already defined as b namespace. And it seems like between those namespaces clearly something go wrong. Moreover, there are plenty of cases in generated code where xsi namespace used for some reason.
Am I doing something unfeasible, or it looks like an issue? Any suggestions how to bypass it?
Mikhail,
Thanks for your detailed report.
Yes, this seems like a reasonable request to me. But ...
In response to your ticket and your questions, I have searched a
bit at the code in
generateDS.py
looking for support fornamespaces on attributes. I cannot find any.
And, adding/implementing that support for namespace prefixes on
attribute names would require significant changes at a number of
locations in the code. That is not a task that I'm willing to take
on. In addition, I'm a bit confused about when namespace prefixes
are allowed or required on attributes.
So, unless you or someone else is willing to implement that feature,
I suppose you will have to use whatever work-around you can come up
with.
I apologize for the omission of that support. It must have been
that I had not anticipated the need for it.
Dave
Dave,
Fair enough. Thank you. I am not sure I'll be having enough enthusiasm to support that too.
Keep it in backlog if for some reason anyone would want to implement that.