Search code examples
xmlxsdxsd-validationxml-validation

Error: No grammar constraints (DTD or XML Schema) referenced in the document


I'm writing an XSD Schema for a XML Document. However, I get a warning that says:

No grammar constraints (DTD or XML Schema) referenced in the document.

I'm attaching the beginnings of my XML and XSD documents where I do the reference. Any advice would be helpful.

XML:

<InvoiceList xmlns:p="https://www.example.org/StefansNamespace"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="https://www.example.org/StefansNamespace Aufgabe3XMLSchema.xsd">

XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="https://www.example.org/StefansNamespace"
           targetNamespace="https://www.example.org/StefansNamespace"
           elementFormDefault="qualified">

Solution

  • InvoiceList as written in your XML file is in no namespace. To place it in the target namespace of your XSD (https://www.example.org/StefansNamespace), add the p namespace prefix to InvoiceList,

    <p:InvoiceList xmlns:p="https://www.example.org/StefansNamespace"
     ^^
    

    or use a default namespace:

    <InvoiceList xmlns="https://www.example.org/StefansNamespace"
                 ^^^^^