2014-03-31 19 views
5

如果我沒有使用Googled進入遺忘,我不會在這裏。我有以下問題: 我有一個XML架構,3個單獨的XML文檔和一個XML文檔來鏈接所有其他3.我遇到了以下錯誤,我不明白爲什麼。嘗試使用Xinclude屬性xml連接XML文件:基本錯誤

E [Xerces] cvc-complex-type.3.2.2:屬性'xml:base'不允許出現在元素'SoftwareRequirementsDocument'中。

我已經閱讀了一堆來自谷歌的論壇帖子,與類似的問題的人,但他們的修復程序都不會幫助我。我將發佈我的Schema,要連接的1個XML文檔以及帶有XInclude的XML文檔。我將在每個文檔的開始處張貼需要的文檔。

這裏是NotionalSchema2.xsd:

<xsd:element name="ProjectLifecycleDocuments" type="ProjectLifecycleDocumentsType"/> 
<xsd:complexType name="ProjectLifecycleDocumentsType"> 
    <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
     <xsd:element ref="Team"/> 
     <xsd:element ref="SoftwareRequirementsDocument"/> 
     <xsd:element ref="UseCaseDocument"/> 
     <xsd:element ref="TestCaseDocument"/> 
    </xsd:choice> 
    <xsd:attribute name="id" use="required" type="xsd:ID"/> 
</xsd:complexType> 

<xsd:element name="SoftwareRequirementsDocument" type="SoftwareRequirementsDocumentType"/> 
<xsd:complexType name="SoftwareRequirementsDocumentType"> 
    <xsd:sequence> 
     <xsd:element ref="Section" maxOccurs="unbounded"/> 

     <!-- Other global elements to be referenced here. --> 
    </xsd:sequence> 
    <xsd:attribute name="projectName" use="required" type="xsd:string"/> 
    <!--<xsd:attribute name="id" use="required" type="xsd:ID"/>--> 
</xsd:complexType> 

這裏是我的NotionalSRS2.xml:

<SoftwareRequirementsDocument projectName="Lifecycle Documents with Requirements 
Tracking" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="NotionalSchema2.xsd"  
xmlns:xx="http://apache.org/xml/features/xinclude/fixup-base-uris"> 

    <Section id="RQ1.0"> 

    <Title>Introduction</Title> 
    <Para>The Software Requirements Specification details the extent of NUWC’s Lifecycle Project Manager. The product’s main feature is it’s ability to create and manage lifecycle documents using a graphical user interface. The lifecycle documents will be organized and exported using an XML Schema. This can be accomplished by a user who has no knowledge of the XML language. This document will review all the basic functionality required for a user to edit, create, and manage lifecycle projects. 
    </Para>  
    </Section> 

    <Section id="RQ1.1"> 
     <Title>Purpose</Title> 
     <Para> To provide a detailed description of how the product will produce it’s lifecycle documents as well as edit and export them. It also overviews the basic functional requirements requested by the customer. 
     </Para> 
    </Section> 

這裏是使用XInclude的我的文件,ProjectLifecycleDocuments.xml:

<ProjectLifecycleDocuments id="PL1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-  
instance" xmlns:xi="http://www.w3.org/2001/XInclude" 
xsi:noNamespaceSchemaLocation="NotionalSchema2.xsd"> 
<xi:include href="NotionalSRS2.xml"/> 

</ProjectLifecycleDocuments> 

現在我在搜索這個錯誤時閱讀了很多關於命名空間的內容,但是我無法清楚地知道我錯在哪裏。

如果你能指出我正確的方向,爲什麼會出現這個錯誤,以及我如何解決它,那將是很棒的。

回答

5

的​​屬性(W3C XML Base由XInclude的符合規範補充。見:http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-3

的常見問題提出了兩個解決方案,其中一個要求您通過設置功能時禁用​​屬性的插入。運行分析器其他由有關配置模式,允許在包括類型,您可以通過導入XML XSD架構中的做​​屬性:

<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd" /> 

然後declari納克與參考屬性到​​:

<xsd:complexType name="SoftwareRequirementsDocumentType"> 
    <xsd:sequence> ... </xsd:sequence> 
    <xsd:attribute name="projectName" use="required" type="xsd:string"/> 
    <xsd:attribute ref="xml:base"/> 
    ... 
</xsd:complexType> 
+0

在您的第二鏈路:「根據規範的XInclude,處理器必須添加一個xml:base屬性的元件從具有不同的基本URI位置包括在內。如果沒有這些屬性,那麼產生的信息集信息將不正確。「禁用插入xml:base時會發生什麼變得不正確,以及它何時會成爲問題? – Andreas

+0

我不確定不正確的零件,但它肯定會使它更難反思元素起源於何處,也許是遞歸包含時包含這個元屬性的很好理由。 – ruffsl