1

我们正在尝试解析 XSD 并从中构建一个属性表(使用 XML Beans)。

代码如下:

   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">
    <复杂内容>
    ...
    ...

堆栈跟踪:

第 0 个提供的输入不是模式文档:它的类型是 N=
    在 org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:211)
    在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    在 java.lang.reflect.Method.invoke(Method.java:597)
    在 org.apache.xmlbeans.XmlBeans.compileXmlBeans(XmlBeans.java:667)
    在 org.apache.xmlbeans.XmlBeans.compileXsd(XmlBeans.java:553)
        ……
4

1 回答 1

2

我在某处读到传递给 XmlBeans.compileXsd 的对象需要是 SchemaDocument 的实例。所以试试这个:SchemaDocument.Factory.parse 而不是XmlObject.Factory.parse

于 2011-06-06T19:41:44.917 回答