Question

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!

No correct solution

OTHER TIPS

Try disabled JAXB Validator.

Project -> Properties -> Validation -> Jaxb Validator

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top