users@jaxb.java.net

Re: White Space Elimination Problem

From: Marcus Walls <marcus.walls_at_ASPECTIVE.COM>
Date: Tue, 14 Jan 2003 11:51:26 -0700

> See the specification about <javaType parseMethod="..."
> printMethod="..."/> for details of this feature.

I have looked at the spec and when I attempted to do this I got
an unexpected attribute "parseMethod" error. Furthermore, I
can't find the javax.xml.bind.DatatypeConverter classes referred
to in the spec - are these not implemented yet, or am I doing
something silly?

However, I did succeed in creating an object with a constructor
and a toString() method, and this successfully compiled.

Alas, the framework appears to collapse the whitespace before
calling my class to do its parsing: i.e. the schema below

  <xsd:annotation>
    <xsd:appinfo>
      <jxb:globalBindings>
        <jxb:javaType name="com.aspective.common.jaxb.TrimmedString"
                      xmlType="xsd:string">
        </jxb:javaType>
      </jxb:globalBindings>
    </xsd:appinfo>
  </xsd:annotation>

produces unmarshalling code that looks like:

   _Field = new com.aspective.common.jaxb.TrimmedString(
     com.sun.xml.bind.WhiteSpaceProcessor.collapse(value));

Is this correct? Hopefully not as it rather defeats my purpose!

Even without this pre-processing of "value" I would prefer to
implement static methods rather than have a new custom object
created everytime a value is marshalled/unmarshalled.

Are there any samples available that do data-type conversion?

Thanks for your help

Marcus