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>
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.
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.
"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)
Your XML should declare the namespace for xsi e.g. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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