xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miroslav Genov <mge...@gmail.com>
Subject XMLBeans Code generation problem
Date Sat, 02 Sep 2006 16:02:08 GMT
Hi everyone,
I have problem with  XML Beans when i want to generate xml file.

This the code that cause an error
public static void main(String[] args) {
        LanguageSpecificDataItemDocument language = 
LanguageSpecificDataItemDocument.Factory.newInstance();       
        NameAndAddressType address = 
NameAndAddressType.Factory.newInstance();       
        NameType name = NameType.Factory.newInstance();
       
        address.setName(name);       
        address.addNewAddress();       
       
        language.setLanguageSpecificDataItem(address);
        validate(language);
        log.info(address);
       
        //log.info("\n" + language.getLanguageSpecificDataItem());
    }
    private static void validate(XmlObject o) {
       
        ArrayList validationErrors = new ArrayList();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener(validationErrors);
        boolean errors = o.validate(validationOptions);
        if (!errors) {
            Iterator iter = validationErrors.iterator();
            while (iter.hasNext()) {
                log.info(">> " + iter.next() + "\n");
            }
        }
    }

 And schema code
<xs:complexType name="AbstractLanguageSpecificDataItemType" abstract="true">
    <xs:sequence>
      <xs:element name="Value" type="xs:string" minOccurs="0" />
    </xs:sequence>
    <xs:attribute name="language" type="SimpleLanguageCodeType" 
use="optional" />
  </xs:complexType>

<xs:element name="NameAndAddress" type="NameAndAddressType" />
  <xs:complexType name="NameAndAddressType">
    <xs:complexContent>
      <xs:extension base="lsd:AbstractLanguageSpecificDataItemType">
        <xs:sequence>
          <xs:element ref="Name" />
          <xs:element ref="Address" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

This is displayed error message when i try to validate generated message.
INFO: >> error: cvc-elt.2: Element 
'T=AbstractLanguageSpecificDataItemType@http://seed.dgtaxud.ec/common/lsd' 
is abstract and cannot be used in an instance

Any ideas how to fix this ?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Mime
View raw message