I just found out XMLHelper.save() method always uses the dataobject's
namespace URI to derive its namespace prefix even the prefix was defined in
the XSD.
For example, I modify "xmlns:nsPrefix=nsURI" in the simple.xsd located in
the resource folder under sdo/impl project from
xmlns:simple="http://www.example.com/simple" to
xmlns:simple="http://www.example.com/simple/1.0" then modify
SimpleDynamicTestCase.java to display its serialization output. Here are the
XSD and the serialization output:
*simple.xsd*
<xsd:schema
targetNamespace="http://www.example.com/simple/1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:simple="http://www.example.com/simple/1.0">
<xsd:element name="stockQuote" type="simple:Quote"/>
<xsd:complexType name="Quote">
<xsd:sequence>
<xsd:element name="symbol" type="xsd:string"/>
<xsd:element name="companyName" type="xsd:string"/>
<xsd:element name="price" type="xsd:decimal"/>
<xsd:element name="open1" type="xsd:decimal"/>
<xsd:element name="high" type="xsd:decimal"/>
<xsd:element name="low" type="xsd:decimal"/>
<xsd:element name="volume" type="xsd:double"/>
<xsd:element name="change1" type="xsd:double"/>
<xsd:element name="quotes" type="simple:Quote" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
*Serialization output*
<?xml version="1.0" encoding="ASCII"?>
<_1:stockQuote xmlns:_1="http://www.example.com/simple/1.0">
<symbol>fbnt</symbol>
<companyName>FlyByNightTechnology</companyName>
<price>1000.0</price>
<open1>1000.0</open1>
<low>1000.0</low>
<volume>1000.0</volume>
<change1>1000.0</change1>
<quotes>
<price>2000.0</price>
</quotes>
</_1:stockQuote>
Is this expected behaviour?