找不到 'p:Peminjaman' 的声明

Cannot find the declaration of 'p:Peminjaman'

我正在努力做到简单 xml。但它显示 cvc-elt.1.a: Cannot find the declaration of element 'p:Peminjaman' 为错误。

<?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>

这是代码,请帮忙,因为我真的不知道哪里出了问题:D

您没有 post 您的 XSD,但如果您正在寻找猜测:

  1. tes.xsdxs:schema 元素上缺少 targetNamespace="namespace"
  2. Peminjaman 未定义为 tes.xsd 中的 top-level 元素。
  3. tes.xsd 不是 well-formed 或无效。
  4. tes.xsd 找不到。

如果您想要更少的猜测和更明确的回答,post 您的问题的最小、完整的可行示例,包括您的 XSD。

另见

  • How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?
  • How to reference a local XML Schema file correctly?