【发布时间】:2011-08-27 06:10:25
【问题描述】:
我正在使用 maven 插件 maven-jaxb2-plugin 从 XSD Schema 文件生成 POJO。 这工作正常。唯一让我感到困扰的是,xml 模式枚举没有映射到 Java 枚举类型中。
我的 maven 插件正在从我称为 schemachooser.xsd 的文件中生成 java pojos
schemachooser.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sch="http://www.ascc.net/xml/schematron"
targetNamespace="http://schema.something" elementFormDefault="qualified"
version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings generateIsSetMethod="true" fixedAttributeAsConstantProperty="true">
<xjc:serializable />
</jaxb:globalBindings>
<jaxb:schemaBindings>
<jaxb:bindings node="//xsd:element[@name='ElementName']/xsd:simpleType">
<jaxb:typesafeEnumClass name="MyEnumType" />
</jaxb:bindings>
</jaxb:schemaBindings>
</xs:appinfo>
</xs:annotation>
<xs:include schemaLocation="myNormalSchema.xsd" />
</schema>
它会生成文件,但不会生成“新”枚举类“MyEnumType”。我是不是用错了绑定?
【问题讨论】: