users@jaxb.java.net

Validation error marshalling using subclass Types

From: Allister Bertram <abertram_at_checkfree.com>
Date: Tue, 06 May 2003 06:33:13 -0600

I'm having problems building a "valid" content model for marshalling to XML. My Schema includes the following:

  <complexType name="iSeriesType" abstract="true">
    <sequence>
      <element minOccurs="0" name="AddDocRef" type="cf:AddDocRefType" />
      <element minOccurs="0" maxOccurs="unbounded" name="Contact" type="cf:ContactType" />
      <element minOccurs="0" maxOccurs="unbounded" name="AuditLog" type="cf:AuditLogType" />
    </sequence>
  </complexType>

AND

  <complexType name="ContactType">
    <complexContent>
      <element name="Locale" type="cf:LocaleType" />
      <element name="Priority" type="string" />
      <element name="Type" type="string" />
      <element minOccurs="0" name="Description" type="string" />
      <element minOccurs="0" name="URL" type="string" />
      <element minOccurs="0" maxOccurs="unbounded" name="Address" type="cf:AddressType" />
      <element minOccurs="0" maxOccurs="unbounded" name="EmailAddress" type="cf:EmailAddressType" />
      <element minOccurs="0" maxOccurs="unbounded" name="PhoneNumber" type="cf:PhoneNumberType" />
    </sequence>
  </complexType>

AND

  <complexType name="PersonContactType">
    <complexContent>
      <extension base="cf:ContactType">
        <sequence>
          <element name="PersonName" type="cf:PersonNameType" />
          <element minOccurs="0" name="JobTitle" type="string" />
        </sequence>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="BusinessContactType">
    <complexContent>
      <extension base="cf:ContactType">
        <sequence>
          <element name="Name" type="string" />
        </sequence>
      </extension>
    </complexContent>
  </complexType>

Notice that BusinessContactType is an extension of ContactType, and that an iSeriesType can contain elements of type ContactType. However, when I try to use the ObjectFactory.newInstance() method to build JAXB content objects for BusinessContactType, I get a validation message as in the following:

tag name "com.checkfree.isolutions.payment.jaxb.binding.BusinessContactType" is not allowed. Possible tag names are: <com.checkfree.isolutions.payment.jaxb.binding.ContactType>

I need to instantiate a BusinessContactTypeImpl to add into my iSeriesTypeImpl. How can I achieve this?