1

Error what occurs is "Invalid schema or missing namespace". I'm new to this, and I don't know what have I do now. This error doesn't show me any wrong line or some other missing value im my code.

When I click in my NotePad++: Plugs -> XML Tools -> Validate now -> Invalid schema or missing namespace

I have XSD file this:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xsd:annotation>
        <xsd:documentation xml:lang="pl">Definicja zawiadomienia w formacie XML</xsd:documentation>
    </xsd:annotation>
    <xsd:element name="WYDZIAŁ">
        <xsd:annotation>
            <xsd:documentation>Dokładny opis wydziału</xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="IDENTYFIKATOR" type="xsd:ID">
                    <xsd:annotation>
                        <xsd:documentation>ID wydziału</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="NAZWA" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>Nazwa wydziału</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="ADRES" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
                    <xsd:annotation>
                        <xsd:documentation>Adres wydziału</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element ref="PRACOWNICY"/>
                <xsd:element ref="ZBIÓR_PRZEDMIOTÓW"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <!--===========================================================-->
    <xsd:element name="PRACOWNICY">
        <xsd:annotation>
            <xsd:documentation>Informacje dotyczace pracowników</xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="IMIE" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>Imie parcownika</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="NAZWISKO" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>Nazwisko pracownika</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="TYTUŁ" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>Tytuł pracownika</xsd:documentation>
                    </xsd:annotation>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:enumeration value="NAUKOWY"/>
                            <xsd:enumeration value="ADMINISTRACYJNY"/>
                            <xsd:enumeration value="TECHNICZNY"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="KATEGORIA" type="xsd:string" minOccurs="0">
                    <xsd:annotation>
                        <xsd:documentation>KATEGORIA pracownika</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="ADRES" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>ADRES parcownika</xsd:documentation>
                    </xsd:annotation>
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="ULICA" type="xsd:string">
                                <xsd:annotation>
                                    <xsd:documentation>ULICA</xsd:documentation>
                                </xsd:annotation>
                            </xsd:element>
                            <xsd:element name="NUMER" type="xsd:integer">
                                <xsd:annotation>
                                    <xsd:documentation>NUMER</xsd:documentation>
                                </xsd:annotation>
                            </xsd:element>
                            <xsd:element name="KOD_POCZTOWY" type="xsd:string">
                                <xsd:annotation>
                                    <xsd:documentation>KOD_POCZTOWY</xsd:documentation>
                                </xsd:annotation>
                                <xsd:simpleType>
                                    <xsd:restriction base="xsd:string">
                                        <xsd:minLength value="6"/>
                                        <xsd:maxLength value="6"/>
                                        <xsd:pattern value="\d{2}-\d{3}"/>
                                    </xsd:restriction>
                                </xsd:simpleType>
                            </xsd:element>
                            <xsd:element name="MIEJSCOWOSC" type="xsd:string">
                                <xsd:annotation>
                                    <xsd:documentation>MIEJSCOWOSC</xsd:documentation>
                                </xsd:annotation>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="ZBIÓR_PRZEDMIOTÓW">
        <xsd:annotation>
            <xsd:documentation>Informacje dotyczace adresata zawiadomienia</xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="ID_PRZEDMIOTU" type="xsd:ID">
                    <xsd:annotation>
                        <xsd:documentation>ID_PRZEDMIOTU</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="NAZWA" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>NAZWA</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element name="LICZBA_UCZESTNIKOW" type="xsd:integer">
                    <xsd:annotation>
                        <xsd:documentation>LICZBA_UCZESTNIKOW</xsd:documentation>
                    </xsd:annotation>
                    <xsd:simpleType>
                    <xsd:restriction base="xsd:integer">
                        <xsd:minInclusive  value="6"/>
                        <xsd:maxInclusive  value="400"/>
                    </xsd:restriction>
                </xsd:simpleType>
                </xsd:element>
                <xsd:element name="PROWADZCY" type="xsd:string" minOccurs="0">
                    <xsd:annotation>
                        <xsd:documentation>Numer wydzialu</xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

and my xml file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<WYDZIAŁ>
    <IDENTYFIKATOR>12</IDENTYFIKATOR>
    <NAZWA>WARTOŚĆ TEKSTOWA NAZWA</NAZWA>
    <ADRES> WARTOSC TEKSTOWA ADRES</ADRES>
    <PRACOWNICY>
        <IMIE>WARTOŚĆ TEKSTOWA IMIE</IMIE>
        <NAZWISKO>WARTOŚĆ TEKSTOWA NAZWISKO</NAZWISKO>
        <TYTUŁ>WARTOŚĆ TEKSTOWA TYTUŁ</TYTUŁ>
        <KATEGORIA>WARTOŚĆ TEKSTOWA KATEGORIA</KATEGORIA>
        <ADRES>
            <ULICA>WARTOŚĆ TEKSTOWA ULICA</ULICA>
            <NUMER>21</NUMER>
            <KOD_POCZTOWY>62-890</KOD_POCZTOWY>
            <MIEJSCOWOSC>WARTOŚĆ TEKSTOWA MIEJSCOWOSC</MIEJSCOWOSC>
        </ADRES>
    </PRACOWNICY>
    <ZBIÓR_PRZEDMIOTÓW>
        <ID_PRZEDMIOTU>12</ID_PRZEDMIOTU>
        <NAZWA>WARTOŚĆ TEKSTOWA NAZWA</NAZWA>
        <LICZBA_UCZESTNIKOW>66</LICZBA_UCZESTNIKOW>
        <PROWADZACY>WARTOŚĆ TEKSTOWA PROWADZCY</PROWADZACY>
    </ZBIÓR_PRZEDMIOTÓW>
</WYDZIAŁ>
kjhughes
  • 106,133
  • 27
  • 181
  • 240
pawroz
  • 15
  • 1
  • 6
  • If your question has been answered, please accept the answer that has helped the most and upvote all answers that have be helped at all. If you're still unclear on the answer, please follow-up to request further information. Thank you. – kjhughes Apr 14 '21 at 19:47

1 Answers1

1

Notepad++ problems: You have to associate your XSD with your XML. I will show an example of how to do so via the standard hint mechanism provided by xsi:noNamespaceSchemaLocation in the XML below, or use Notepad++'s particular binding mechanism.

See:

XSD problems: Do not define both a type attribute and provide a type child element to xs:element. (3 occurrences of this issue)

XML problems: Abide by the XSD's enumeration constraints given on several elements. Spell the tag the same as is specified in the XSD. Etc.

Corrections to your XSD and XML follow. Once you follow the instructions for associating the XSD with your XML, the updated XSD will validate the updated XML.

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xsd:annotation>
    <xsd:documentation xml:lang="pl">Definicja zawiadomienia w formacie XML</xsd:documentation>
  </xsd:annotation>
  <xsd:element name="WYDZIAŁ">
    <xsd:annotation>
      <xsd:documentation>Dokładny opis wydziału</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="IDENTYFIKATOR" type="xsd:ID">
          <xsd:annotation>
            <xsd:documentation>ID wydziału</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="NAZWA" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>Nazwa wydziału</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="ADRES" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
          <xsd:annotation>
            <xsd:documentation>Adres wydziału</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element ref="PRACOWNICY"/>
        <xsd:element ref="ZBIÓR_PRZEDMIOTÓW"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <!--===========================================================-->
  <xsd:element name="PRACOWNICY">
    <xsd:annotation>
      <xsd:documentation>Informacje dotyczace pracowników</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="IMIE" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>Imie parcownika</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="NAZWISKO" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>Nazwisko pracownika</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="TYTUŁ">
          <xsd:annotation>
            <xsd:documentation>Tytuł pracownika</xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:enumeration value="NAUKOWY"/>
              <xsd:enumeration value="ADMINISTRACYJNY"/>
              <xsd:enumeration value="TECHNICZNY"/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="KATEGORIA" type="xsd:string" minOccurs="0">
          <xsd:annotation>
            <xsd:documentation>KATEGORIA pracownika</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="ADRES">
          <xsd:annotation>
            <xsd:documentation>ADRES parcownika</xsd:documentation>
          </xsd:annotation>
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="ULICA" type="xsd:string">
                <xsd:annotation>
                  <xsd:documentation>ULICA</xsd:documentation>
                </xsd:annotation>
              </xsd:element>
              <xsd:element name="NUMER" type="xsd:integer">
                <xsd:annotation>
                  <xsd:documentation>NUMER</xsd:documentation>
                </xsd:annotation>
              </xsd:element>
              <xsd:element name="KOD_POCZTOWY">
                <xsd:annotation>
                  <xsd:documentation>KOD_POCZTOWY</xsd:documentation>
                </xsd:annotation>
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:minLength value="6"/>
                    <xsd:maxLength value="6"/>
                    <xsd:pattern value="\d{2}-\d{3}"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element name="MIEJSCOWOSC" type="xsd:string">
                <xsd:annotation>
                  <xsd:documentation>MIEJSCOWOSC</xsd:documentation>
                </xsd:annotation>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="ZBIÓR_PRZEDMIOTÓW">
    <xsd:annotation>
      <xsd:documentation>Informacje dotyczace adresata zawiadomienia</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ID_PRZEDMIOTU" type="xsd:ID">
          <xsd:annotation>
            <xsd:documentation>ID_PRZEDMIOTU</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="NAZWA" type="xsd:string">
          <xsd:annotation>
            <xsd:documentation>NAZWA</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element name="LICZBA_UCZESTNIKOW">
          <xsd:annotation>
            <xsd:documentation>LICZBA_UCZESTNIKOW</xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
            <xsd:restriction base="xsd:integer">
              <xsd:minInclusive  value="6"/>
              <xsd:maxInclusive  value="400"/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="PROWADZCY" type="xsd:string" minOccurs="0">
          <xsd:annotation>
            <xsd:documentation>Numer wydzialu</xsd:documentation>
          </xsd:annotation>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

XML

<?xml version="1.0" encoding="UTF-8" ?>
<WYDZIAŁ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="try.xsd">
  <IDENTYFIKATOR>a12</IDENTYFIKATOR>
  <NAZWA>WARTOŚĆ TEKSTOWA NAZWA</NAZWA>
  <ADRES> WARTOSC TEKSTOWA ADRES</ADRES>
  <PRACOWNICY>
    <IMIE>WARTOŚĆ TEKSTOWA IMIE</IMIE>
    <NAZWISKO>WARTOŚĆ TEKSTOWA NAZWISKO</NAZWISKO>
    <TYTUŁ>NAUKOWY</TYTUŁ>
    <KATEGORIA>WARTOŚĆ TEKSTOWA KATEGORIA</KATEGORIA>
    <ADRES>
      <ULICA>WARTOŚĆ TEKSTOWA ULICA</ULICA>
      <NUMER>21</NUMER>
      <KOD_POCZTOWY>62-890</KOD_POCZTOWY>
      <MIEJSCOWOSC>WARTOŚĆ TEKSTOWA MIEJSCOWOSC</MIEJSCOWOSC>
    </ADRES>
  </PRACOWNICY>
  <ZBIÓR_PRZEDMIOTÓW>
    <ID_PRZEDMIOTU>a13</ID_PRZEDMIOTU>
    <NAZWA>WARTOŚĆ TEKSTOWA NAZWA</NAZWA>
    <LICZBA_UCZESTNIKOW>66</LICZBA_UCZESTNIKOW>
    <PROWADZCY>WARTOŚĆ TEKSTOWA PROWADZCY</PROWADZCY>
  </ZBIÓR_PRZEDMIOTÓW>
</WYDZIAŁ>
kjhughes
  • 106,133
  • 27
  • 181
  • 240