xjc为@XMLAttribute生成错误的List <string>

时间:2017-03-07 19:20:08

标签: java xsd xjc

我有一个XML Schema,它定义了一个名为&#34; attribute&#34;的XML元素。使用名为&#34; path&#34;的XML属性;当给予xjc 2.2.8-b130911.1802时,似乎生成了错误的Java代码。

Java生成的代码:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "attribute")
public class Attribute {

  @XmlAttribute(name = "path", required = true)
  protected List<String> path;
}

相关架构部分:

  <xs:element name="attribute">
    <xs:complexType>
      <xs:attributeGroup ref="c:absoluteElementPathOrAbsoluteOrRelativeAttributePathWithPredicate"/
    </xs:complexType>
  </xs:element>

  <xs:attributeGroup name="absoluteElementPathOrAbsoluteOrRelativeAttributePathWithPredicate">
    <xs:attribute name="path" use="required" type="c:absoluteElementPathOrAbsoluteOrRelativeAttributePathWithPredicateType"/>
  </xs:attributeGroup>

  <xs:simpleType name="absoluteElementPathOrAbsoluteOrRelativeAttributePathWithPredicateType">
    <xs:union memberTypes="c:absoluteElementPathWithPredicateType c:absoluteOrRelativeAttributePathWithPredicateType"/>
  </xs:simpleType>

  <xs:simpleType name="absoluteElementPathWithPredicateType">
    <xs:restriction base="xs:string">
      <xs:pattern value="/|(//?[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?(\[@[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?\s*(eq|ne|=)\s*'[^']*'\])?)+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="absoluteOrRelativeAttributePathWithPredicateType">
    <xs:union memberTypes="c:absoluteAttributePathWithPredicateType c:relativeAttributeNameType"/>
  </xs:simpleType>


  <xs:simpleType name="absoluteAttributePathWithPredicateType">
    <xs:restriction base="xs:string">
      <xs:pattern value="/|(//?[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?(\[@[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?\s*(eq|ne|=)\s*'[^']*'\])?)+\/@[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="relativeAttributeNameType">
    <xs:restriction base="xs:string">
      <xs:pattern value="@[0-9a-zA-Z]+(:[0-9a-zA-Z]+)?"/>
    </xs:restriction>
  </xs:simpleType>

据我所知,在同一个XML元素上不可能有多个同名的XML属性,因此任何生成的@XMLAttribute Java代码应始终为String并且不是List<String>

有人可以确认我似乎遇到了XJC中的错误吗? 也有人知道在哪里报告XJC中的错误吗?

0 个答案:

没有答案
相关问题