users@jaxb.java.net

Issues with arbitrary transformation of boolean to String

From: Ioannis Mavroukakis <imavroukakis_at_gameaccount.com>
Date: Wed, 23 Sep 2009 15:51:12 +0100

Hello fellow listers,

I've got the following conundrum I'd like some help with.

Assume this schema (shortened for brevity)

   <xs:element name="Foo">
         <xs:complexType>
             <xs:complexContent>
                     <xs:attribute name="bar" type="xs:string"/>
             </xs:complexContent>
         </xs:complexType>
  </xs:element>

In reality, bar is a boolean attribute (stay with me) which I need for
business reasons to convert to a single character lexical
equivalent of true/false in another language, for transport over a
WSDL call.

I thought that I could perhaps use a custom binding to do my biding
and extend that for different use cases hence

<bindings node="/xsd:schema/xsd:element[@name='Foo']/xsd:complexType/
xsd:complexContent/xsd:attribute[@name='bar']">
             <property>
                 <baseType>
                     <javaType name="java.lang.String"
                      
parseMethod="com.transform.PartnerTransform.parseBooleanToString"
                      
printMethod="com.transform.PartnerTransform.printStringToBoolean" />
                 </baseType>
             </property>
         </bindings>

However I quickly realised that my cunning plan to assign another
XMLAdapter while initialising the marshaller for each use case was
blown out of the water
as the adapter is randomly named by xjc, and touching the generated
classes is a no-no.

Therefore, the grand question here is , is there some arcane way to
make jaxb do that, or should I be looking at a different solution?

Thanks!

Yiannis