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 help - marshaling of complex type that holds sequence of hexBinaries

843834Apr 16 2009 — edited Apr 30 2009
Hi,

I need help with marshaling of the following XML structure:
I have an XSD file that contains the following structure:
    ...
    <xs:element name="UAListStruct">
	<xs:complexType>
	       <xs:sequence>
		<xs:element name="UA" type="cmsi-commun:UAType" minOccurs="0" maxOccurs="unbounded"/>
	       </xs:sequence>
	</xs:complexType>				
     </xs:element>
     ...
Where the definition of UAType is:

<xs:simpleType name="UAType">
		<xs:restriction base="xs:hexBinary">
			<xs:length value="5"/>
		</xs:restriction>
	</xs:simpleType>
The corresponding Java class member that is being generated for this code is:
@XmlElementRef(name = "UA", namespace = "http://www.viaccess.com/tdr/cmsi/xml/emulator", type = JAXBElement.class)
        protected List<JAXBElement<byte[]>> ua;
Now, the problem that I encounter is that marshalling of the generated object, writes the value as xs:base64Binary and not as xs:hexBinary.

Note: I tried to generate a similiar structure in which the base of UAType was xs:base64Binary (instead of xs:hexBinary) and the class member that has being generated was not a list of JAXBElements but rather a simple list of bytes[]. I guess it has to do with some default.

One last comment - I have not so few occurecnces of structures like UAListStruct that contains sequences of complex types that hold hexBinary (like UAType above) so I would rather use a generic solution rather that changing something specific in each JAXC generated file (but if there is no other solution - I would be happy to hear about the specific solution).

I would appriciate your kind assistance.

Thanks
Carmel
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2009
Added on Apr 16 2009
8 comments
374 views