I created an XSD with the following header.
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="https://github.com/geryxyz/binary-schema"
targetNamespace="https://github.com/geryxyz/binary-schema"
>
<xsd:complexType name="formatType">
<xsd:annotation>
<xsd:documentation xml:lang="en">
The root element for the binary file format specification.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="type" type="typeType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
...
I also created a sample XML based on the above XSD.
<?xml version="1.0" encoding="UTF-8" ?>
<format xmlns="https://github.com/geryxyz/binary-schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/geryxyz/binary-schema binary-schema.xsd">
<type name="sdfsd">
<chunk length="23"/>
</type>
</format>
My investigations suggested that the usage of xmlns
and targetNamespace
in the XSD is somewhat redundant.
I use PyCharm as an IDE, which reports an error in the sample XML file.
The error disappears if I remove the xmlns
declaration from the XSD. I would like to understand the underlying concept behind what happened. Is it a bug in PyCharm, or is it an XSD bad practice?