Please excuse the fact that I have only a PHP testcase for this. The PHP is however pretty trivial and it seems a simple thing to make in C. Also, I know that the PHP layer is doing very little to interfere, so this is genuine Tuscany behaviour.
Here is the bug report from the PHP bug tracking system:
Description:
------------
I have been quite sceptical about the XML that SDO is producing when it
builds a SOAP request, especially w.r.t. the namespaces. So I tried
loading the XML that SDO is producing into Java XERCES with validation
on. There are several problems with the XML generated, I think.
Using the two xsds that are in the reproduce section below, and the
short PHP script also there, SDO generates:
<?xml version="1.0" encoding="UTF-8"?>
<BOGUS xmlns="
http://Component" xmlns:tns="
http://Component"
xmlns:tns2="
http://www.test.com/info"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:type="add">
<person>
<tns2:name>
<first>Will</first>
<last>Shakespeare</last>
</tns2:name>
</person>
</BOGUS>
There are three (!) things wrong with this.
1. XERCES will not accept the xsi:type="add". I do not really know why.
I assume this is because there is no type called "add", it's only an
element. So I do not think this should be coming out.
2. name should not be in tns2=
http://www.test.com/info, neither should
"first" and "last" be in the default namespace of
http://Component. The
person.xsd has no elementFormDefault, so the elements below <person>
should all ne in the no name namespace.
3.You have to change the person.xsd to see the third thing: put
ElementNameDefault="qualified" in
the person schema, then "name", "first" and "last" should all now be
coming out in the
http://www.test.com/info namespace, but it makes no
difference to the generated XML.
Reproduce code:
---------------
<?php
$xmldas = SDO_DAS_XML::create('types.xsd');
$person =
$xmldas->createDataObject('
http://www.test.com/info','personType');
$name = $person->createDataObject('name');
$name->first = "Will";
$name->last = "Shakespeare";
$add = $xmldas->createDataObject('
http://Component','add');
$add->person = $person;
$xdoc = $xmldas->createDocument('', 'BOGUS', $add);
$xmlstr = $xmldas->saveString($xdoc, 2);
echo $xmlstr;
?>
types.xsd:
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:ns0="
http://www.test.com/info"
targetNamespace="
http://Component"
elementNameDefault="qualified">
<xs:import schemaLocation="person.xsd"
namespace="
http://www.test.com/info"/>
<xs:element name="add">
<xs:complexType>
<xs:sequence>
<xs:element name="person" type="ns0:personType"
nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
person.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="
http://www.w3.org/2001/XMLSchema"
targetNamespace="
http://www.test.com/info"
xmlns:info="
http://www.test.com/info">
<complexType name="nameType">
<sequence>
<element name="first" type="string"></element>
<element name="last" type="string"></element>
</sequence>
</complexType>
<complexType name="personType">
<sequence>
<element name="name" type="info:nameType"></element>
</sequence>
</complexType>
</schema>
Expected result:
----------------
see above
Actual result:
--------------
see above
[2007-01-31 12:21 UTC] mfp at php dot net
I just came across what I think is another example of this. Now I
understand better how namespaces work, I suspect it is more common than
we realise.
Here's the example in a nutshell:
Catalog.xsd defines a catalog element in the catalogNS namespace, which
contains items defined in a different namespace in a different file,
Order.xsd:
<schema xmlns="
http://www.w3.org/2001/XMLSchema"
xmlns:cat="catalogNS" xmlns:ord="orderNS" targetNamespace="catalogNS">
<include schemaLocation="Order.xsd"/>
<element name="catalog" type="cat:CatalogType"/>
<complexType name="CatalogType">
<sequence>
<element maxOccurs="unbounded" ref="ord:item"/>
</sequence>
</complexType>
</schema>
Order.xsd defines the item element as being in the "OrderNS" namespace:
.../...
<schema xmlns="
http://www.w3.org/2001/XMLSchema"
xmlns:ord="orderNS" xmlns:cust="customerNS" targetNamespace="orderNS">
.../...
<element name="item">
.../...
but when you build a catalog and write it out, although a namespace
prefix is defined for "orderNS", everything is in the default namespace,
"catalogNS":
<catalog xmlns="catalogNS" xmlns:tns="catalogNS"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns2="orderNS">
<item>
.../...