更新-問題が修正されました
この問題の次のバグを入力していただきありがとうございます。
これは、EclipseLink2.4.2および2.5.0ストリームで修正されました。以下の考えから、2013年2月12日から毎晩ダウンロードして修正を試すことができます。
私はあなたが見ている問題を再現することができませんでした。以下は私がこれまでに試したことです。
シナリオ#1-Person
そしてIdentifierType
同じ名前空間で
POJOと列挙型が同じ名前空間にある場合、1つのXMLスキーマのみが生成されます。
人(POJO)
package forum14778338;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Person {
private IdentifierType identifierType;
public IdentifierType getIdentifierType() {
return identifierType;
}
public void setIdentifierType(IdentifierType identifierType) {
this.identifierType = identifierType;
}
}
IdentifierType
package forum14778338;
public enum IdentifierType {
FOO,
BAR
}
jaxb.properties
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
デモ
package forum14778338;
import java.io.IOException;
import javax.xml.bind.*;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(Person.class);
jc.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String namespaceURI, String suggestedFileName)
throws IOException {
StreamResult result = new StreamResult(System.out);
result.setSystemId(suggestedFileName);
return result;
}
});
}
}
出力
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="person">
<xsd:sequence>
<xsd:element name="identifierType" type="identifierType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="person" type="person"/>
<xsd:simpleType name="identifierType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="FOO"/>
<xsd:enumeration value="BAR"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
シナリオ#2-Person
およびIdentifierType
異なる名前空間
POJOとEnumが異なる名前空間にある場合は、2つのXMLスキーマを生成する必要があります。
IdentifierType
@XmlType
列挙型に注釈を追加しIdentifierType
て、別の名前空間に配置しました。
package forum14778338;
import javax.xml.bind.annotation.*;
@XmlEnum
@XmlType(namespace="foo")
public enum IdentifierType {
FOO,
BAR
}
出力
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ns0="foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import schemaLocation="schema2.xsd" namespace="foo"/>
<xsd:complexType name="person">
<xsd:sequence>
<xsd:element name="identifierType" type="ns0:identifierType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="person" type="person"/>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ns0="foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="foo">
<xsd:simpleType name="identifierType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="FOO"/>
<xsd:enumeration value="BAR"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>