Re: Fast Infoset
Dennis Sosnoski <[email protected]> Mon, 13 Sep 2010 11:36:57 +1200
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <[email protected]> |
You'll probably get a better size reduction by just compressing the text
XML. Binary XML representations can be faster to process and smaller
than text XML, but they don't compress nearly as well.
- Dennis
Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
On 09/13/2010 05:08 AM, sub3 wrote:
> 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]
>>
>>
>>
>>
>