Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: The prefix "xsi" for attribute "xsi:schemaLocation" is not bound

I am having trouble validating my XML against an XSD. The validator throws

The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "mpreader" is not bound.

Here's the an XML clip

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mpreader xmlns="C:\Users\Dallan\Desktop\Mpreader\" xmlns:xs="http://www.w3.org/20one/XMLSchema-instance" 
 xsi:schemaLocation="C:\Users\Dallan\Desktop\Mpreader\mpreaderschemafinal.xsd"> 
                <firmware>"3.4.16"</firmware>  

                <hardware>"2.3.53"</hardware>  

                <sn>"234-1three5"</sn>

                <devices> 
            </devices>
        </mpreader>

And here's the XSD clip

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="C:Users/Dallan/Desktop/Mpreader/" elementFormDefault="qualified" targetNamespace="C:\Users\Dallan\Desktop\Mpreader\">

<xs:element name="mpreader">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
    <xs:element name="firmware" type="xs:string"/>
    <xs:element name="hardware" type="xs:string"/>
    <xs:element name="sn" type="xs:string"/>
    <xs:element name="devices">
        <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
like image 611
Dallan Baker Avatar asked Aug 03 '15 23:08

Dallan Baker


People also ask

What is XSI schemaLocation in XML?

The xsi:schemaLocation attribute locates schemas for elements and attributes that are in a specified namespace. Its value is a namespace URI followed by a relative or absolute URL where the schema for that namespace can be found. It is most commonly attached to the root element but can appear further down the tree.

What is the Xmlns XSI attribute for?

xmlns:xsi:http://www.w3.org/2001/XMLSchema-instance — Declared in the XML and is used to help declare that the XML document is an instance of and XSD. The convention is to use the namespace prefix of xsi. targetNamespace: is used in the header of the XSD to defined the namespace that the XSD describes.


2 Answers

"The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "mpreader" is not bound."

Then bind it, dear Dallan, dear Dallan, dear Dallan...

Just add a namespace declaration binding the prefix xsi to the namespace http://www.w3.org/2001/XMLSchema-instance

(https://en.wikipedia.org/wiki/There%27s_a_Hole_in_My_Bucket)

like image 145
Michael Kay Avatar answered Oct 20 '22 12:10

Michael Kay


Your XML should declare the namespace for xsi e.g. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

like image 26
srjt Avatar answered Oct 20 '22 13:10

srjt