Warm tip: This article is reproduced from stackoverflow.com, please click
java xsd

Error while trying to create Java Class out of .xsd file

发布于 2020-04-22 10:45:25

I have two XMLs and i want convert them into java classes so i went to this page where i can generate .xsd files. I'm trying to make two Java Class out of them in Eclipse and I'm getting the same error:

parsing a schema...
[ERROR] Content is not allowed in prolog.
  line 1 of file:/(...)/queryClass.xsd

Failed to parse a schema.

These are my .xsd files:

First:

<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="dao" type="daoType" />
  <xsd:complexType name="daoType">
    <xsd:sequence>
      <xsd:element name="query" type="queryType" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="queryType">
    <xsd:sequence>
      <xsd:element name="arguments" type="argumentsType" />
      <xsd:element name="statement" type="xsd:string" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" />
  </xsd:complexType>
  <xsd:complexType name="argumentsType">
    <xsd:sequence>
      <xsd:element name="argument" type="argumentType" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="argumentType">
    <xsd:attribute name="name" type="xsd:string" />
  </xsd:complexType>
</xsd:schema>

Second:

<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="properties" type="propertiesType" />
  <xsd:complexType name="propertiesType">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" name="entry" type="entryType" />
    </xsd:sequence>
    <xsd:attribute name="version" type="xsd:decimal" />
  </xsd:complexType>
  <xsd:complexType name="entryType">
    <xsd:attribute name="key" type="xsd:string" />
  </xsd:complexType>
</xsd:schema>
Questioner
CoralWombat
Viewed
34
CoralWombat 2020-02-07 00:16

It turned out that the XSD files were wrong. I used another XML-XSD converter and it worked perfectly fine.