2010-10-22 75 views
0

我們試圖解析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"> 
    <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) 
     ...... 

回答

1

我在某處讀取傳遞給XmlBeans.compileXsd的對象需要成爲SchemmaDocument的實例。所以試試這個:SchemaDocument.Factory.parse而不是XmlObject.Factory.parse