users@jaxb.java.net

Re: JAXBElement binding and the ObjectFactory

From: Sekhar Vajjhala <Sekhar.Vajjhala_at_Sun.COM>
Date: Mon, 09 Jan 2006 13:38:21 -0500

mark_at_javector.com wrote:

>Shouldn't the ObjectFactory createXXX methods return JAXBElement<T> instances
>for local element declarations per 6.7.1 of the JAXB 2.0 specification?
>
No. Section 6.7.1 won't apply but Section 6.7.3,
"Binding of an anonymous complex type definition" applies.

The later part of section 6.7.1 describes the default binding rules
that determine when a createXXX method that returns JAXBElement<T>
instance is generated. And the example shown below does not satisfy any of
those criteria i.e.
a. billTo does not have a named type definition; it has an anonymous
   type definition.
b. the content model of billTo does not bind to a general content property;
   (described in section 6.12.3).

>However, when I run XJC on the following schema:
>
><schema targetNamespace="http://www.example.com/oms"
> elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:oms="http://www.example.com/oms">
> <element name="simpleOrder">
> <complexType>
> <sequence>
> <element name="billTo">
> <complexType>
> <sequence>
> <element name="street" type="string"/>
> <element name="city" type="string"/>
> <element name="state" type="string"/>
> <element name="zip" type="string"/>
> <element name="phone" type="string"/>
> </sequence>
> </complexType>
> </element>
> <element name="items">
> <complexType>
> <sequence>
> <element name="item" type="oms:ItemType" maxOccurs="unbounded"/>
> </sequence>
> </complexType>
> </element>
> </sequence>
> </complexType>
> </element>
> <complexType name="ItemType">
> <sequence>
> <element name="quantity" type="positiveInteger"/>
> <element name="price" type="double"/>
> </sequence>
> <attribute name="productName" use="required" type="string"/>
> </complexType>
></schema>
>
>The ObjectFactory contains the following for the billTo element:
>
> /**
> * Create an instance of {_at_link BillTo }
> *
> */
> public BillTo createSimpleOrderBillTo() {
> return new BillTo();
> }
>
>Shouldn't it return a JAXBElement<BillTo> ??
>
No. See above.

>
>
>-- Mark
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>