Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.19
-
Fix Version/s: 1.20
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
In our JAXB classes, we have some common classes in a common namespace, and some other classes in separate namespaces that use those common classes.
roughly:
/** * The common element */ @XmlType(name="common", namespace="common") @XmlRootElement(name="common", namespace="common") class Common { private String something; /** * The something element */ @XmlElement(name="something") public String getSomething() { return something; } } /** * The something else element */ @XmlType(name="something-else", namespace="something-else") @XmlRootElement(name="something-else", namespace="something-else") class SomethingElse { private Common common; /** * I'm using a common from the common namespace */ @XmlElement(name="common", namespace="common") public Common getCommon() { return common; } }
The problem that occurs is when generating the schema file for the 'common' namespace,
the @XmlElement annotation in the SomethingElse class causes a duplicate 'xs:element' to be added to the common namespace.
The resulting 'common' XSD file looks like:
<xs:schema version="1.0" targetNamespace="common" xmlns:cmn="common" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="common" type="cmn:common"/> <xs:complexType name="common"> <xs:annotation> <xs:documentation> <![CDATA[The common element]]> </xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="something" type="xs:string" minOccurs="0"> <xs:annotation> <xs:documentation> <![CDATA[The something element]]> </xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> <xs:element name="common" type="cmn:common"> <xs:annotation> <xs:documentation> <![CDATA[I'm using a common from the common namespace]]> </xs:documentation> </xs:annotation> </xs:element> </xs:schema>
Note the second occurrence of 'xs:element name="common", this causes the schema to emit errors when trying to use it for validation.
I'm attaching my examples hooked up with a little maven project that spits out the generated schemas.
Thanks!
-Cameron
ah snap, sorry didn't realize wiki markup was on for the description or I'd have put it in {code}