Xml – Creating an XSD using Notepad++ XML Tools

notepadxmlxsd

I'm working on creating XSD files for various XML documents, I'm currently using the XML Tools Notepad++ plugin, and when I try to validate my XSD files,
it asks for XML Schema to validate against: I'm not sure how to properly point XML Tools to the right schema to validate my XSD file, since the schema for an XSD file is not locally defined, its defined universally by W3. This is my current schema tag declaration:

<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3.org/2009/XMLSchema/XMLSchema.xsd">

I've tried looking up a solution on other sites, but I haven't exactly found a solution. This is my full XSD file as of now. I'm thinking that XML Tools either can't resolve the location of a non-local URI or XML Tools isn't properly recognizing my XSD file as an XML Schema, but I'm not entirely sure. It's also possible that I'm simply not declaring something properly.

Just to be clear, I'm not at the point of validating my XML file, I'm simply trying to create an XSD that is properly formed.

Best Answer

The best way to validate that a schema is correct is to submit it to a schema processor. This will do a much more thorough check than merely assessing it against the schema-for-schema-documents (S4SD). There are many constraints on a schema that cannot be expressed in the S4SD.

In fact these are of two kinds.

(1) Schema representation constraints are constraints at the level of the schema document, for example (in XSD 1.1 part 1 §3.9.1):

In addition to the conditions imposed on <any> and <anyAttribute> element information items by the schema for schema documents, namespace and notNamespace attributes must not both be present.

(2) Schema component constraints are expressed in terms of constraints on the schema component model generated from the source schema document. An example is the "element declarations consistent" constraint (§3.8.6.3) which says that if two element particles in a content model have the same name then they must also have the same type.

Different schema processors will provide different ways of validating a schema. For example with Saxon on .NET you can just do

Validate -xsd:my-schema.xsd -t

(supplying a schema and no source document) and it will tell you if there are any errors in your schema.