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 not able to parse extended xml schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "not able to parse extended xml schema " Watch "not able to parse extended xml schema " New topic

not able to parse extended xml schema

avinash sudh

Joined: Apr 22, 2013
Posts: 8
Hi all,

I am trying to generate java classes out of ApiExceptionExtended.xsd. ApiExceptionExtended.xsd is an extension of ApiException.xsd.
However I am running into this error.

C:\Users\avinashms\POC\xero_POC\XSD_Download\XeroAPI-Schemas-master\v2.00\xsd_experiment>xjc -d src -p org.xero.poc.apiextended ApiExceptionExtended.xsd

parsing a schema...
[ERROR] cos-all-limited.1.2: An all model group must appear in a particle with {min occurs} = {max occurs} = 1, and that particle must be part of a pair which constitutes the {content type} of a complex ty
pe definition.
line 35 of file:/C:/Users/avinashms/POC/xero_POC/XSD_Download/XeroAPI-Schemas-master/v2.00/xsd_experiment/ApiExceptionExtended.xsd

[ERROR] s4s-elt-invalid-content.1: The content of '#AnonType_ElementsApiExceptionExtended' is invalid. Element 'element' is invalid, misplaced, or occurs too often.
line 38 of file:/C:/Users/avinashms/POC/xero_POC/XSD_Download/XeroAPI-Schemas-master/v2.00/xsd_experiment/ApiExceptionExtended.xsd
Below are the ApiException.xsd and ApiExceptionExtended.xsd files :

ApiException.xsd file :

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ApiException" elementFormDefault="qualified" xmlns:xs="">

<!-- API Exception -->
<xs:complexType name="ApiException">
<xs:element name="ErrorNumber" type="xs:integer" minOccurs="1" maxOccurs="1" />
<xs:element name="Type" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Message" type="xs:string" minOccurs="1" maxOccurs="1" />



ApiExceptionExtended.xsd file :

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ApiException"

<xs:include schemaLocation="ApiException.xsd" />

<xs:include schemaLocation="Account.xsd" />
<xs:include schemaLocation="BankTransaction.xsd" />
<xs:include schemaLocation="BrandingTheme.xsd" />
<xs:include schemaLocation="Contact.xsd" />
<xs:include schemaLocation="CreditNote.xsd" />
<xs:include schemaLocation="Currency.xsd" />
<xs:include schemaLocation="Employee.xsd" />
<xs:include schemaLocation="ExpenseClaim.xsd" />
<xs:include schemaLocation="Invoice.xsd" />
<xs:include schemaLocation="Items.xsd" />
<xs:include schemaLocation="Journal.xsd" />
<xs:include schemaLocation="ManualJournal.xsd" />
<xs:include schemaLocation="Organisation.xsd" />
<xs:include schemaLocation="Payment.xsd" />
<xs:include schemaLocation="Receipt.xsd" />
<xs:include schemaLocation="Report.xsd" />
<xs:include schemaLocation="TaxRate.xsd" />
<xs:include schemaLocation="Tracking.xsd" />
<xs:include schemaLocation="User.xsd" />

<!-- API Exception -->
<xs:complexType name="ApiExceptionExtended">
<xs:extension base="ApiException">
<xs:element name="Elements" minOccurs="1" maxOccurs="1">
<xs:element name="DataContractBase" type="xs:anyType" />

Please let me know what I could do to fix it.
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199

Are you allowed to change the schema definition?
avinash sudh

Joined: Apr 22, 2013
Posts: 8
Hi Carles,

I think I can ... I would like to change it to overcome this error.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 619
@avinash sudh
Within the big picture, you have no chance to succeed with the schema you're intending to do, by extending a base complexType with a content model of xs:all. xs:all is akin to a "final" class, you can't extend it. There are two alternatives in the least.

[1] Either you modify the ApiException type to include an additional element "Elements" (if that is what you mean of extending it).
[2] You change the ApiException type to an xs:sequence content model. Consequence, you give up the arbitrary order (which is not that useful and for what good you make it in an arbitrary order?!) of the child elements.

[2.1] If you choose the course of [2], you extension syntax is incorrect that need to correct. xs:element cannot be a direct child to xs:complexType. That is invalid.
avinash sudh

Joined: Apr 22, 2013
Posts: 8

Thank you so much for the explanation given about the issue. It resolved my issue.
I agree. Here's the link:
subject: not able to parse extended xml schema
It's not a secret anymore!