users@jaxb.java.net

Re: Datatype conversion problem

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 06 Jun 2003 10:03:13 -0700

Marcus Walls <marcus.walls_at_ASPECTIVE.COM> wrote:
> Is this a necessary price for what I'm trying to achieve?
> i.e. is there any way of performing the datatype conversions
> before the validation occurs?

Since doing a length check sounds simple enough to me, I took that to
mean you are asking the question mainly to find out the "right" way to
do it.

I think you are doing the right thing. What you are doing is to
introduce an application-specific processing semantics on top of XML
Schema datatype (because what you are doing is not achievable with XML
Schema)



> I was thinking of perhaps pre-processing the XML and doing
> my trimming before passing it to JAXB, but alas the description
> of which fields need to be trimmed is contained within the
> schema and my pre-processing code wouldn't know which fields
> to trim!

Usually, you can find out what needs to be trimmed just from the
neighbor element names. So this approach will still work for most of
people. But sounds like you are not so lucky...


> Anyone got any bright ideas?

If you have more complicated custom validation needs, check if Sun's XSDLib
work for you. You can build a datatype anyway you want, and have it
validate any java.lang.String.

So you can easily trim a string, then use XSDLib to check if it
satisfies certain constraints.


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