Hi,

I will have a look at the namespace issue, but you have two options to work 
around this problem:

1) use the XmlDocument output protocol. That will let you return arbitrary 
ComplexModel subclasses as raw Xml.

2) Keep using the soap protocol but use an event to alter the return document 
after the function returns but before the xml is serialized to string.

Best,
Burak

--

Sent from my mobile. Pardon the brevity.



On 14.11.2012 17:04 Joni Kivinen wrote:

Hey,


I'm trying to get the response from spyne to match up with a set of
fixed schemas, and I'm running to a wall trying to deal with
referenced elements. As an example, using these two schema files:


base.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.test.org/base";
xmlns:a="http://xml.test.org/base";
xmlns:b="http://xml.test.org/base";
xmlns:xs="http://xml.test.org/base";
elementFormDefault="qualified">
<xs:import namespace="http://xml.test.org/base";
schemaLocation="addon.xsd"/>
<xs:element name="Test" type="b:TestBase" />
<xs:complexType name="TestBase">
<xs:sequence>
<xs:element name="Value" type="xs:string" />
<xs:element ref="a:Addon" />
</xs:sequence>
</xs:complexType>
</xs:schema>


addon.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.test.org/base";
xmlns:a="http://xml.test.org/base";
xmlns:xs="http://xml.test.org/base";
elementFormDefault="qualified">
<xs:element name="Addon" type="a:AddonType" />
<xs:simpleType name="AddonType">
<xs:restriction base="xs:string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
</xs:schema>


the result should be something like:


<?xml version="1.0" encoding="UTF-8"?>
<b:Test xmlns:a="http://xml.test.org/base";
xmlns:b="http://xml.test.org/base";
xmlns:xsi="http://xml.test.org/base";>
<b:Value>Value0</b:Value>
<a:Addon>1</a:Addon>
</b:Test>


but whatever I try, I can't figure out how to change the namespace of
immediate children with the spyne classes (while in this case I'm
dealing with enumerations, I can't seem to change it for any other
types either, complex or not).


As a quick example of one way I'm trying to solve this:
addon = Enum('1', '2', type_name='Addon')
addon.__namespace__ = 'http://xml.test.org/base'


class Test(ComplexModel):
__namespace__ = 'http://xml.test.org/base'
Value = String
Addon = addon


test = Test(Value='1', Addon='2')
print lxml.etree.tostring(get_object_as_xml(test), pretty_print=True)


results in:
<ns0:Test xmlns:ns0="http://xml.test.org/base";>
<ns0:Value>1</ns0:Value>
<ns0:Addon>2</ns0:Addon>
</ns0:Test>


That all said, if there is a way to just return raw xml to the client,
that'd work as a workaround for me just fine.


- Joni

_______________________________________________

Soap mailing list

[email protected]
http://xml.test.org/base



_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to