java - 具有相对路径的 Jaxb2 目录文件

标签 java jaxb xsd jaxb2 catalog

我正在尝试从大量 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/

相关文章:

java - 使用 java - ref 的 JSON 模式验证

java - 启动后,Android应用程序崩溃。按钮问题?

xml - 为什么XJC生成@XmlElementRefs

java - 从 XML 文件读取内容时如何保留 "Character Reference Codes"(<)

xml - 导入 ComplexType 时 Xsd.exe 无法生成类

java - gradle 构建失败,jooq 配置 : java. lang.ClassNotFoundException : com. mysql.jdbc.Driver

java - 我将如何创建 "infinite"循环,直到用户决定退出?

xsd - XJC 生成整数而不是 int

C# 序列化 xsi :type and xsd

使用 SDL Tridion 的 XSD 方面和指标