I use JAXB in eclipse Luna to generate Java classes from a third party XSD file. This file often defines a simple type which is just a primitive type. For instance:

<xsd:simpleType name="ChannelIdType">
  <xsd:restriction base="xsd:unsignedInt" />
</xsd:simpleType>

The simple type is then used for elements of a complex type, for instance:

<xsd:complexType name="DataRequestEntryType">
  <xsd:sequence>
    <xsd:element name="ChannelId" type="ChannelIdType" />
    <xsd:element name="IsChannelOpen" type="xsd:boolean" />
    ...
  </xsd:sequence>
</xsd:complexType>

JAXB generates a Java class for the complex type that seems perfectly correct:

public class DataChannelEntryType {
  @XmlElement(name = "ChannelId")      <-- ERROR here, see below
  protected long channelId;
  @XmlElement(name = "IsChannelOpen")
  protected boolean isChannelOpen;
  ...
}

But, it also generates the following JAXB ERROR for the line @XmlElement(name = "ChannelId")

The expected XML type associated with 'long' is not valid for XML element 'ChannelId'.

Does anybody know what that error message means? I cannot change the XSD file, but what should one do to remove the error (short of removing the simple class, which anyway seems quite legal)? Or at least suppress the generation of the error?

Any help will be greatly appreciated!

没有正确的解决方案

其他提示

Try disabled JAXB Validator.

Project -> Properties -> Validation -> Jaxb Validator

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top