0

では、XML プロジェクトの名前空間を宣言し、DTD を使用して検証する必要があります。私の友人や教授もそう言っていますが、「要素「st:course」の接頭辞「st」はバインドされていません」というエラーメッセージが表示され続けます。それは私に縛られているように見えます、私は何が欠けていますか?

XML:

<?xml-namespace ns="http://www.student_courses/data/st/ns" prefix="st"?>
<?xml-namespace ns="http://www.student_courses/data/cr/ns" prefix="cr"?>
<!DOCTYPE students SYSTEM "student_courses.dtd">

<students>
<student number="a101"> <!-- number is an ID, required-->
<Name title="Mr.">John Doe</Name><!-- title values can be 'Mr.','Ms.','Dr.'-->
<st:course xmlns= "http://www.student_courses/data/st/ns" section="01">WEB 225</st:course>
<enrolled>22</enrolled>

<content>
<level class="Intro"></level>
<comments>Great course</comments><!-- An optional element -->
<book isbn="">XML</book><!--isbn is required, but the element is optional -->
</content>
</student>

<student number="a102"><!-- number is an ID, required-->
<Name title="Dr.">Jane Williams</Name>
<st:course xmlns= "http://www.student_courses/data/st/ns">WEB 325</st:course>
<enrolled>22</enrolled>

<content>
<level class="Adv."></level>
</content>
</student>

<student number="a103"><!-- number is an ID, required-->
<Name title="Ms.">Jane Doe</Name><!-- title values can be 'Mr.','Ms.','Dr.'-->
<st:course xmlns= "http://www.student_courses/data/st/ns" section="03">WEB  440</st:course>
<enrolled>12</enrolled>

<content>
<level class="Adv."></level>
<comments>Great course</comments><!-- An optional element -->
</content>
</student>

<courses>

<cr:course xmlns = "http://www.student_courses/data/cr/ns" id="WEB225">
<name>Web Development II</name>
<offered>Spring</offered>
<pre_reqs>WEB125</pre_reqs>
</cr:course>

<cr:course xmlns = "http://www.student_courses/data/cr/ns" id="WEB125">
<name>Web Development I</name>
<offered>Fall</offered>
</cr:course>

<cr:course xmlns = "http://www.student_courses/data/cr/ns" id="WEB325">
<name>Client-Side Scripting</name>
<offered>Spring</offered>
<offered>Fall</offered>
<pre_reqs>WEB225</pre_reqs>
</cr:course>

</courses>

</students>

そして、ここに私のDTDがあります:

<!ELEMENT students (student+)>
<!ELEMENT student (Name+,st:course+,enrolled+,content+)>
<!ATTLIST student number ID #REQUIRED>
<!ELEMENT Name (#PCDATA)>
<!ATTLIST Name title (Mr. | Ms. | Dr.) #IMPLIED>
<!ELEMENT st:course (#PCDATA)>
<!ATTLIST st:course xmlns CDATA #FIXED "http://www.student_courses/data/st/ns"> 
<!ATTLIST st:course section CDATA #IMPLIED>
<!ELEMENT enrolled (#PCDATA)>
<!ELEMENT content (level+, comments*, book?)>
<!ELEMENT level (#PCDATA)>
<!ATTLIST level class (Intro | Adv.) #IMPLIED>
<!ELEMENT comments (#PCDATA)> 
<!ELEMENT book (#PCDATA)>
<!ATTLIST book isbn CDATA #REQUIRED>
<!ELEMENT courses (cr:course+)>
<!ELEMENT cr:course (name+,offered+,pre_reqs*)>
<!ATTLIST cr:course xmlns:cr CDATA #FIXED "http://www.student_courses/data/cr/ns"> 
<!ATTLIST cr:course id CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT offered (#PCDATA)>
<!ELEMENT pre_reqs (#PCDATA)>

みんなありがとう、この場所が大好き!!

-K

4

1 に答える 1