Xsd cvc复杂类型.2.4.c:匹配的通配符是严格的,但找不到任何声明

Xsd cvc复杂类型.2.4.c:匹配的通配符是严格的,但找不到任何声明,xsd,xsd-validation,Xsd,Xsd Validation,我试图理解xsd中的元素。我有两个XSD 图书目录.xsd <?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualifie

我试图理解xsd中的
元素。我有两个XSD

图书目录.xsd

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com"
    elementFormDefault="qualified">
    <xs:element name="BookCatalogue">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Book" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Title" type="xs:string" />
                            <xs:element name="Author" type="xs:string" />
                            <xs:element name="Date" type="xs:string" />
                            <xs:element name="ISBN" type="xs:string" />
                            <xs:element name="Publisher" type="xs:string" />
                            <xs:any namespace="##any" minOccurs="0" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema> 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com"
    elementFormDefault="qualified">

    <xs:element name="Reviewer">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="First" type="xs:string" />
                            <xs:element name="Last" type="xs:string" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>



</xs:schema> 

Reviewer.xsd

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com"
    elementFormDefault="qualified">
    <xs:element name="BookCatalogue">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Book" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Title" type="xs:string" />
                            <xs:element name="Author" type="xs:string" />
                            <xs:element name="Date" type="xs:string" />
                            <xs:element name="ISBN" type="xs:string" />
                            <xs:element name="Publisher" type="xs:string" />
                            <xs:any namespace="##any" minOccurs="0" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema> 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com"
    elementFormDefault="qualified">

    <xs:element name="Reviewer">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="First" type="xs:string" />
                            <xs:element name="Last" type="xs:string" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>



</xs:schema> 

但是如果我基于上面的xsd验证下面的xml,我将得到cvc复杂类型。2.4.c:匹配的通配符是严格的,但是找不到元素“p:Reviewer”的声明。错误。两个xsd文件是否不应位于同一命名空间中

<?xml version="1.0" encoding="UTF-8"?>
<pr:BookCatalogue xmlns:pr="http://www.w3schools.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3schools.com AddRequest.xsd ">
    <pr:Book>
        <pr:Title>pr:Title</pr:Title>
        <pr:Author>pr:Author</pr:Author>
        <pr:Date>pr:Date</pr:Date>
        <pr:ISBN>pr:ISBN</pr:ISBN>
        <pr:Publisher>pr:Publisher</pr:Publisher>
        <p:Reviewer xmlns:p="http://www.w3schools.com"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.w3schools.com Children.xsd ">
            <p:Name>
                <p:First>p:First</p:First>
                <p:Last>p:Last</p:Last>
            </p:Name>
        </p:Reviewer>
    </pr:Book>
</pr:BookCatalogue>

公关:标题
公关:作者
pr:日期
pr:ISBN
公关:出版商
p:首先
p:最后一个
两个选项

选项一:如果您不希望必须提供
p:Reviewer
的定义,请将
processContents=“lax”
添加到
xs:any
元素中:

      <xs:any namespace="##any" minOccurs="0"  processContents="lax"/>
注意:确保Review.xsd中的
targetNamespace
与BookCatalog.xml的
xsi:schemaLocation
属性中为其声明的内容匹配

选项二:如果您确实希望坚持
p:Reviewer
的定义存在
,只需进行上述更改,以确保可以通过
xsi:schemaLocation
机制找到Review.xsd。不需要
processContents
设置;它默认为
strict

两个选项

选项一:如果您不希望必须提供
p:Reviewer
的定义,请将
processContents=“lax”
添加到
xs:any
元素中:

      <xs:any namespace="##any" minOccurs="0"  processContents="lax"/>
注意:确保Review.xsd中的
targetNamespace
与BookCatalog.xml的
xsi:schemaLocation
属性中为其声明的内容匹配


选项二:如果您确实希望坚持
p:Reviewer
的定义存在
,只需进行上述更改,以确保可以通过
xsi:schemaLocation
机制找到Review.xsd。不需要
processContents
设置;默认为
严格

谢谢。但为什么错误发生在以前而不是现在?这意味着什么。最初,处理器找不到
p:Review
的定义,并且有义务投诉,因为
xs:any/@processContents
默认为
strict
。在使用
processContents
lax
设置掩盖问题之前,您应该确保您的
schemaLocation
设置正确。谢谢。但为什么错误发生在以前而不是现在?这意味着什么。最初,处理器找不到
p:Review
的定义,并且有义务投诉,因为
xs:any/@processContents
默认为
strict
。在使用
processContents
lax
设置掩盖问题之前,应确保您的
schemaLocation
设置正确。