users@jaxb.java.net

Re: serialized data in xml file

From: Mark Brouwer <mark.brouwer_at_virgil.nl>
Date: Sat, 22 Mar 2003 18:00:51 +0100

Filip Rindler wrote:
>
> exception. Is there a way to save this serial data string into an XML file
> in a simple way? Actually, the system seems to convert some of characters in
> the stream as I find things like "&#165;" in the serial data saved into my
> XML file.
>
> Thanks for your help!
>
> Fil

This can be done with W3C Schema by using the type base64Binary. Pass in
a byte array and all the work is being done for you. Below an example of
how we store a MarshalledObject in XML:

<xsd:complexType name="entry">
    <xsd:annotation>
        <xsd:documentation>
Specifies a serialized entry.

The entry is a MarshalledObject that has
been serialized as a Base64 byte stream.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:simpleContent>
        <xsd:extension base="xsd:base64Binary">
            <xsd:attribute name="name" type="xsd:NCName">
                <xsd:annotation>
                    <xsd:documentation>
            Identifier for entry, can be useful in case
            of exception when unmarshalling the entry.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
        </xsd:extension>
    </xsd:simpleContent>
</xsd:complexType>
--
Mark Brouwer