XML Serialization Loses Namespaces

I have a CRM entity XML message as follows:

<c:KeyValuePairOfstringanyType xmlns:c="ns1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" > .... <c:value i:type="**b:AliasedValue**" **xmlns:b="ns3"**> SomethingHere... </c:value> </c:KeyValuePairOfstringanyType> 

Then I separated it to the object and serialized back to xml
I get

 <c:KeyValuePairOfstringanyType xmlns:c="ns1" xmlns:i="http://www.w3.org/2001/XMLSchema- instance" > <c:value i:type="b:AliasedValue" > SomethingHere... </c:value> </c:KeyValuePairOfstringanyType> 

I am losing the definition of xmlns: b. Any idea why?

+4
source share
1 answer

forty-two rights: attribute values ​​have no default semantics, therefore the use of the namespace is not recognized as such using xml-processors.

if you want to reference some b data in your i:type attribute, you use a mapping element to associate c:value with the (hypothetical) b:value , i.e.:

 <mapping xml:id="idXY'/> ... <c:value c:ref="idXY">...</c:value> ... <b:value b:ref="idXY">...</b:value> ... 

... where you declare _:ref as IDREF attributes in the corresponding xml schemes. you may have to adjust the design for 1: n- / m: n - mappings, for example. using referrers as child elements of _:value .

Best regards, carsten

0
source

All Articles