java如何在jaxb XJC生成期间重命名xs:simpleType?
我正在使用jaxb
和xjc
从xsd
文件自动生成java类
问题:我有两个文件显示相同的simpleType
名称。从而得到一个编译错误:
xsd1.xsd [49:3]: 'FileKey' is already defined
xsd1:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="FileKey">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9_]+" />
</xs:restriction>
</xs:simpleType>
...
</xs:schema>
xsd2:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="FileKey">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9_]+" />
</xs:restriction>
</xs:simpleType>
...
</xs:schema>
我尝试的绑定文件:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="xsd1.xsd">
<jaxb:bindings node="//xs:simpleType[@name='FileKey']">
<jaxb:class name="FileKeyRenamed" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
旁注:我无法修改XSD,因为我无法控制它们
共 (0) 个答案