我在这里尝试了JAXB Simplify插件vs*.xjb的问题解决方案.
但它失败了以下例外
"编译器无法遵循这种简化:as-element-property customization.它附加到错误的地方,或者与其他绑定不一致."
这是我使用的自定义绑定
<jaxb:bindings node="//xs:complexType[@name='Op']//xs:choice/xs:element[@name='Time']">
<simplify:as-element-property/>
</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)
jaxb简化插件融合页面是不可访问的,所以有人使用过此插件并可以举个例子吗?
这是我根据答案更新的架构
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://www.amadeus.com/APT/FOM/00" targetNamespace="http://www.amadeus.com/APT/FOM/00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" jaxb:extensionBindingPrefixes="simplify">
...
...
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="Time" type="xs:dateTime" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property />
</xs:appinfo>
</xs:annotation>
</xs:element>
... ...
</xs:choice>
...
Run Code Online (Sandbox Code Playgroud)
我在maven构建期间得到了异常,例如"不支持的绑定命名空间" http://jaxb2-commons.dev.java.net/basic/simplify ".也许你的意思是" http://jaxb.dev.java.net/plugin/code-injector "?"
我有一个WSDL文件weatherservice.wsdl,我正在尝试使用生成与此WSDL的绑定xjc。如何使用xjc执行此操作?
我从xjc中找不到任何命令行参数来执行此操作。 xjc -p com -wsdl weatherservice.wsdl
今天我遇到了一个令人难以置信的问题,我无法解决。我将从解释和示例开始。
我有 2 个 XSD 文件。一个 XSD 文件引用另一个 XSD 文件的元素之一。
第一个 XSD-ReportInfo.xsd:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xs:schema id="ReportInfoWrapper" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="ReportInfoWrapper" >
<xs:complexType>
<xs:sequence>
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
第二个 XSD-ReportInfoRecordSet.xsd:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xs:schema id="ReportInfoRecordSetWrapper" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:include schemaLocation="./ReportInfo.xsd" />
<xs:element name="ReportInfoRecordSetWrapper">
<xs:complexType>
<xs:sequence>
<xs:element ref="ReportInfoWrapper" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
ReportInfoRecordSet 引用 ReportInfoWrapper(ReportInfo 的根元素)。我需要知道在 JAXB 绑定文件中定义什么来更改 ReportInfoRecordSet 中此引用元素的生成名称。这是它当前生成的:
public class ReportInfoRecordSetWrapper {
@XmlElement(name = "ReportInfoWrapper", required = true)
protected List<ReportInfoWrapper> reportInfoWrappers; //I …Run Code Online (Sandbox Code Playgroud) 我试图将不同的名称空间分配给不同的 xsd 文件,并使用 jaxb2-maven 插件来构建由这些 xsd 文件定义的工件。
Maven 无法生成源并出现以下错误:The namespace of element 'bindings' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'
这是我的配置:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<jaxb:bindings schemaLocation="xsd/TheRequest.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.package.request" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="xsd/TheResponse.xsd" node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.package.response" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://company.services.com"
xmlns:tns="http://company.services.com"
elementFormDefault="unqualified">
<xsd:complexType name="FindSomething">
<xsd:sequence>
<xsd:element name="TestMode" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Channel" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="UserId" type="xsd:string" maxOccurs="1" minOccurs="1"/>
<xsd:element name="Role" type="xsd:string" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Format" …Run Code Online (Sandbox Code Playgroud)