我正在尝试从大量 XSD 中生成一些 Java 代码。它们中的大多数工作得很好,但是我在使用一个特定的 XSD 时遇到了麻烦,该 XSD 使用相对路径导入另一个 XSD。一个例子:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xmpl="http://example.com/this/is/namespace" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/this/is/namespace">
<include schemaLocation="../../0301/required.xsd" />
<some> ... xml ... </some>
</schema>
当然,这是由于客户原因而匿名的 XSD。但是,我已经构建了它在另一个模块中引用的另一个 XSD。顺便说一句,这效果很好。所以现在我想解决包含问题,但目前没有成功。我尝试过不同的多个目录,如下所示:
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
<public publicId="required.xsd" uri="maven:com.geodan.imgeo:stuf!stuf0301!stuf/stuf0301.xsd" />
<public publicId="../../0301/required.xsd" uri="maven:com.project.example!module!folder/required.xsd" />
<public publicId="http://example.com/this/is/namespace/required.xsd" uri="maven:com.project.example!module!folder/required.xsd" />
<public publicId="http://example.com/this/is/namespace/../../required.xsd" uri="maven:com.project.example!module!folder/required.xsd" />
<public publicId="http://example.com/stuf0301.xsd" uri="maven:com.project.example!module!folder/required.xsd" />
</catalog>
和
--
Standard Catalog test file for Imgeo
--
PUBLIC "http://example.com/this/is/namespace/required.xsd" "module/src/main/resources/folder/required.xsd"
PUBLIC "../../0301/required.xsd" "module/src/main/resources/folder/required.xsd"
PUBLIC "0301/required.xsd" "module/src/main/resources/folder/required.xsd"
但这行不通。有人有什么想法吗?
最佳答案
不幸的是,maven-jaxb2-plugin 项目在这个主题上有一个 Unresolved 问题: Allow rewriting system ids for local files #19
关于java - 具有相对路径的 Jaxb2 目录文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22169681/