XML tools: validation against XSD: noNamespaceSchemaLocation attribute not allowed?
-
I am quite new to Notepad++. I downloaded this tool because of the XML tools available.
I am generally trying to follow some of Brendan Jones’ videos on XSD from YouTube (e.g., https://www.youtube.com/watch?v=OfjqSkgO7Hg&index=5&list=PL73qvSDlAVViXEuAWaRFKul4gmYX9D-qL)I believe I’ve installed Notepad++ (the latest 64 bit version )and the plugin manager correctly, and used the plugin manager to install the XML tools.
Here’s a very simple XML file:
<?xml version=“1.0”?>
<plant xmlns:xsi=“https://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation=“plants.xsd”>
<genus>Cercis</genus>
</plant>In the root element, I am trying to specify that this XML file should be validated against the local (i.e., same directory) XSD file: plants.xsd (what I see Brendan doing in his videos).
Here’s the very simple simple content of that XSD file:
<?xml version=“1.0” encoding=“UTF-8”?>
<xs:schema xmlns:xs=“http://www.w3.org/2001/XMLSchema”>
<xs:element name=“plant”>
xs:complexType
xs:sequence
<xs:element name=“genus”>
xs:simpleType
<xs:restriction base=“xs:string”>
<xs:maxLength value=“60”/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>When I run the validator, the error message returned is:
Validation of current file using XML schema:
ERROR: Element ‘plant’, attribute ‘{https://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation’: The attribute ‘{https://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation’ is not allowed.
I can actually remove that attribute from the root element of the XML instance (my <plant> tag), run the validator and then NPP will launch a dialog asking me to specify the XSD file. I can just type in “plants.xsd” and the file will validate as expected.
But the dialog itself suggests that you specify your XSD in the root element.
This dialog box is displayed because default validation schema cannot be found in the XML root
element. To avoid having to specify the XSD for every validation, please define the default
XML schema in your root element using the following syntax:<plant xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespcaeSchemaLocation=“XSD_FILE_PATH”>where XSD_FILE_PATH is the relative or absolute path of the XML schema file.
Well, yeah… that sounds great.
That’s what I did, actually.I don’t get it - why the error?