Hm, this is strange indeed. Maybe a parser bug? You can use XmlOptions to 
change the parser that XmlBeans uses, you should try that.
 
Radu


________________________________

        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
        Sent: Monday, October 20, 2008 7:12 AM
        To: [email protected]
        Subject: XmlObject.Factory.parse throws "Unexpected element: CDATA"
        
        

        Hi All! 
        
        I have one XML file which gives me trouble. 
        The XML is really simple - just root element, subelement and a lot of 
spaces around. 
        I have to attach the file since adding or removing just one character 
in it makes it parsable again (very strange). 
        I really hope that somebody can help me to figure out what is the 
problem with this particular XML (attached). 
        
        Environment: 
                Java 1.5.0_11, XmlBeans 2.4.0 
        
        Java code (works fine with other XML files): 
                XmlObject xml = XmlObject.Factory.parse(new 
File("d:/Laurens/__d3configserver.xml")); 
        
        Throws: 
        
        org.apache.xmlbeans.XmlException: 
d:\Laurens\__d3configserver.xml:457:1: error: Unexpected element: CDATA 
                at 
org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3486) 
                at 
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1276) 
                at 
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1263) 
                at 
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
 
                at 
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:252)
 
                at 
org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:639) 
                at 
com.agfa.apomedia.translation.UtilsTest.testGetTranslatedFile(UtilsTest.java:122)
 
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
                at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
                at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 
                at java.lang.reflect.Method.invoke(Method.java:585) 
                at junit.framework.TestCase.runTest(TestCase.java:154) 
                at 
org.jmock.integration.junit3.VerifyingTestCase.runBare(VerifyingTestCase.java:37)
 
                at junit.framework.TestResult$1.protect(TestResult.java:106) 
                at junit.framework.TestResult.runProtected(TestResult.java:124) 
                at junit.framework.TestResult.run(TestResult.java:109) 
                at junit.framework.TestCase.run(TestCase.java:118) 
                at junit.framework.TestSuite.runTest(TestSuite.java:208) 
                at junit.framework.TestSuite.run(TestSuite.java:203) 
                at 
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
 
                at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 
                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 
                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 
                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
 
        Caused by: org.xml.sax.SAXParseException: Unexpected element: CDATA 
                at 
org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(Piccolo.java:1038)
 
                at 
org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:723) 
                at 
org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3454) 
                ... 24 more 
        
        Thanks, Alex 
        
        

Reply via email to