By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

JAXB creating Nested Interface from XSD Definition

P: n/a
We have an issue where the JAXB generated classes are creating an
interface which references itself. The Schema is valid, and I have
not seen this ran into before. The code is below. What is interesting,
is if I change the name of ErrorType to Error the issue goes away.

Has anyone else ran into this issue? Do you have a solution?

The pertanant part of the schema:

<snip>

<xsd:element name="Errors" type="ErrorType"/>
<xsd:complexType name="ErrorType">
<xsd:sequence>
<xsd:element name="Error" maxOccurs="unbounded">
<xsd:complexType>
<xsd:all>
<xsd:element name="ErrorCode">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="ErrorMessageText">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
</xsd:all>
<xsd:attribute name="Level" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

</snip>

and the Java Code that JAXB generated

<snip>
//
// This file was generated by the JavaTM Architecture for XML
Binding(JAXB) Reference Implementation, vBeta
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of
the source schema.
// Generated on: 2003.08.29 at 09:35:26 EDT
//
package prime.ccs;
/**
* The following schema fragment specifies the expected content
contained within this java content object.
* <p>
* <pre>
* &lt;complexType name="ErrorType">
* &lt;complexContent>
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Error" maxOccurs="unbounded">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="ErrorCode">
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;/restriction>
* &lt;/element>
* &lt;element name="ErrorMessageText">
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;/restriction>
* &lt;/element>
* &lt;/all>
* &lt;attribute name="Level" use="required"
type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*/
public interface ErrorType {
java.util.List getError();
/**
* The following schema fragment specifies the expected content
contained within this java content object.
* <p>
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="ErrorCode">
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;/restriction>
* &lt;/element>
* &lt;element name="ErrorMessageText">
* &lt;restriction
base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;/restriction>
* &lt;/element>
* &lt;/all>
* &lt;attribute name="Level" use="required"
type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*/
public interface ErrorType {
String getErrorMessageText();

void setErrorMessageText(String value);

String getLevel();

void setLevel(String value);

String getErrorCode();

void setErrorCode(String value);

}

}
</snip>
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.