xmlxsdxml-namespacesxsd-validationxml-validation

Cannot find the declaration of 'p:Peminjaman'


I'm trying to do simple xml. but it shows cvc-elt.1.a: Cannot find the declaration of element 'p:Peminjaman' as an error.

<?xml version="1.0" ?>
<p:Peminjaman xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="namespace tes.xsd" xmlns:p="namespace">
    <p:PinjamanDetail>
        <p:Buku>
            <p:Judul>Widget </p:Judul>
            <p:Jumlah>1</p:Jumlah>
            <p:Category>Programming</p:Category>
        </p:Buku>
    </p:PinjamanDetail>
    <p:CustomerDetail>
        <p:Nama>James</p:Nama>
        <p:Alamat>
            <p:Line1>15 Some Road</p:Line1>
            <p:Line2>SomeTown</p:Line2>
        </p:Alamat>
    </p:CustomerDetail>
</p:Peminjaman>

here is the code, please help since I really don't know what's wrong :D


Solution

  • You didn't post your XSD, but if you're looking for guesses:

    1. tes.xsd lacks targetNamespace="namespace" on the xs:schema element.
    2. Peminjaman is not defined as a top-level element in tes.xsd.
    3. tes.xsd is not well-formed or invalid.
    4. tes.xsd cannot be found.

    If you'd like less guessing and more definitive answering, post a minimum, complete viable example of your issue, including your XSD.

    See also