Reputation: 373
I'm extremely new to XML, and currently ready Ineasysteps. I keep getting the same issue from the parser saying
5:The prefix "xsd" for element "xsd:schema" is not bound.
This is the hello.xml:
<?xml version = "1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 82. -->
<doc xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = "hello.xsd" >
<msg>Hello World</msg>
</doc>
Here is the hello.xsd doc
<?xml version="1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 84. -->
<xsd:schema>
<!-- DECLARE ELEMENTS. -->
<!-- Simple types. -->
<xsd:element name="msg" type="xsd:string"/>
<!-- Complex types. -->
<xsd:element name="doc" type="docType"/>
<!-- DEFINE STRUCTURE. -->
<xsd:complexType name="docType">
<xsd:sequence>
<xsd:element ref="msg"/>
</xsd:sequence>
</xsd:complexType
Upvotes: 2
Views: 8711
Reputation: 111491
A namespace prefix such as xsd
must be defined before being used. This applies even to the well-known xsd
(or xs
) prefixes commonly used for the component of XML Schema (XSD).
To eliminate the error, define the xsd
namespace prefix by adding
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
to the xsd:schema
root element like this:
<?xml version="1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 84. -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- DECLARE ELEMENTS. -->
<!-- Simple types. -->
<xsd:element name="msg" type="xsd:string"/>
<!-- Complex types. -->
<xsd:element name="doc" type="docType"/>
<!-- DEFINE STRUCTURE. -->
<xsd:complexType name="docType">
<xsd:sequence>
<xsd:element ref="msg"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Upvotes: 6