File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes unexpected child element xs:element error?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "unexpected child element xs:element error??" Watch "unexpected child element xs:element error??" New topic

unexpected child element xs:element error??

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Im getting a unexpected child element xs:element error at ****
Im quite new to schemas. Thank you all for your time.

<xs:schema xmlns:xs=""

<xs:element name="time" type="xs:int" default="1"/>
<xs:element name="timeType">
<xs:restriction base="xs:string" default="weeks">
<xs:enumeration value="minutes"/>
<xs:enumeration value="hours"/>
<xs:enumeration value="days"/>
<xs:enumeration value="weeks"/>

<xs:complexType name="refresh">
<xs:element ref="target:time"/>
<xs:element ref="target:timeType"/>

<xs:complexType name="query">
<xs:extension base="xs:string">
<xs:attribute name="series" type="xs:string" use="required"/>

<xs:complexType name="chartDefinition">
<xs:element ref="target:refresh"/>
<xs:element ref="target:query"/>
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="title" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="xaxislabel" type="xs:string" use="required"/>
<xs:attribute name="yaxislabel" type="xs:string" use="required"/>
<xs:attribute name="classType" default="com.dms.chart.DefaultChartBusinessHandler">
<xs:restriction base="xs:string" >
<xs:enumeration value="com.dms.chart.DefaultChartBusinessHandler"/>
<xs:enumeration value="com.dms.chart.PieChartBusinessHandler"/>
<xs:attribute name="width" type="xs:int" default="500"/>
<xs:attribute name="height" type="xs:int" default="500"/>
<xs:attribute name="chartColor" type="xs:string" default="#FFFFFF"/>

<xs:element name="charts">
**** <xs:element ref="target:chartDefinition" maxOccurs="unbounded"/>
clio katz
Ranch Hand

Joined: Apr 30, 2004
Posts: 101

The schema has validation errors.

my validating schema parser emits


not sure why there are asterisks in line 58:

**** <xs:element ref="target:chartDefinition" maxOccurs="unbounded"/>

the other errors you can trace out by the ":line:col:" notations and the error titles above. write back if you run into trouble!

Tom Passin
Ranch Hand

Joined: Aug 08, 2004
Posts: 30
You are not allowed to have an xs:element there. You are supposed to have a sequence, choice, etc., that would contain the element (even if there is only one, it can still be a sequence or choice).

Author of <a href="" target="_blank" rel="nofollow">Explorer's Guide to the Semantic Web</a>

Joined: Aug 28, 2004
Posts: 1

I have this schema and it gives me the same error...

Can anyone, please, tell what's wrong with it?

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Hello Janis,

May I ask you to add a last name into your display name so that it complies with our naming policy?

Thanks, and welcome to the 'ranch!

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: unexpected child element xs:element error??
jQuery in Action, 3rd edition