That's not quite the schema definitions Ipertaining to the XML
snippet. We'd need to see the schema type definition for element
<homeAddress>, containing a (repeating) element with
name="LocalAddress". And I'd like to see the definition of that
element's type CompoundLocalAddress from SIDBusinessViewCommon.xsd.
But here's a couple of pointers.
Similar explicit inclusion of a schema type in an instance document's
element occurs if you instantiate a JAXB element using an object of
some (abstract) XML schema base type so that the element would have
the element tag of the base type.
Second, avoid xs:anySimpleType since this will also create multiple
references to the namespaces bound to xsi and xs, and type attributes
containing the actual type.
And you lose JAXB's advantage of having typed fields in your Java
classes so that you lose all the checks the Java compiler might do,
and for unmarshalling you'll have to handle all the conversions
yourself.
On Mon, Oct 20, 2008 at 8:13 PM, Son Nguyen <sontrang91_at_gmail.com> wrote:
>
> Here is a partial information of my xsd for the address type:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:SIDBusCm="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"
> xmlns:SIDBusCu="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer">
> <xs:import
> namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Customer"
> schemaLocation="SIDBusinessViewCustomer.xsd"/>
> <xs:import
> namespace="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common"
> schemaLocation="SIDBusinessViewCommon.xsd"/>
>
>
> <xs:complexType name="InitiateAddress">
> <xs:complexContent>
> <xs:extension base="SIDBusCm:GeographicAddress">
> <xs:sequence>
> <xs:element name="locality" type="xs:anySimpleType"
> minOccurs="0"/>
> <xs:element name="postcode" type="xs:anySimpleType"
> minOccurs="0"/>
> <xs:element name="geoText1" type="xs:anySimpleType"
> minOccurs="0"/>
> <xs:element name="GeoCode1" type="xs:anySimpleType"
> minOccurs="0"/>
> <xs:element name="GeoCode2" type="xs:anySimpleType"
> minOccurs="0"/>
> <xs:element name="addressLine"
> type="SIDBusCm:CompoundLocalAddress" minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> </xs:schema>
>
> Thanks,
>
>
>
> Son Nguyen wrote:
>>
>> Hi,
>> I have this problem when I use jaxb to create output xml. My output xml
>> looks like this:
>>
>> <data>
>> <instanceData>
>> <individual>
>> <homeAddress>
>> <LocalAddress xsi:type="ns3:CompoundLocalAddress"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common">
>> <positionNr xsi:type="xs:int"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema">1</positionNr>
>> <fullAddress xsi:type="xs:string"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema">7783 SOUTH 73 RD
>> STREET</fullAddress>
>> </LocalAddress>
>> <LocalAddress xsi:type="ns3:CompoundLocalAddress"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ns3="http://www.tmforum.org/NGOSS/SID/Business/7.0/Common">
>> <positionNr xsi:type="xs:int"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema">2</positionNr>
>> <fullAddress xsi:type="xs:string"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"></fullAddress>
>> </LocalAddress>
>> </homeAddress>
>> </individual>
>> </instanceData>
>> </data>
>>
>> There are duplicate namespace declaration on the output. How can I set it
>> to be delcared only one time?
>>
>> Thanks,
>>
>
> --
> View this message in context: http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp20069914p20075599.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>