XML架构和类型为字符串的元素
我试图创建一个XML模式,但我被卡住了。似乎我不能用字符串内容定义元素。我做错了什么 模式:XML架构和类型为字符串的元素,xml,validation,xsd,Xml,Validation,Xsd,我试图创建一个XML模式,但我被卡住了。似乎我不能用字符串内容定义元素。我做错了什么 模式: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://ponderka.wz.cz/MusicLibrary0" targetNamespace="http://ponderka.wz.cz/MusicLibrary0"> <xs:elem
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://ponderka.wz.cz/MusicLibrary0" targetNamespace="http://ponderka.wz.cz/MusicLibrary0">
<xs:element name="music-library">
<xs:complexType>
<xs:sequence>
<xs:element name="artist" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
文件:
<?xml version="1.0"?>
<music-library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ponderka.wz.cz/MusicLibrary0 data0.xsd" xmlns="http://ponderka.wz.cz/MusicLibrary0">
<artist>a</artist>
</music-library>
A.
验证者说:
Element <artist> is not allowed under element <music-library>.
Reason: The following elements are expected at this location (see below)
<artist>
Error location: music-library / artist
Details
cvc-model-group: Element <artist> unexpected by type '{anonymous}' of element <music-library>.
cvc-elt.5.2.1: The element <music-library> is not valid with respect to the actual type definition '{anonymous}'.
元素下不允许使用元素。
原因:此位置应具有以下元素(见下文)
错误位置:音乐库/艺术家
细节
cvc模型组:元素的类型“{anonymous}”导致元素意外。
cvc elt.5.2.1:元素对于实际类型定义“{anonymous}”无效。
您缺少以下内容:
attributeFormDefault="unqualified"
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ponderka.wz.cz/MusicLibrary0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="music-library">
<xs:complexType>
<xs:sequence>
<xs:element name="artist" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>