Tuesday, May 4, 2010

XMLBeans, I can be so stupid...

while doing this

XmlObject xmlObject = XmlObject.Factory.parse("emp.xsd");

I am getting this

Exception in thread "Main Thread" org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3486)
    at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:712)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:696)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:683)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:208)
    at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:580)
    at com.acme.xquerygenerator.XSDParser.main(XSDParser.java:8)
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)
    ... 6 more

and, of course, the answer is that I should do this:

XmlObject xmlObject = XmlObject.Factory.parse(new File("emp.xsd"));

I am simply too stupid to survive.

1 comment:

jg said...

Thanks, this was actually very helpful!