users@jaxb.java.net

Re: Does jaxb 2.1 enforce xs:restriction

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 8 Jan 2009 11:53:46 +0100

JAXB doesn't generate any code for checking ranges and similar schema
facets.

You might consider passing the XML schema to your marhaller or unmarshaller
to achieve the more meticulous schema validation.

-W

On Thu, Jan 8, 2009 at 10:29 AM, chamibuddhika <chamibuddhika_at_gmail.com>wrote:

>
> Hi,
>
> I've got a schema with following element.
>
> <xs:element name="Amount">
> <xs:simpleType>
> <xs:restriction base="xs:int">
> <xs:minExclusive
> value="1"></xs:minExclusive>
> <xs:maxExclusive
> value="1000000"></xs:maxExclusive>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
>
> In the generated java class the setter method does not enforce the
> restriction when setting a value to the amount variable allowing any value
> to be assigned to Amount.
>
> public void setAmount(int value) {
> this.amount = value;
> }
>
> I'm programmatically generating source files from SchemaCompiler class and
> using jaxb 2.1. I'm new to JAXB and may be missing some obvious point. Can
> anybody please explain how this restriction can be enforced. I've attached
> the generated source file for reference as well.
> http://www.nabble.com/file/p21348458/LoanServiceRequest.java
> LoanServiceRequest.java
>
> Thanks in advance.
> --
> View this message in context:
> http://www.nabble.com/Does-jaxb-2.1-enforce-xs%3Arestriction-tp21348458p21348458.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>