gpt4 book ai didi

java - 什么是 .episode 文件..?

转载 作者:IT老高 更新时间:2023-10-28 21:03:37 25 4
gpt4 key购买 nike

什么是 JAXB 中的 .episode 文件..?它是由 JAXB 生成的,还是我们为了避免 JAXB 重新生成相同类而操作的配置文件..?

最佳答案

注意:我是 EclipseLink JAXB (MOXy) 的负责人,也是 JAXB 2 (JSR-222) 专家组的成员。

.episode 文件由 XJC(XML Schema to Java)编译器生成。它是将模式类型与现有类相关联的模式绑定(bind)。当您有一个由其他模式导入的 XML 模式时,它很有用,因为它会阻止重新生成模型。下面是一个例子:

Product.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Product"
xmlns:tns="http://www.example.org/Product"
elementFormDefault="qualified">
<element name="product">
<complexType>
<sequence>
<element name="id" type="string"/>
<element name="name" type="string"/>
</sequence>
</complexType>
</element>
</schema>

由于多个 XML 模式导入 Product.xsd,我们可以利用情节文件,以便与 Product.xsd 对应的类只生成一次。

xjc -d out -episode product.episode Product.xsd

ProductPurchaseRequest.xsd

以下是导入 Product.xsd 的 XML 架构示例:

<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/ProductPurchaseRequest"
xmlns:tns="http://www.example.org/ProductPurchaseRequest"
xmlns:prod="http://www.example.org/Product"
elementFormDefault="qualified">
<import namespace="http://www.example.org/Product" schemaLocation="Product.xsd"/>
<element name="purchase-request">
<complexType>
<sequence>
<element ref="prod:product" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</schema>

当我们从这个 XML 模式生成类时,我们将引用我们从 Product.xsd 生成 Java 类时创建的剧集文件。

xjc -d out ProductPurchaseRequest.xsd -extension -b product.episode

ProductQuoteRequest.xsd

下面是另一个导入 Product.xsd 的 XML 模式示例:

<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/ProductQuoteRequest"
xmlns:tns="http://www.example.org/ProductQuoteRequest"
xmlns:prod="http://www.example.org/Product"
elementFormDefault="qualified">
<import namespace="http://www.example.org/Product" schemaLocation="Product.xsd"/>
<element name="quote">
<complexType>
<sequence>
<element ref="prod:product"/>
</sequence>
</complexType>
</element>
</schema>

当我们从这个 XML 模式生成类时,我们将引用我们在从 Product.xsd 生成 Java 类时创建的剧集文件。

xjc -d out ProductQuoteRequest.xsd -extension -b product.episode

更多信息

关于java - 什么是 .episode 文件..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9756185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com