8

グーグルでオブリビオンにアクセスしていなかったら、私はここにいなかったでしょう。次の問題があります。XML スキーマ、3 つの単一の XML ドキュメント、および他の 3 つのすべてをリンクする XML ドキュメントがあります。次のエラーが発生しましたが、その理由がわかりません。

E [Xerces] cvc-complex-type.3.2.2: 属性「xml:base」は要素「SoftwareRequirementsDocument」に表示できません。

同様の問題を抱えている人々と一緒にGoogleからのフォーラム投稿をたくさん読んだことがありますが、彼らの修正はどれも役に立ちませんでした. スキーマ、接続する 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>

このエラーを検索するときに名前空間について多くのことを読みましたが、どこが間違っているのか明確に把握できませんでした。

このエラーが発生する理由と、それを修正する方法について正しい方向に向けることができれば、それは素晴らしいことです.

4

1 に答える 1

11

xml:base属性 ( W3C XML Baseは、仕様に準拠するために XInclude によって追加されます。参照: http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-3

FAQ では 2 つの解決策が提案されています。xml:baseそのうちの 1 つは、パーサーの実行時に機能を設定して、属性の挿入を無効にする必要があります。もう 1 つは、含まれる型の属性を許可するようにスキーマを構成するxml:baseことです。これは、スキーマに XML XSD をインポートすることで実行できます。

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

次に、への参照を使用して属性を宣言しますxml:base

<xsd:complexType name="SoftwareRequirementsDocumentType">
    <xsd:sequence> ... </xsd:sequence>
    <xsd:attribute name="projectName" use="required" type="xsd:string"/>
    <xsd:attribute ref="xml:base"/>
    ...
</xsd:complexType>
于 2014-04-01T16:22:27.040 に答える