XML验证出错

时间:2014-09-29 02:08:40

标签: xml validation w3c

我对XML很新,我确实在弄清楚我做错了什么。回来的大多数错误都是文档类型不允许元素“跟踪”。如果有人能告诉我我做错了什么,我真的很感激。 请记住,我提前不到一个月就这样做了。

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="CdCollection.xsl"?>
<!DOCTYPE cdCollection [
<!ELEMENT cdCollection(album)>
<!ELEMENT album(title, artist, label, disk, track+, diskOne, diskTwo)>
<!ELEMENT title(#PCDATA)>
<!ELEMENT artist(#PCDATA)>
<!ELEMENT label(#PCDATA)>
<!ELEMENT disk(#PCDATA)>
<!ELEMENT track(trackTitle, trackNumber, trackTime)>
<!ELEMENT trackTitle(#PCDATA)>
<!ELEMENT trackNumber(#PCDATA)>
<!ELEMENT trackTime(minute, seconds)>
<!ELEMENT minute(#PCDATA)>
<!ELEMENT seconds(#PCDATA)>
<!ELEMENT diskOne(title, artist, label, track+)>
<!ELEMENT diskTwo(title, artist, label, track+)>
]>
<cdCollection>
	<album>
		<title>Barenaked Ladies Are Men</title>
		<artist>Barenaked Ladies</artist>
		<label> Raisin Records</label>
		<disk>
			<track>
				<trackTitle>Serendipity</trackTitle>
				<trackNumber>1.</trackNumber>
				<trackTime>
					<minute>&#45; 4 &#58;</minute>
					<seconds>11</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Something You&#39;ll Never Find</trackTitle>
				<trackNumber>2.</trackNumber>
				<trackTime>
					<minute>&#45; 4 &#58;</minute>
					<seconds>57</seconds>
				</trackTime>
			</track>
				<track>
				<trackTitle>One and Only</trackTitle>
				<trackNumber>3.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>47</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Angry People</trackTitle>
				<trackNumber>4.</trackNumber>
				<trackTime>
					<minute>&#45; 4 &#58;</minute>
					<seconds>01</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Down to Earth</trackTitle>
				<trackNumber>5.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>46</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Beautiful</trackTitle>
				<trackNumber>6.</trackNumber>
				<trackTime>
					<minute>&#45; 2 &#58;</minute>
					<seconds>35</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Running Out of Ink</trackTitle>
				<trackNumber>7.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>58</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Half a Heart</trackTitle>
				<trackNumber>8.</trackNumber>
				<trackTime>
					<minute>&#45; 4 &#58;</minute>
					<seconds>27</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Maybe Not</trackTitle>
				<trackNumber>9.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>00</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>I Can I Will I Do</trackTitle>
				<trackNumber>10.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>08</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Fun &amp; Games</trackTitle>
				<trackNumber>11.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>45</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>The New Sad</trackTitle>
				<trackNumber>12.</trackNumber>
				<trackTime>
					<minute>&#45; 2 &#58;</minute>
					<seconds>34</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Quality</trackTitle>
				<trackNumber>13.</trackNumber>
				<trackTime>
					<minute>&#45; 4 &#58;</minute>
					<seconds>15</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Another Spin</trackTitle>
				<trackNumber>14.</trackNumber>
				<trackTime>
					<minute>&#45; 2 &#58;</minute>
					<seconds>34</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>What A Letdown</trackTitle>
				<trackNumber>15.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>49</seconds>
				</trackTime>
			</track>
			<track>
				<trackTitle>Why Say Anything Nice?</trackTitle>
				<trackNumber>16.</trackNumber>
				<trackTime>
					<minute>&#45; 3 &#58;</minute>
					<seconds>42</seconds>
				</trackTime>
			</track>
		</disk>
	</album>
	<album>
		<diskOne>
			<title>Live From Mars</title>
			<artist>Ben Harper</artist>
			<label> Virgin Records US</label>
				<track>
					<trackTitle>Glory &amp; Consequenc</trackTitle>
					<trackNumber>1.</trackNumber>
					<trackTime>
						<minute>&#45; 6 &#58;</minute>
						<seconds>01</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Excuse Me Mr</trackTitle>
					<trackNumber>2.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>54</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Alone</trackTitle>
					<trackNumber>3.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>01</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Sexual Healing</trackTitle>
					<trackNumber>4.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>14</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Woman In You</trackTitle>
					<trackNumber>5.</trackNumber>
					<trackTime>
						<minute>&#45; 8 &#58;</minute>
						<seconds>00</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Ground On Down</trackTitle>
					<trackNumber>6.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>39</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Steal My Kisses</trackTitle>
					<trackNumber>7.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>15</seconds>
					</trackTime>
				</track>
					<track>
					<trackTitle>Burn One Down</trackTitle>
					<trackNumber>8.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>53</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Mama&#39;s Got A Girlfriend Now</trackTitle>
					<trackNumber>9.</trackNumber>
					<trackTime>
						<minute>&#45; 2 &#58;</minute>
						<seconds>53</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Welcome To The Cruel World</trackTitle>
					<trackNumber>10.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>52</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Forgiven</trackTitle>
					<trackNumber>11.</trackNumber>
					<trackTime>
						<minute>&#45; 9 &#58;</minute>
						<seconds>26</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Faded&#47;Whole Lotta Love</trackTitle>
					<trackNumber>12.</trackNumber>
					<trackTime>
						<minute>&#45; 10 &#58;</minute>
						<seconds>45</seconds>
					</trackTime>
				</track>
		</diskOne>
		<diskTwo>
			<title>Live From Mars</title>
			<artist>Ben Harper</artist>
			<label> Virgin Records US</label>
			<track>
					<trackTitle>Waiting On An Angel</trackTitle>
					<trackNumber>1.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>27</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Rose From My Friends</trackTitle>
					<trackNumber>2.</trackNumber>
					<trackTime>
						<minute>&#45; 5 &#58;</minute>
						<seconds>36</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Power Of The Gospel</trackTitle>
					<trackNumber>3.</trackNumber>
					<trackTime>
						<minute>&#45; 6 &#58;</minute>
						<seconds>49</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Pleasure And Pain</trackTitle>
					<trackNumber>4.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>29</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Please Bleed</trackTitle>
					<trackNumber>5.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>56</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>The Drugs Don&#39;t Work</trackTitle>
					<trackNumber>6.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>37</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>The Lord&#39;s Arms</trackTitle>
					<trackNumber>7.</trackNumber>
					<trackTime>
						<minute>&#45; 3 &#58;</minute>
						<seconds>15</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Not Fire &#44; Not Ice</trackTitle>
					<trackNumber>8.</trackNumber>
					<trackTime>
						<minute>&#45; 3 &#58;</minute>
						<seconds>45</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Beloved One</trackTitle>
					<trackNumber>9.</trackNumber>
					<trackTime>
						<minute>&#45; 3 &#58;</minute>
						<seconds>47</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Number Three</trackTitle>
					<trackNumber>10.</trackNumber>
					<trackTime>
						<minute>&#45; 2 &#58;</minute>
						<seconds>31</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Walk Away</trackTitle>
					<trackNumber>11.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>35</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Another Lonely Day</trackTitle>
					<trackNumber>12.</trackNumber>
					<trackTime>
						<minute>&#45; 4 &#58;</minute>
						<seconds>48</seconds>
					</trackTime>
				</track>
				<track>
					<trackTitle>Like A King&#47;I&#39;ll Rise (Medley)</trackTitle>
					<trackNumber>13.</trackNumber>
					<trackTime>
						<minute>&#45; 10 &#58;</minute>
						<seconds>02</seconds>
					</trackTime>
				</track>
		</diskTwo>
	</album>
</cdCollection>
 

1 个答案:

答案 0 :(得分:0)

重新判断结束标记 - 听起来像你错过了>个字符。查看文件第156行或其附近的</album>标记,并找出错误输入方式。

重新验证错误:您已宣布

<!ELEMENT disk(#PCDATA)>

您已告诉它<disk>应仅包含未标记的文字。你想要的可能是

<!ELEMENT disk(#PCDATA | track)>

或者甚至

<!ELEMENT disk(track)>

如果<track>元素以外的唯一内容将格式化空格。

请参阅http://www.w3.org/TR/REC-xml/#sec-mixed-content以及描述DTD元素声明的相关章节或一个优秀的XML DTD教程。

(您可能需要考虑从DTD迁移到XML Schema,这是描述文档预期结构的更强大的方式......除非您需要保持与老年解析器的兼容性。)