2
我想創建一個XML模式,我卡住了。看來我無法定義一個包含字符串內容的元素。我究竟做錯了什麼?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: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>
驗證器說:
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}'.
這是'elementFormDefault'屬性,謝謝。 – svick 2010-05-15 19:03:12