You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by Oliver Tonnhofer <to...@lat-lon.de> on 2008/09/18 14:44:10 UTC

No exceptions for invalid XML (WSCOMMONS-111, WSCOMMONS-323)

Hi,

is there any progress on
https://issues.apache.org/jira/browse/WSCOMMONS-111
or
https://issues.apache.org/jira/browse/WSCOMMONS-323

Both are still open and the first one is nearly two years old. The
outcome of this bug is, that axiom will parse invalid XML without
throwing an exception. All elements after the first invalid one are just
missing from the result tree.

I think that it's a serious issue and it's unfortunate that no one
commented on that.

Below is a small example that will parse the invalid xml snippet.

Regards,
Oliver

=============
import java.io.StringReader;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.apache.axiom.om.impl.builder.StAXOMBuilder;


public class WSCommons323 {

        public static void main( String[] args )
                            throws XMLStreamException {
        String xml =
"<a><d>valid</d><bar:b>invalid</bar:b><c>valid</c></a>";
        StringReader input = new StringReader( xml );
        XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader( input );
        StAXOMBuilder builder = new StAXOMBuilder( reader );
        // will output '<a><d>valid</d></a>'
        System.out.println( builder.getDocumentElement() );
    }
}