Notepad++ doesn't ask me the XLM Schema when I click on validate now

Viewed 1735

I created a file.xml and a file.xsd. I installed the XML tools in notepad++. After I opened only the file.xml and I clicked on Plugin->XML Tools->Validate now. The following window appears:

enter image description here

It's quite weird because I didn't specified the XML schema (file.xsd). If I change the name of an element, the xml tools still says no error detected, but actually there is an error.

How can I reference the file.xml to the file.xsd?


EDIT The contect of the file.xml is the following:

<?xml version="1.0"?>

<note
xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3schools.com/xml note.xsd">
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

EDIT2: file.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com"
xmlns="https://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>
1 Answers

Notepad++ does not throw an error because a) your XML document contains a reference to an XML Schema file and b) the XML document is valid against that schema.

This references a schema file:

xsi:schemaLocation="https://www.w3schools.com/xml note.xsd"

Notepad++ will assume that there is a local file note.xsd in the same folder as the XML document itself.


How can I reference the file.xml to the file.xsd?

If your XML document defines a namespace, then xsi:schemaLocation should include this namespace. Your XML document is in the namespace https://www.w3schools.com. Reference the XML Schema as follows:

xsi:schemaLocation="https://www.w3schools.com note.xsd"
Related