Reputation: 65
I've got a problem validating my XML file against my XML Schema. Everything works perfectly except it shows that it cannot find the declaration of countries
root element.
Here is part of my XML file:
<?xml version="1.0" encoding="UTF-8"?>
<countries xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="kraje.xsd">
<!-- I don't paste everything that's inside the countries element
since it's not causing errors -->
</countries>
Here is part of my XSD file:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="countries" type="countriesType"/>
<xs:complexType name="countriesType">
<xs:sequence>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Upvotes: 2
Views: 529
Reputation: 111491
Since your XML is in a https://www.w3schools.com
namespace, change
xsi:schemaLocation="kraje.xsd"
to
xsi:schemaLocation="https://www.w3schools.com kraje.xsd"
Add a matching targetNamespace
,
targetNamespace="https://www.w3schools.com"
to the xs:schema
root element.
Upvotes: 1