users@jaxb-verification.java.net

Custom Data Type Support

From: Marcus Walls <Marcus.Walls_at_ASPECTIVE.com>
Date: Mon, 13 Mar 2006 18:24:24 -0000

Hi there,

I have been using jaxb-verification extensively in my internal projects
and it's revolutionised our error reporting, so firstly a big thank-you.

Now, I'm considering introducing it into a customer project but have
come across a limitation which I want to understand a bit more before
deciding what to do.

My customer wants the contents of the XML elements to be trimmed (i.e.
leading and trailing white removed). The schema whitespace support
isn't good enough for me, because I don't want multiple spaces within
the string to be reduced to a single space. Thus, I have created a
custom datatype, as follows:

  <xsd:simpleType name="MyString">
    <xsd:annotation>
      <xsd:appinfo>
        <jxb:javaType name="java.lang.String"
 
parseMethod="mypackage.DataTypeHandler.parseString"
 
printMethod="mypackage.DataTypeHandler.printString"/>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:restriction base="xsd:string"/>
  </xsd:simpleType>

And this appears to work fine as far as trimming the data is concerned.
However, jaxb-verification doesn't appear to support the custom type and
adds a comment to say so:

   java.lang.String realValue = ((java.lang.String) value);
   // Check primitive value
   // Custom type conversion is defined, no check is possible

What I'd like it to do, is:

   java.lang.String realValue =
((java.lang.String)mypackage.DataTypeHandler.parseString(value));
   // Check primitive value
   {
      // Perform the check
      // Checking class com.sun.msv.datatype.xsd.MaxLengthFacet datatype
      de.fzi.dbs.verification.event.datatype.ValueProblem problem =
null;
      if (((null == realValue)? 0 :realValue.length())>= 1) {
        // Value length is correct
                [...]


Is this in anyway possible, or am I asking for something really silly
that's just impossible?

Many thanks for you help.

Marcus