1

なぜこのスキーマなのか:

<xsd:complexType name="ErrType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
 <xsd:element name="errorCode" type="xsd:string"/>
 <xsd:element name="errorDescription" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

このJavaコードを生成します。

class ErrType {
  @XmlElementRefs({
    @XmlElementRef(name = "errorCode", namespace = "http://somewhere/blah.xsd", type = JAXBElement.class),
    @XmlElementRef(name = "errorDescription", namespace = "http://somewhere/blah.xsd", type = JAXBElement.class)
  })
  protected List<JAXBElement<String>> errorCodeAndErrorDescription;
  // ... 
}

私はもっ​​と次のようなものを期待していたでしょう:

class ErrType extends ArrayList<ErrTypeEntry> {}
class ErrTypeEntry {
  protected String errorCode
  protected String errorDescription;
}

さて、答えはそうだと思います。2つのフィールドを1つのフィールドに結合することは非常に望ましくないようです。重要な構造を不必要に削除しました。

4

1 に答える 1

1

私の推測では、(構造的に) 期待に近いものを得るには、次のようにスキーマをもう少し書く必要があると思います。

<xsd:complexType name="ErrTypeEntry">
  <xsd:sequence>
    <xsd:element name="errorCode" type="xsd:string"/>
    <xsd:element name="errorDescription" type="xsd:string"/>
  </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Errors">
  <xsd:sequence>
    <xsd:element name="error" type="ErrTypeEntry" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>
于 2012-06-07T21:50:50.717 に答える