5

I have an XML schema, where element Calling1 is 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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.