[英]How can I generate classes from XSD that includes another XSD
I have 2 projects: 我有2个项目:
xsdproject/
src/main/resources/
a.xsd
b.xsd
implproject/
In implproject I want to generate classes from xsd using maven-jaxb2-plugin. 在implproject中,我想使用maven-jaxb2-plugin从xsd生成类。
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<cleanPackageDirectories>true</cleanPackageDirectories>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<dependencyResource>
<groupId>some.group</groupId>
<artifactId>xsdproject</artifactId>
<version>${project.version}</version>
<resource>a.xsd</resource>
</dependencyResource>
</schema>
<schema>
<dependencyResource>
<groupId>some.group</groupId>
<artifactId>xsdproject</artifactId>
<version>${project.version}</version>
<resource>b.xsd</resource>
</dependencyResource>
</schema>
</schemas>
</configuration>
</plugin>
The problem comes here -> b.xsd has 问题来了 - > b.xsd有
<xs:include schemaLocation="a.xsd" />
and during generation I have an error: 在生成过程中我有一个错误:
Failed to read schema document 'a.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Is there a way to succesfully import 2 XSD and compile them? 有没有办法成功导入2 XSD并编译它们?
Disclaimer. 免责声明。 I am the author of the
maven-jaxb2-plugin
. 我是
maven-jaxb2-plugin
。
Try the following: 请尝试以下方法:
src/main/resources/catalog.cat
: src/main/resources/catalog.cat
:
REWRITE_SYSTEM "a.xsd" "maven:some.group:xsdproject:jar::!/a.xsd"
In the configuration
in pom.xml
在
pom.xml
的configuration
中
<catalog>src/main/resource/catalog.cat</catalog>
(See Using Catalogs .) (请参阅使用目录 。)
I also think you only need to compile b.xsd
. 我还认为你只需要编译
b.xsd
。 a.xsd
should be included automatically. 应自动包含
a.xsd
。
In case of problems run mvn -X clean install
and check the log. 如果出现问题,请运行
mvn -X clean install
并检查日志。
See also: 也可以看看:
If you need further support, please file an issue and provide a sample project. 如果您需要进一步的支持,请提交问题并提供示例项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.