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>
现在我在搜索此错误时阅读了很多关于命名空间的内容,但我无法清楚地了解出错的地方。
如果你能指出我正确的方向,为什么会发生这种错误以及如何解决这个错误,那就太棒了。
答案 0 :(得分:8)
XInclude添加了xml:base
属性(W3C XML Base符合规范。请参阅:http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-3
FAQ提出了两种解决方案。其中一个要求您通过在运行解析器时设置功能来禁用xml:base
属性的插入。另一个包括配置架构以允许包含类型中的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>