2014-10-16 38 views
2

我試圖讓hyperjaxb處理一個真正的模式。我下載並解壓縮了hyperjaxb maven項目from this link,然後使用cmd.exe導航到根目錄,並通過運行mvn clean install以確保它與示例模式一起使用示例數據對其進行測試。然後,我用一個精簡版的實際shematics替換schema.xsd,po.xmlbindings.xjb文件,以便我可以準備通過上述鏈接的hyperjaxb項目運行真實應用程序。然後我再次運行mvn clean install。從替換bindings.xjb文件,您可以使用schema.xsd文件at this linkpo.xml,你可以閱讀at this link閱讀at this link. 「xs:complexType [@ name ='Any']」的XPath評估會導致空的目標節點

[ERROR] Error while parsing schema(s).Location 
[ file:/C:/path/to/src/main/resources/bindings.xjb{25,53}]. 
com.sun.istack.SAXParseException2; systemId: 
file:/C:/path/to/src/main/resources/bindings.xjb; lineNumber: 25; columnNumber: 53; 
XPath evaluation of "xs:complexType[@name='Any']" results in empty target node 

:不過,我收到以下錯誤消息。

bindings.xjb的相關部分是:

<jaxb:bindings node="xs:complexType[@name='Any']"> 
    <hj:entity> 
     <orm:table name="any"/> 
    </hj:entity> 
</jaxb:bindings> 

在schema.xsd的ANY複雜類型的定義是:

<xs:complexType name="ANY"><!-- abstract="true">--> 
    <xs:annotation> 
    <xs:documentation> 
     Some documentation. 
    </xs:documentation> 
    </xs:annotation> 
    <xs:attribute name="nullFlavor" type="NullFlavor" use="optional"> 
    <xs:annotation> 
     <xs:documentation> 
      Some other documentation. 
     </xs:documentation> 
    </xs:annotation> 
    </xs:attribute> 
</xs:complexType> 

注意,完整的代碼在上面的鏈接。 我該如何解決這個錯誤?

回答

2

你應該使用下面的配置..

<jaxb:bindings node="//xs:complexType[@name='ANY']"> 
    <hj:entity> 
     <orm:table name="any"/> 
    </hj:entity> 
</jaxb:bindings> 

一個例子,你可以在我這一個話題的答案找到。 https://stackoverflow.com/a/24953369/3364187


我想你的項目,這樣的配置能正常工作。讓我知道如果在你的環境中工作。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<jaxb:bindings 
    version="2.1" 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations" 
    xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" 
    jaxb:extensionBindingPrefixes="hj orm"> 

    <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema"> 
     <jaxb:globalBindings generateIsSetMethod="true"/> 
     <jaxb:schemaBindings> 
      <jaxb:package name="org.jvnet.hyperjaxb3.ejb.tests.pocustomized"/> 
     </jaxb:schemaBindings> 
     <jaxb:bindings node="//xs:complexType[@name='InfrastructureRoot.typeId']"> 
      <hj:entity> 
       <orm:table name="typeId"/> 
      </hj:entity> 
     </jaxb:bindings> 
     <jaxb:bindings node="//xs:complexType[@name='II']"> 
      <hj:entity> 
       <orm:table name="II"/> 
      </hj:entity> 
     </jaxb:bindings> 
     <jaxb:bindings node="//xs:complexType[@name='ANY']"> 
      <hj:entity> 
       <orm:table name="any"/> 
      </hj:entity> 
     </jaxb:bindings> 
    </jaxb:bindings> 


</jaxb:bindings> 

總之每個節點失蹤//

從匹配 選擇當前節點在文檔中選擇節點,無論他們在哪裏

和複雜類型不是「任何」而是「任意」,那麼正確的節點是@name='ANY'

+0

非常感謝您對此進行調查。我剛剛嘗試了您的更改,但它導致了相同的確切錯誤。還有什麼可能導致這種情況? – CodeMed 2014-10-16 17:34:15

+0

你可以添加更多的XSD細節嗎? – Xstian 2014-10-16 17:35:25

+1

我發佈了整個xsd文件以及所有其他相關文件,以完全重現上面我原始發佈的鏈接中的問題。該xsd文件是259行,所以我不想污染整個發佈。但是有人可以在幾分鐘內使用上述所有鏈接在本地機器上重現問題。 – CodeMed 2014-10-16 17:37:12