qua*_*ypt 33 java web-services jaxb web
什么是JAXB中的.episode文件..?它是由JAXB生成的还是我们操作的配置文件,以避免JAXB重新生成相同的类?
bdo*_*han 30
注意:我是EclipseLink JAXB(MOXy)的负责人,也是JAXB 2(JSR-222)专家组的成员.
.episode文件由XJC(XML Schema to Java)编译器生成.它是一种模式绑定,它将模式类型与现有类相关联.当您有一个由其他模式导入的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>
Run Code Online (Sandbox Code Playgroud)
由于多个XML模式导入Product.xsd,我们可以利用episode文件,以便只生成一次与Product.xsd相对应的类.
xjc -d out -episode product.episode Product.xsd
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
当我们从这个XML模式生成类时,我们将引用我们从Product.xsd生成Java类时创建的剧集文件.
xjc -d out ProductPurchaseRequest.xsd -extension -b product.episode
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
再次,当我们从这个XML模式生成类时,我们将引用我们从Product.xsd生成Java类时创建的剧集文件.
xjc -d out ProductQuoteRequest.xsd -extension -b product.episode
Run Code Online (Sandbox Code Playgroud)
欲获得更多信息
我会添加一些琐事.
.episode文件只是普通的绑定文件(这就是他们使用的原因xjc -b).-episode这样).META-INF/sun-jaxb.episode路径下的JAR中,您可以这样做xjc b.xsd a.jar- XJC将扫描JAR以查找剧集文件,然后自动使用作为绑定文件.| 归档时间: |
|
| 查看次数: |
17124 次 |
| 最近记录: |