.. .and I suppose attributes too although we don't currently ever write a
prefix on an attribute (we should!)
OK so I have been trying to fix the SDOXMLWriter code to "do the right
thing" and I think it is OK now for writing xsi:type information. The
problem we have is writing namespace prefix for elements. For example
(apologies for the inaccurate and loose schema but the gist should be here):
<schema targetNameSpace="fred">
<element>
<complexType name="myType">
<sequence>
<element name="elemA" .../>
<element name="elemB" .../>
<any ...>
</sequence>
</complexType>
</element>
</schema> <schema targetNameSpace="joe">
<element name="elemX" ...../>
</schema>
So myType is open.
I could now load an xml document
<myType xmlns="fred" xmlns:tns="fred" xmlns:tns1="joe">
<elemA .../>
<elemB .../>
<tns1:elemX ... />
</myType>
and get a DataObject of Type "fred#myType" with 3 properties set: elemA,
elemB and elemX
Now if I want to write this as xml form the DataObject using
XMLHelper->save() what do I get?
Well we can write the <myType> and the "defined" properties elemA and elemB
without much trouble but how do we determine the namespace of element elemX?
In this case I recently added code to the parsing code to remember the
element namespace in our PropertyDefinition which is available to us from
the Property when serializing. So... I can see that elemX is an element
defined in namespace "joe" and write it out correctly. THis is easy !!! ;-)
So where does it all fall apart? A. If you create the DataObject not from
deserializing an XML document as above but programatically.
Your code would look something like:
DataObjectPtr x = datafactory->create("fred", "myType");
x->setXXX("elemA", blah...);
or..
x->create("elemB");
x->setDataObject("elemX", somevalue_or_other);
So trying to serialize this we have no imformation about the namespace that
elemX is in.
I can't see any easy way around this and the various attempts to fix the
problem are really just best guess as to the namespace of the element:
- use the namespace of the element type
- use the namespace of the receiving DO
- use the namspace of the root DO
None of these are correct and each works fine in different scenarios (which
is why we are flip-flopping between breaking Sebastien's open type REST
samples and Caroline's wsdl/soap php tests).
The only thing I can think of to fix this requires a change in the SDO
specification to make property names QNames. This would allow
programatically setting the namespace:
x->setDataObject("joe#elemx", somevalue_or_other);
Thoughts? Help?
--
Pete