开发者

JAXB does not throw an Error on wrong dateTime values

开发者 https://www.devze.com 2023-03-29 20:58 出处:网络
I have an XML schema, where element Calling1 is 开发者_Go百科defined like this: <xsd:element name=\"Calling1\" type=\"xsd:dateTime\">

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

精彩评论

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

关注公众号