2

I am currently working on a project, where I have a base XML Schema that I have to extend. I tried following the solutions of https://www.w3schools.com/xml/el_include.asp and How to extend an xml-schema from another xml-schema?.

I am using XML Tools 2.3.2 on Visual Studio Code, that work as expected when validating xml to xsd. However, when I try to extend the schema like depicted below:

node.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="node" type="nodeType"></xs:element>
...
</xs:schema>

nodeextenstion.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:include schemaLocation="node.xsd"/>
</xs:schema>

Visual Studio Code throws me this error:

Visual Studio Code XSD Extension Error

Has anybody experienced this behaviour and may help me out.

Appreciate every hint :)

Gama11
  • 31,714
  • 9
  • 78
  • 100
Dengoe
  • 21
  • 1
  • 5

1 Answers1

0

Since schemaLocation is not part of the current "xmlns", it cannot be recognized.

"Please try":

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema-instance" >
    <xs:include schemaLocation="node.xsd"/>
</xs:schema>

... add xmlns="http://www.w3.org/2001/XMLSchema-instance" in the node hierarchy (above), where schemaLocation is used.

Alternatively:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
    <xs:include xsi:schemaLocation="node.xsd"/>
</xs:schema>

..introduce prefix for "http://www.w3.org/2001/XMLSchema-instance" & use it as prefix:schemaLocation.


see also: XML Schema Validation : Cannot find the declaration of element

xerx593
  • 12,237
  • 5
  • 33
  • 64