axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathaniel Auvil" <nathaniel.au...@gmail.com>
Subject [1.2.1] Xmlbeans Performance Boost
Date Fri, 24 Feb 2006 20:20:21 GMT
Hi. I have added a major performance improvement to the XMLBeanSerializer
Class that has made its way around the lists.  We saw the performance for
large documents (>7MB) drop from 106 seconds to 8 seconds!  With smaller
improvements for smaller documents.  Here is the updated Serialize method:


    public void serialize( QName name, Attributes attributes, Object value,
SerializationContext context ) throws IOException
    {
        if( !(value instanceof XmlObject) )
        {
            throw new IOException( ((value != null) ?
value.getClass().getName()
: "null") + " is not an " + XmlObject.class.getName() );
        }
        else
        {
            context.setWriteXMLType( null );


            XmlObject xmlObject= (XmlObject) value;

            XmlOptions xmlOptions= new XmlOptions();
            xmlOptions.setSaveSyntheticDocumentElement( name );
            context.writeString( xmlObject.xmlText( xmlOptions ) );


            /**************
            //---this is SLLLLOOOOWWWWW on very large xml documents

                context.startElement( name, attributes );

                XmlCursor xCur = ((XmlObject) value).newCursor();
                if( xCur.toFirstContentToken() == XmlCursor.TokenType.START)
                {
                    do
                    {
                        Node n = xCur.getDomNode();
                        if( n.getNodeType() == Node.ELEMENT_NODE )
                        {
                            context.writeDOMElement( (Element) n );
                        }
                    }
                    while( xCur.toNextSibling() );
                }
                context.endElement ();

            **************/
        }
    }

Mime
View raw message