users@jaxb.java.net

Re: unmarshal/marshal discrepancy with attribute

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Tue, 11 Feb 2003 15:16:17 -0500

Mike Storey wrote:
> On Wed, 8 Jan 2003 12:03:55 -0800, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM> wrote:
>
>
>>The bug of RI in this case is its inability to reject this schema. I
>>checked it with my current working version and made sure that it reports
>>an error.
>>
>>Now the correct fix to this problem is to add a customization that
>>changes the property name.
>>
>><xs:complexType name="BIND-experimental-system1">
>> <xs:simpleContent>
>> <xs:extension base="xs:integer">
>> <xs:attribute name="value">
>> <xs:appinfo><xs:annotation>
>> <jaxb:property name="category"/>
>> </xs:annotation></xs:appinfo>
>> ...
>>
>>
>>regards,
>>--
>>Kohsuke KAWAGUCHI 408-276-7063 (x17063)
>>Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
> Is it possible to customise the property name for the content rather than customising the property name of the "value" attribute?

Add a jaxb:property customization right after the <xs:complexType>.
I must caution you that this might not work in beta since the placement
and implementation of some
customizations were not completely nailed down till after beta.

Against the soon to be released JAXB RI v1.0, the following customization worked.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
               jaxb:version="1.0"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
              xmlns="http://www.example.com/user"
              targetNamespace="http://www.example.com/user">
<xs:complexType name="BIND-experimental-system1">
   <xs:annotation><xs:appinfo>
      <jaxb:property name="TextContent"/>
   </xs:appinfo></xs:annotation>
   <xs:simpleContent>
     <xs:extension base="xs:integer">
       <xs:attribute name="value" type="xs:string"/>
     </xs:extension>
   </xs:simpleContent>
</xs:complexType>
<xs:element name="test" type="BIND-experimental-system1"/>
</xs:schema>

Generating:

public interface BINDExperimentalSystem1 {
     java.math.BigInteger getTextContent()
     void setTextContent(java.math.BigInteger value);
     java.lang.String getValue();
     void setValue(java.lang.String value);
}

-Joe Fialli, Sun Microsystems

>
> Cheers
>
> Mike Storey
> Lead Developer, Kizoom Ltd


--