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

时间:2014-03-04 10:43:43

标签: java jaxb xsd jaxb2 catalog

我正在尝试从很多XSD中生成一些Java代码。他们中的大多数都工作得很好,但是我遇到了一个特定的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" 

但它不起作用。有人有什么想法吗?

1 个答案:

答案 0 :(得分:1)

不幸的是,maven-jaxb2-plugin项目在这个问题上有一个未解决的问题: Allow rewriting system ids for local files #19