You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Ole Lensmar <ol...@eviware.com> on 2009/07/01 11:11:50 UTC

xmlbeans chokes on invalid xml

Hi!

I have the following (invalid) xml:

 

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Fault
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Code
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Value
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">soapenv:Receiver</so
apenv:Value></soapenv:Code><soapenv:Reason
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Text
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns="http://www.w3.org/XML/1998/namespace" xml:lang="en-US">For input
string: "1XXXXBAD"</soapenv:Text></soapenv:Reason><soapenv:Detail
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"></soapenv:Detail></s
oapenv:Fault></soapenv:Body></soapenv:Envelope>

 

(there is an invalid xmlns="http://www.w3.org/XML/1998/namespace" in there).

 

When trying to parse this xmlbeans does ok, but when doing xmlText() on the
created XmlObject it goes into an endless loop somehow.. 

 

A JUnit TestCase that hangs is as follows:

 

package com.eviware.soapui.support.xml;

 

import junit.framework.TestCase;

 

import org.apache.xmlbeans.XmlObject;

 

public class XmlBeansTestCase extends TestCase

{

       public void testXml() throws Exception

       {

              String xml = "<?xml version='1.0'
encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +

                           "<soapenv:Body
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +

                           "<soapenv:Fault
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +

                           "<soapenv:Code
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +

                           "<soapenv:Value
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">soapenv:Receiver</
soapenv:Value>" +

                           "</soapenv:Code><soapenv:Reason
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +

                           "<soapenv:Text
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"
xmlns=\"http://www.w3.org/XML/1998/namespace\" " +

                           "xml:lang=\"en-US\">For input string:
\"1XXXXBAD\"</soapenv:Text></soapenv:Reason>" +

                           "<soapenv:Detail
xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"></soapenv:Detail>"
+

 
"</soapenv:Fault></soapenv:Body></soapenv:Envelope>";

              

              XmlObject xmlObject = XmlObject.Factory.parse( xml );

              xmlObject.xmlText();

       }

}

 

(confirmed in 2.4.0 and HEAD)

 

Although the XML is invalid, it would be nice if there was either an
exception thrown or something else that doesn't choke the program.. 

 

Or am I misunderstanding something!?

 

Thanks for any help!

 

Regards,

 

/Ole

Eviware.com

 


eviware 

 Ole Lensmar
 ole@eviware.com <ma...@eviware.com> 
 tel: +46 (0)703 555 000
 fax: +46 (0)8 790 61 19