Hi,
Per a
JAXB Wiki, the
positiveInteger XSD datatype maps to
Java's BigInteger datatype.
I am trying out different data types (allowed in XML Schemas) to see the generated code. And I am using xjc from NetBeans to generate Java code for the schema.
And for this element:
xjc generates this code:
Now I started questioning this because for a positive integer, I was thinking that the generated code would actually check that the integer is positive, and if not, then I was expecting that it would throw an exception.
So I went ahead and ran a simple client, and observed these results:
a) When I put in a negative value in the XML data file and unmarshal it, it works without throwing an exception (which I was expecting)
b) When I add a negative value and marshal it to XML, there is still no exception.
Now:
1. The XML Schema specification clearly states that "The ·value space· of positiveInteger is the infinite set {1,2,...}"
However:
2. The xjc-generated code does not check whether the number is positive, and
3. Neither does the marshalling and unmarshalling infrastructure in javax.xml.bind check for the sign
Question: So what is going on? Is this how it is supposed to work or am I missing some important step or configuration setting or xjc option in the process?
Thanks in advance for your help!
Srini