I wouldn't be here if I hadn't Googled my way into Oblivion. I have the following problem: I have an XML Schema, 3 single XML documents, and an XML document to link all of the other 3. I am running into the following error and I do not understand why.
E [Xerces] cvc-complex-type.3.2.2: Attribute 'xml:base' is not allowed to appear in element 'SoftwareRequirementsDocument'.
I have read a bunch of forum posts from Google with people with a similar problem but none of their fixes would help me. I will post my Schema, 1 XML document to be connected, and the XML document with XInclude. I will post the beginning of each document as that is what is needed.
Here is 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>
Here is my 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>
And here is my file using 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>
Now I read a lot about namespacing when searching this error, but I could not get a clear grasp on where I was going wrong.
If you could point me in the right direction as to why this error is happening and how I can approach fixing it, that would be great.
The xml:base
attribute (W3C XML Base is added by XInclude for compliance with the specification. See: http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-3
The FAQ proposes two solutions. One of them requires you to disable the insertion of the xml:base
attribute by setting a feature when running the parser. The other consists on configuring your schema to allow the xml:base
attribute in the included type, which you can do by importing the XML XSD in your schema:
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd" />
And then declaring the attribute with a reference to 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With