Hi Duane,

In order to have non-empty documents that are valid with respect to an XML schema, a root element must be defined in the schema. This is not a limitation of XMLBeans, but an aspect of the way that XML schema works.

If you cannot modify the schema by adding a root element definition, I suggest that you define a new, trivial, schema that imports the one that you are working with now, and define the root element in that. You should be able to use the same target namespace in both schema files. If you then use this new trivial schema as the input to scomp, you should get FooDocument.java. You may need to add a "schemaLocation" attribute to your <xsd:import...> element to get scomp to pull in the type definition automatically.

Good luck,
Peter.

On Thu, 27 May 2010, Duane Zamrok wrote:

Hello,

I’m working with an XML schema that defines a complex type but not an element 
of that type. This means that when I compile the schema
with XMLBeans I get FooType.java but not a FooDocument.java. However, I’d like 
to be able to parse documents whose root element has been
defined to be of type Foo. Is this possible with XMLBeans or should I simply 
pursue a manual parsing alternative?

 

 

Example Schema

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="urn:org:test:namespace" elementFormDefault="qualified">
    <xs:complexType name="FooType">
        <xs:sequence>
            <xs:element name="bar" type="xs:string"/>
        </xs:sequence>       
    </xs:complexType>
</xs:schema>

 

Example Document

<someElementName xmlns:tst="urn:org:test:namespace" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="tst:FooType">
    <tst:bar>some value</tst:bar>   
</someElementName>

 

Thanks

-Duane




--
Peter Keller                                     Tel.: +44 (0)1223 353033
Global Phasing Ltd.,                             Fax.: +44 (0)1223 366889
Sheraton House,
Castle Park,
Cambridge CB3 0AX
United Kingdom
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to