简体   繁体   English

XML对DTD无效(相同的ID)

[英]XML not valid to DTD (same ID)

So I've written this xml document but I fail to write an DTD in which it is valid to. 因此,我已经编写了这个xml文档,但是未能编写对其有效的DTD。 I know that the problem is that the ID (Student name "DB") occurs twice in the document and therefor it is not uniqe. 我知道问题在于ID(学生名“ DB”)在文档中出现两次,因此它不是唯一的。 But how can I change my DTD to allow the ID to do that? 但是,如何更改我的DTD以允许ID做到这一点? I'm really green in this area so this might be a stupid question. 我在这方面真的很绿,所以这可能是一个愚蠢的问题。

<?xml version="1.0" standalone="no"?>
<!DOCTYPE COURSES [
<!ELEMENT COURSES (COURSE*)>
<!ELEMENT COURSE (PROFESSOR+, STUDENT+)>
<!ATTLIST COURSE name ID #REQUIRED>
<!ELEMENT PROFESSOR EMPTY>
<!ATTLIST PROFESSOR name ID #REQUIRED>
<!ELEMENT STUDENT (NOTES*)>
<!ATTLIST STUDENT name ID #REQUIRED>
<!ATTLIST STUDENT enrolled IDREFS #IMPLIED>
<!ELEMENT NOTES (#PCDATA)>
]>
<COURSES>
<COURSE name="Architecture">
<PROFESSOR name="Andersson"/>
<STUDENT name="JB" enrolled="Architecture">
<NOTES>2nd BaSC</NOTES>
</STUDENT>
<STUDENT name="DB" enrolled="Architecture"/>
</COURSE>
<COURSE name="Mechanics">
<PROFESSOR name="Geerts"/>
<STUDENT name="DB" enrolled="Mechanics"/>
</COURSE>
</COURSES>

Use this link for validate your dtd/xml http://validator.w3.org/check , this website is the oficcial organization for standard this lengage. 使用此链接来验证您的dtd / xml http://validator.w3.org/check ,该网站是标准的官方组织。

<STUDENT name="DB" enrolled="Architecture"/>

Is replied. 被答复。

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

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