Thank you Peter.

At first I didn't believe you, mostly because all of my tools are reporting 
that the document I submitted was valid. However after checking the XML Schema 
conformance recommendation[1] (W3C) I see that an element must be defined to be 
considered valid.

Thank you again for the helpful suggestion
-Duane

[1]http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#conformance



-----Original Message-----
From: Peter Keller [mailto:pkel...@globalphasing.com]
Sent: Thursday, May 27, 2010 2:53 PM
To: user@xmlbeans.apache.org
Subject: Re: XMLBean Document Objects

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