Options in a DTD

天大地大妈咪最大 提交于 2019-12-14 03:22:42

问题


I am editing my last post with a whole new question about the same assignment. I ended up submitting my assignment and the professor said it had a lot of errors. So I have been working on it for the past few weeks and am stuck in my current situation. My DTD comes up with absolutely no errors. However, my XML document comes up with errors to every element that I had to make options for, For example genre, movie rating, and viewer rating.

The errors are:

Attribute "genre" is required and must be specified for element type "movie".

Attribute "movie_rating" is required and must be specified for element type "movie".

Attribute "viewer_rating" is required and must be specified for element type "movie".

My DTD is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->



<!ELEMENT movies (movie*)>  
<!ELEMENT movie (title, genre, movie_rating, viewer_rating, summary, year, director+, runtime, studio, actors+)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ATTLIST movie genre (action|comedy|drama|family|foreign|horror|musical|other) #REQUIRED>
<!ELEMENT movie_rating (#PCDATA)>
<!ATTLIST movie movie_rating (G|PG|PG-13|R|NC-17)  #REQUIRED>
<!ELEMENT viewer_rating (#PCDATA)>
<!ATTLIST movie viewer_rating (0 | 1 | 2 | 3 | 4 | 5) #REQUIRED>
<!ELEMENT summary (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT director (#PCDATA)>
<!ELEMENT runtime (#PCDATA)>
<!ELEMENT studio (#PCDATA)>
<!ELEMENT actors (#PCDATA)>
<!ATTLIST actors id CDATA #REQUIRED>

My XML is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 13 10:41:29 AST 2014 -->

<!DOCTYPE movies SYSTEM "MoviesDTD.dtd">


<movies>
<movie>   
<title>Transcendence</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>4</viewer_rating>  
<summary>In Transcendence, Dr. Will Carter is an expert in Artificial Intelligence, and initially is excited by the promises it offers the world at large. Unfortunately, when he is diagnosed with a terminal disease, his motives change and he becomes focused on his own transcendence. Now he is racing against his own mortality as extremists attempt to stop him. Max Waters is his best friend and a researcher as well, and is torn between helping his friend and what that will mean for society at large.</summary>  
<year>2014</year>  
<director>Wall Pfistery</director>  
<runtime>119</runtime>  
<studio>Warner Bros.</studio>
<actors id="1000">Johnny Depp</actors>
<actors id="1001">Paul Bettany</actors>
<actors id="1002">Rebecca Hall</actors>  
</movie>

<movie>   
<title>Edge of Tomorrow</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>4</viewer_rating>  
<summary>Lieutenant Colonel Bill Cage is a skilled tactician who has honed his abilities through his experiences as a soldier. However, there is still much he can learn, and soon he is going to get his chance. It's the last day of a major battle on a futuristic Earth that is overrun with aliens. This battle may determine the fate of humanity. Bill is determined to fight it out to the end, but just what is that end? He is startled to discover that this day will not end for him. He is caught in a time loop. He wants to get out, but in the meantime, he is becoming a soldier of unsurpassed skill. What will it take to break free and win the battle?</summary>  
<year>2014</year>  
<director>Doug Liman</director>  
<runtime>113</runtime>  
<studio>Warner Bros.</studio>
<actors id="1003">Emily Blunt</actors>
<actors id="1004">Tom Cruise</actors>
<actors id="1005">Charlotte Riley</actors> 
</movie>

<movie>   
<title>22 Jump Street</title>  
<genre>Action</genre>  
<movie_rating>R</movie_rating>  
<viewer_rating>4</viewer_rating>  
<summary>Schmidt and Jenko Mike barely made it through high school the first time. Thanks to police program called 21 Jump Street, they went back a second time. The officers went undercover as high school students and made the school safe by taking down a huge drug operation. Since the program was so successful, more funding was made available and the operation moved across the street to 22 Jump Street. Schmidt and Jenko have been assigned to go to college. The guys get their own dorm, play college sports (well, kind of), and they get to party (they are college students, right?) all while investigating illegal drug activity.</summary>  
<year>2014</year>  
<director>Phil Lord, Chris Miller</director>  
<runtime>112</runtime>  
<studio>Columbia Pictures</studio>
<actors id="1006">Jonah Hill</actors>
<actors id="1007">Channing Tatum</actors>
<actors id="1008">Ice Cube</actors>  
</movie>

<movie>   
<title>The Matrix</title>  
<genre>Action</genre>  
<movie_rating>R</movie_rating>  
<viewer_rating>5</viewer_rating>  
<summary>A programmer by day and a computer hacker by night, Thomas A. Anderson lives two distinct lives. His night persona, Neo, has always harbored questions about the true nature of reality. Neo finds out that his suspicions were correct when he is suddenly targeted by the police after Morpheus, a legendary hacker, makes contact. Morpheus shows Neo the real world, a wasteland where humanity is captive to machines that live off of human electrochemical energy and body heat. Thomas Anderson's world, our world, is just an artificial reality known as the Matrix used to imprison the minds of captive humans. Neo joins the rebels in in their fight to defeat the machines. Within the Matrix, Neo must battle agents, powerful computer programs dedicated to eliminating the rebels.</summary>  
<year>1999</year>  
<director>Andy Wachowski, Lana Wachowski</director>  
<runtime>136</runtime>  
<studio>Warner Bros.</studio>
<actors id="1009">Keanu Reeves</actors>
<actors id="1010">Laurence Fishburne</actors>
<actors id="1011">Carrie-Anne Moss</actors> 
</movie>

<movie>   
<title>Star Trek Into Darkness</title>  
<genre>Science Fiction</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>4</viewer_rating>
<summary>The Enterprise crew is asked to return home to take part in a battle. When they return home, they soon discover an evil force among their group has destroyed their fleet and its symbolism. Captain Kirk has his own personal agenda to take care of, and he heads a search to catch the villain who was responsible for such devastation. They enter into a war to try to uncover the villain who caused this extreme damage. Lives will be forever changed, and something must be given up for Kirk's crew, otherwise known as his family.</summary>  
<year>2013</year>  
<director>J.J. Abrams</director>  
<runtime>136</runtime>  
<studio>Paramount Pictures</studio>
<actors id="1012">Chris Pine</actors>
<actors id="1013">Zachary Quinto</actors>
<actors id="1014">Zoe Saldana</actors> 
</movie>

<movie>   
<title>Resident Evil</title>  
<genre>Action</genre>  
<movie_rating>R</movie_rating>  
<viewer_rating>3</viewer_rating>
<summary>In Umbrella Corporation's underground genetics experimentation and bioweapon research facility known as The Hive, a thief steals virus samples and purposely drops one during his escape. The Hive's administrator, an AI called the Red Queen, seals off the complex and kills everyone in an attempt to stop the virus's spread. She doesn't report the reason for her actions to the company. Believing that she has become homicidal, Umbrella dispatches a security force to determine what happened and shut her down. In the above-ground mansion that hides an emergency entrance, they find one of their own suffering from amnesia: Alice. Alice's mind contains many secrets. Yet, before she can remember, the team discovers one on their own: The Red Queen didn't permanently kill anyone.</summary>  
<year>2002</year>  
<director>Paul W.S. Anderson</director>  
<runtime>100</runtime>  
<studio>Constantin Film</studio>
<actors id="1015">Milla Jovovich</actors>
<actors id="1016">Michelle Rodriguez</actors>
<actors id="1017">Eric Mabius</actors> 
</movie>

<movie>   
<title>Divergent</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>4</viewer_rating>
<summary>Generations after a catastrophic event destroys the city of Chicago, the survivors have divided themselves into different factions based on personality type to prevent future discord. Beatrice Prior finds herself torn when the day comes for her to choose a faction of her own. Her family expects her to select the selfless Abnegation group that focuses on service to others, but she secretly yearns for the adventure that other factions could bring her. Meanwhile, a sinister plot brews among faction leaders that could destroy the city's status quo forever.</summary>  
<year>2014</year>  
<director>Neil Burger</director>  
<runtime>143</runtime>  
<studio>Red Wagon Entertainment</studio>
<actors id="1018">Shailene Woodley</actors>
<actors id="1019">Kate Winslet</actors>
<actors id="1020">Miles Teller</actors> 
</movie>

<movie>   
<title>X-Men: Days of Future Past</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>5</viewer_rating>  
<summary>Forming an alliance, Professor Xavier and Magneto send Wolverine back in time in an attempt to change circumstances which would lead to the demise of the mutant race and, possibly, the human race as we'll. The current Wolverine works with his younger self and younger versions of the X-men to change the past and protect the present status. Traveling between the time periods explores the past histories of some of our favorite X-men characters and what forces turned the into the people they are today.</summary>  
<year>2014</year>  
<director>Bryan Singer</director>  
<runtime>131</runtime>  
<studio>20th Century Fox</studio>
<actors id="1021">Patrick Stewart</actors>
<actors id="1022">James McAvoy</actors>
<actors id="1023">Michael Fassbender</actors> 
</movie>

<movie>   
<title>Transformers Age Of Extinction</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>3</viewer_rating>  
<summary>Set three years after the previous installment, the focus revolves around Cade Yeager and his daughter, Tessa. Together, the duo make a powerful discovery that brings them into the world of the Autobots and the Decepticons. Harold Attinger, a paranoid public servant, is also after them, but his motives are unclear. The humans must find a way to resolve the conflict with the machines. Cade, a mechanic by trade, assists the Autobots by performing crucial repairs. Together, they go against the Decepticons in a battle of explosions and twisted metal.</summary>  
<year>2014</year>  
<director>Michael Bay</director>  
<runtime>165</runtime>  
<studio>Paramount Pictures</studio>
<actors id="1024">Nicola Peltz</actors>
<actors id="1025">Mark Wahlberg</actors>
<actors id="1026">ZStanley Tucci</actors> 
</movie>

<movie>   
<title>Need for Speed</title>  
<genre>Action</genre>  
<movie_rating>PG-13</movie_rating>  
<viewer_rating>4</viewer_rating>  
<summary>Need for Speed is the epic saga of Tobey Marshall, a working-class mechanic and highly skilled muscle car enthusiast, on his race for revenge. In a last-ditch effort to redeem his failing garage, Tobey pairs with pompous Dino Brewster, a highly successful NASCAR driver. After an unsanctioned race goes awry, Dino frames Tobey for manslaughter. Fresh out of prison two years later, Tobey is keen to avenge himself by defeating Dino in the De Leon – underground racing's biggest race. Avoiding cops and bounty hunters along his entire journey and backed by his loyal crew, Tobey races across the country defying odds and proving to the supercar world that there's still hope for the underdog.</summary>  
<year>2014</year>  
<director>Scott Waugh</director>  
<runtime>102</runtime>  
<studio>Touchstone Pictures</studio>
<actors id="1027">Aaron Paul</actors>
<actors id="1028">Dominic Cooper</actors>
<actors id="1029">Imogen Poots</actors> 
</movie>
</movies>

回答1:


This is exactly the same situation as in your previous question - the DTD should not itself contain a <!DOCTYPE movies [ line.

The DOCTYPE is used in an XML document to tell the parser which DTD to use, it's not part of the DTD.



来源:https://stackoverflow.com/questions/24745056/options-in-a-dtd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!