XML Schema示例 - 未绑定元素“xs:element”的前缀“xs”

时间:2017-03-15 10:57:12

标签: xml xsd xsd-validation

以下是来自https://www.w3schools.com/xml/xml_schema.asp

的示例
[rule1:

(?if rdf:type p:InferredConfiguration)
(?if p:userName ?userEmail)
(?subProfile rdf:type u:PersonSubProfile)
(?subProfile u:hasUsername ?email)
equal(?userEmail, ?email)

(?subProfile u:hasName "")
(?subProfile u:hasLastname "")
(?subProfile u:hasPhone ?var)
equal (?var, "")
(?subProfile u:hasEducation "Low")
  ->
drop(7)
(?subProfile u:hasPhone "00000")

print('**************** Phone defined - Rule 1 ***************')
]

当我尝试验证时,我收到错误:

  

元素“xs:element”的前缀“xs”未绑定在第1行 - XML上   架构问题

这有什么架构问题?

1 个答案:

答案 0 :(得分:2)

添加名称空间前缀:xs

`

<?xml version="1.0" encoding="UTF-8"?>
     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="note">
          <xs:complexType>
             <xs:sequence>
                <xs:element name="to" type="xs:string" />
                <xs:element name="from" type="xs:string" />
                <xs:element name="heading" type="xs:string" />
                <xs:element name="body" type="xs:string" />
             </xs:sequence>
          </xs:complexType>
       </xs:element>
    </xs:schema>
相关问题