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: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to