开发者

JAXB does not throw an Error on wrong dateTime values

I have an XML schema, where element Calling1 is 开发者_Go百科defined like this:

<xsd:element name="Calling1" type="xsd:dateTime">

I have generated Jaxb bindings :

 <xjc extension="true" schema="${basedir}/message.xsd"
  destdir="${basedir}/src" package="org.test"/>

I am using JAXB to unmarshal XML documents to Java representation. If my XML cantains element Calling1, which value is not a correct dateTime, for example

<Calling1>NOT_A_DATETIME</Calling1>

JAXB does not throw any error, but returns me an java object, which property calling1 is null.

Why i get null, and not an Error? How can i change that Jaxb behaviour?


Have you set the schema on your Unmarshaller by calling setSchema ? You will need to specify the xsd file as well as the Schema NS URI for validation to take place

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜