简体   繁体   English

XML模式:找不到元素'users'的声明

[英]XML Schema: Cannot find the declaration of element 'users'

I am new to XML Schema. 我是XML Schema的新手。 So I really dont know what happened. 所以我真的不知道发生了什么。 I followed the tutorials and created an valid XML Schema. 我按照教程学习并创建了一个有效的XML模式。 But it cant find the declaration. 但是它找不到声明。 That's odd. 真奇怪

The XML file: XML文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<users>
<user><id>1</id><username>thomas01</username><display_name>Thomas Müntzer</display_name><birthday>04.12.1956</birthday><email_address>thomas@muentzer.de</email_address><quota>524288000</quota><quota_used>14727606</quota_used></user>
</users>

The XML Schema: XML模式:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.infbox_normal.com" xmlns="http://www.infbox_normal.com" elementFormDefault="qualified">

    <xs:element name="users">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="user">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="id" type="xs:integer"/>
                            <xs:element name="username" type="xs:string"/>
                            <xs:element name="display_name" type="xs:string"/>
                            <xs:element name="birthday" type="xs:string"/>
                            <xs:element name="email_address">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:pattern value="/^\S+@\S+\.\S+$/"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                            <xs:element name="quote" type="xs:integer"/>
                            <xs:element name="quote_used" type="xs:integer"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    </xs:schema> 

The error meg: 错误错误:

Error - Line 2, 8: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 8; cvc-elt.1: Cannot find the declaration of element 'users'.

I use this to validate the XML Schema. 我用来验证XML模式。

您的XSD定义了目标名称空间http://www.infbox_normal.com但您的XML没有名称空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM