English 中文(简体)
定义带有 xjc 和装订的通用 XSD s 和 xjc 的套件名称
原标题:Defining package names for common XSD s with xjc and bindings

我试图从几个特定的 XSD 中生成 Java 类, 包括 < code> xjc 。 这些图案有一些共同的定义, 所以它们导入了一些共同的 XSD 类。 特别是, 它们可以包含从零到所有共同的 XSD 类 。

我喜欢从特定的 XSD 到特定的软件包中生成所有类, 但将生成的普通方程式类 保留在一个共同的软件包中, 这样它们不会在源树上每个特定的方程式中被重复 。

我了解到,可以使用定制装订物,按每个系统指定包件,例如:

<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
    <jxb:schemaBindings>
        <jxb:package name="mypackage.commonclasses"/>
    </jxb:schemaBindings>
</jxb:bindings>

我有以下结构:

schemas
| - common
| | - common1.xsd --> XSD with common types #1
| | - ...
| | - commonN.xsd --> XSD with common types #N
| | - commonBindings.xjb --> Defines package "mypackage.commons" for common*.xsd
| - specific1
| | - specific1.xsd --> Includes ../common/common{1-N}.xsd
| | - specific1.xjb --> Defines package "mypackage.specific1" for specific1.xsd
| - specificN
| | - specificN.xsd --> Includes only ../common/common1.xsd
| | - specificN.xjb --> Defines package "mypackage.specificN" for specificN.xsd

一切顺利地与:

xjc -b schemas/specific1
    -b schemas/common 
    schemas/specific1/specific1.xsd

它在 mepackage. code1 mypackage.commons 中生成 特定类别1. xsd 。 但是,当我试图生成 特定类别N 的分类时, xjc 的错误如下:

[ERROR] "file:/drive/dir/schemas/common/common1.xsd" is not a part of
 this compilation. Is this a mistake for "/drive/dir/schemas/common/commonBindings.xjb"?
  line 2 of file:/drive/dir/schemas/common/commonBindings.xjb

对于在任何特定的 xsd 中未导入的每个常见 XSD, 我都会重复此错误 。

是否有办法我可以让 xjc 忽略 commonBindings.xjb 中在 XSD I m 生成分类时没有使用的绑定?

或者,我是否通过使用这种方法瞄准错误的方向,例如,应该使用特定的 xsd 中的注解?如果可能,我想避免修改方案。

最佳回答
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签