Issue Details (XML | Word | Printable)

Key: TUSCANY-1231
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Matthew Peters
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Tuscany

Various incorrect namespaces in generated XML

Created: 24/Apr/07 04:48 PM   Updated: 25/Apr/07 09:32 AM
Return to search
Component/s: C++ SDO
Affects Version/s: Cpp-M3
Fix Version/s: None

Time Tracking:
Not Specified

Environment: WinXP
Issue Links:
Duplicate
 

Resolution Date: 25/Apr/07 09:32 AM


 Description  « Hide
Given the following two xsds, which define an add element in http://Component and a PersonType in http://www.test.com/info...

<?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>

... if you now create a document with an 'add' element, create a PersonType object and assign meaningful first and last names, and serialise to XML, you get:

<?xml version="1.0" encoding="UTF-8"?>
<add xmlns="http://Component" xmlns:tns="http://Component" xmlns:tns2="http://www.test.com/info" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <person>
    <tns2:name>
      <first>Will</first>
      <last>Shakespeare</last>
    </tns2:name>
  </person>
</add>

There are several things wrong with this XML.

1. "name" should not be in tns2=http://www.test.com/info, and 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 be in the no name namespace.
2.You have to change the person.xsd to see the next 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.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Matthew Peters added a comment - 25/Apr/07 09:32 AM
Raised in error - I had mislaid the earlier TUSCANY-1112