mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
107 stars 77 forks source link

XmlType on a public static enum and a namespace problem. #33

Closed jinahya closed 9 years ago

jinahya commented 9 years ago

Following link is a question.

http://stackoverflow.com/q/32882736/330457

test/Address.java

@XmlRootElement
public class Address {

    @XmlEnum
    @XmlType(name="addressType")
    public static enum Type {
    }
}

test/package-info.java

@XmlSchema(
    attributeFormDefault = XmlNsForm.UNQUALIFIED,
    elementFormDefault = XmlNsForm.QUALIFIED,
    namespace = "http://some",
    xmlns = {
        @XmlNs(prefix = "xsi",
               namespaceURI = XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)
    }
) 
@XmlAccessorType(XmlAccessType.NONE)
package some;

Two separated XSDs are generated.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="..."
           targetNamespace="...">
  <xs:complexType name="address">
    ...
    <xs:sequence>
      ...
      <xs:element name="type" type="addressType"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
  <xs:simpleType name="addressType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="CC"/>
      <xs:enumeration value="BCC"/>
      <xs:enumeration value="TO"/>
      <xs:enumeration value="REPLY_TO"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>