JAXB SCD изменяет имя класса, сгенерированное из сложного типа из схемы - PullRequest
0 голосов
/ 08 января 2020

Мне нравится изменять имя класса, сгенерированное из сложного типа, из следующей схемы common.xsd. «UserType» переименовывается в «User», «UserWithEffectiveDateType» переименовывается в «UserWithEffectiveDate». Я попытался настроить JAXB (v2.2.6) с помощью «обозначения компонента схемы» (SCD). Однако выходные данные состоят из «UserType» и «User», «UserWithEffectiveDateType» и «UserWithEffectiveDate». Как решить эту проблему?

common.xsd:

<xsd:complexType name="UserType">
    <xsd:sequence>
        <xsd:element name="firstname" type="xsd:string"/>
        <xsd:element name="lastname" type="xsd:string"/>
    </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserWithEffectiveDateType">
    <xsd:complexContent>
        <xsd:extension base="xsd:UserType">
            <xsd:sequence>
                <xsd:element name="effectiveDate" type="xsd:date">
                </xsd:element>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>        
</xsd:complexType>

user.xsd:

<xsd:include schemaLocation="common.xsd"/>

scd.xjb:

<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:tns="http://mycomp.com/xmlns/schemas" version="2.1">

    <bindings scd="x-schema::tns">
        <bindings scd="~tns:UserType">
            <class name="User" />
        </bindings>
    </bindings>
    <bindings scd="x-schema::tns">
        <bindings scd="~tns:UserWithEffectiveDateType">
            <class name="UserWithEffectiveDate" />
        </bindings>
    </bindings>
</bindings>

build. xml:

<xjc destdir="${jaxbout}"
  package="com.mycomp.webservices"
  source="2.0">
    <arg line="-extension"/>
    <arg line="-b"/>
    <arg file="${wsdl}/scd.xjb"/>
    <schema dir="${schemadir}">
        <include name="user.xsd"/>
    </schema>
    <depends dir="${schemadir}">
        <include name="common.xsd"/>
    </depends>
    <produces dir="${jaxbout}/com/mycomp/webservices">
        <include name="*.java"/>
    </produces>
</xjc>

output UserWithEffectiveDate. java:

<code>// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6
/*
 * <p>The following schema fragment specifies the expected content contained within this class.
 * <pre>
 * &lt;complexType name="UserWithEffectiveDateType">
 *   &lt;complexContent>
 *     &lt;extension base="{http://mycomp.com/xmlns/schemas}UserType">
 *       &lt;sequence>
 *         &lt;element name="effectiveDate" type="{http://www.w3.org/2001/XMLSchema}date"/>
 *       &lt;/sequence>
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * 
* / @XmlAccessorType (XmlAccessType.FIELD) @XmlType (name = "UserWithEffectiveDateType", propOrder = { «ffectiveDate »}) publi c класс UserWithEffectiveDate расширяет пользователя {// ....}
...