我们正在尝试解析XSD并从中构建属性表(使用XML Bean)。
代码如下:
XmlObject xmlObj = XmlObject.Factory.parse( schema ); sts = XmlBeans.compileXsd(new XmlObject[] { xmlObj }, XmlBeans.getBuiltinTypeSystem(), null);
调用compileXsd会抛出一个带有消息的异常:第0个提供的输入不是架构文档:它的类型是N =
我们的架构如下所示:
<schema xmlns:com.co.workflow="com.co.workflow" xmlns:org.data="org.data" targetNamespace="org.activity" version="1.0"> <complexType class="org.activity.ExecuteCommand" name="executeCommand"> <complexContent> ... ...
堆栈追踪:
The 0th supplied input is not a schema document: its type is N= at org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:211) 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:597) at org.apache.xmlbeans.XmlBeans.compileXmlBeans(XmlBeans.java:667) at org.apache.xmlbeans.XmlBeans.compileXsd(XmlBeans.java:553) ......
答案 0 :(得分:1)
我在某处读到传递给XmlBeans.compileXsd的对象需要是SchemmaDocument的实例。所以试试这个:SchemaDocument.Factory.parse
而不是XmlObject.Factory.parse