4
類我有2個項目:怎樣才能從XSD包括另一個XSD
xsdproject/
src/main/resources/
a.xsd
b.xsd
implproject/
在implproject我要生成使用maven-JAXB2-插件從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>
,問題就出現在這裏 - > b.xsd有
<xs:include schemaLocation="a.xsd" />
和生成過程中我有一個錯誤:
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>.
有沒有辦法來成功地導入2 XSD和編譯他們?
以下內容應該有所幫助:http://blog.bdoughan.com/2011/10/jaxb-xjc-imported-schemas-and-xml.html – 2014-10-31 14:42:29