users@jaxb.java.net

Re: White Space Elimination Problem

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Sun, 12 Jan 2003 07:14:18 -0800

> <xsd:element name="surname">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <xsd:whiteSpace value="collapse"/>
> <xsd:minLength value="1"/>
> <xsd:maxLength value="255"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:element>

"xs:string" datatype doesn't do whitespace normalization (that's the
jargon that roughly corresponds to "String.trim"). So to enforce what
you want, it seems like you should be using "xs:token"

This will consider " abc " to be "abc", and " xyz abc " to be
"xyz abc" (note that any sequence of whitespaces in the middle of a
string is also collapsed into one WS)


> If white space processing appears to work okay (if my element contains
> 255 characters with lots of trailing and leading whitespace it doesn't
> complain)

The unmarshaller don't perform strict validation unless you tell it to
do so. So it seems to me that what you are seeing is the forgiving
behavior of the unmarshaller.



regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com