Hi, 
I have the following xsd 
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
            xmlns="urn:test" 
            targetNamespace="urn:test">
        <xsd:element name="smallCar" type="Car"/>
        <xsd:complexType name="Car">
            <xsd:all>
                <xsd:element ref="person" minOccurs="1" maxOccurs="1" />
            </xsd:all>
        </xsd:complexType>

  <xsd:element name="person" type="Person" abstract="true"/>
  
  <xsd:complexType name="Person" abstract="true">
    <xsd:attribute name="id" type="xsd:ID" />
  </xsd:complexType>
  
  <xsd:complexType name="Programmer">
    <xsd:complexContent>
      <xsd:extension base="Person">
        <xsd:attribute name="pId" type="xsd:int" />
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>

Which generates all the right classes, I then have the following test.

import org.apache.xmlbeans.XmlOptions;

import test.Car;
import test.Programmer;
import test.SmallCarDocument;

public class Helper {
        public static void main(String args[]) {
                SmallCarDocument doc =
SmallCarDocument.Factory.newInstance();
                Car car = doc.addNewSmallCar();
                
                Programmer person = Programmer.Factory.newInstance();
                person.setPId(22);
                person.setId("ID");
                car.setPerson(person);
                
                XmlOptions xmlOptions = new XmlOptions();
                xmlOptions.setSavePrettyPrint();
                xmlOptions.setSavePrettyPrintIndent(4);
                
                String output = doc.xmlText(xmlOptions);
                System.out.println(output);
        }
}

Which outputs 
<urn:smallCar xmlns:urn="urn:test">
    <urn:person pId="22" id="ID" xsi:type="urn:Programmer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</urn:smallCar>

Where I would have expected it to output
<urn:smallCar xmlns:urn="urn:test">
    <Programmer pId="22" id="ID"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</urn:smallCar>

The former of the two being invalid because person is abstract
>> error: cvc-elt.2: Element '[EMAIL PROTECTED]:test' is abstract and cannot be
used in an instance
I've searched and looked for an answer to make it so that XMLBeans will
serialize it into the latter to no avail. Can anyone help?

Regards,
Henry


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to