That works great. Thanks.
I am getting about 30% reduction in size. I can get another 30% (total
~60%) if I compress the byte[] afterwards.
I know this is highly object dependent, but does these 2 steps sound like
the smallest I can make an object?
Thanks.
Tim Watts-3 wrote:
>
> For serializing, looks like you could use a SAX approach with the
> XmlBean's save(ContentHandler,LexicalHandler) method:
>
> OutputStream out = ...
> SAXDocumentSerializer saxOut = new SAXDocumentSerializer();
> saxOut.setOutputStream(out);
> myXmlBeanDocument.save(saxOut, saxOut); // both args ???
> out.close();
>
> Haven't actually tried this so I don't know if it will work (or even
> compile). But it seems like a reasonable approach based on the FI
> samples and the fact that there isn't a save(XMLStreamWriter) method.
>
> What you outlined for unserializing seems reasonable.
>
> HTH
>
>
> On Sat, 2010-09-11 at 20:28 -0700, sub3 wrote:
>> Hi,
>> I am trying to save my XmlBeans objects and I need to use the smallest
>> amount of disk space possible. I believe that the Fast Infoset will give
>> me
>> that. Please correct me if I am wrong.
>>
>> Does anyone have any example code to implement this? I tried using the
>> example code on the Fast Infoset site, but I am not sure how it interacts
>> with the XmlBeans.
>>
>> I've tried to serialize by :
>> ByteArrayOutputStream fiDocument = new ByteArrayOutputStream();
>> StAXDocumentSerializer staxDocumentSerializer = new
>> StAXDocumentSerializer();
>> staxDocumentSerializer.setOutputStream(fiDocument);
>>
>> XMLStreamWriter streamWriter = staxDocumentSerializer;
>> // Write out some simple infoset
>> streamWriter.writeStartDocument();
>> //streamWriter.writeStartElement("foo");
>> //streamWriter.writeCharacters("bar");
>> streamWriter.writeEndElement();
>> streamWriter.writeEndDocument();
>> streamWriter.close();
>> return fiDocument.toByteArray();
>>
>> I don't really understand the start/character functions, but even without
>> that, I am still not getting any data saved.
>>
>> Assuming the above is a simple fix, would this unserialize the object:
>> InputStream fiDocument = new ByteArrayInputStream(bytes);
>> XMLStreamReader streamReader = new StAXDocumentParser(fiDocument);
>> return AckDocument.Factory.parse(streamReader);
>>
>> Thanks for any help.
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://old.nabble.com/Fast-Infoset-tp29688572p29690719.html
Sent from the Xml Beans - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]