Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB error on empty elements

843834Oct 29 2003 — edited Apr 23 2004
I have a problem when I get empty elements (like <SomeElement/>) for elements of my type "character".

The essential parts of my schema:
<xs:element name="SomeElement" type="character"/>

<xs:simpleType name="character">
<xs:annotation>
<xs:appinfo>
<jxb:javaType name="java.lang.Character" parseMethod="com.test.jaxb.MyDatatypeConverter.parseCharacter" printMethod="com.test.jaxb.MyDatatypeConverter.printCharacter"/>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
</xs:restriction>
</xs:simpleType>

This works with an xml file element like <SomeElement>X</SomeElement>

When the xml file elemnt is like <SomeElement/>, I get a UnmarshallException:
parse event[1] severity=ERROR line#, Position (19, 14) message=Unexpected text ""
parse event[2] severity=FATAL_ERROR line#, Position (19, 14) message=Unexpected end of element {}:Standard") nested exception is
javax.xml.bind.UnmarshalException("Unexpected end of element {}:Standard")

If I change my schema to: <xs:element name="SomeElement" type="xs:string"/>, <SomeElement/> do not give an Exception.

Since my "character" type is only a restriction of xs:string, I thought this would work.

Do someone know how I can change my schema to get this to work, without having xml-file elements as <SomeElement xsi:nil="true"/>?

Hakon
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2004
Added on Oct 29 2003
2 comments
267 views