CIT 597 Quiz 4: DTDs and DOM
Fall 2008, David Matuszek Name_________________________________________
  1. (20 points) Write a DTD fragment to describe the following XML.
        <link>
            <linkText>Dr. Dave's Home page</linkText>
            <url>www.cis.upenn.edu/~matuszek</url>
        </link>

    <!ELEMENT link (linkText, url)>
    <!ELEMENT linkText (#PCDATA)>
    <!ELEMENT url (#PCDATA)>



  2. (20 points) Write an example of the XML that is described by the following DTD fragment.

    <!ATTLIST dog name CDATA #REQUIRED age CDATA #IMPLIED>

    <dog name="fido" age="4"> ... </dog>

    <dog name="Rover"></dog>

  3. (30 points) List the three most important (according to Dave) subclasses of NODE, and for each one, tell what getNodeValue() returns.

    1. Applied to a NODE of type __Element__, getNodeValue() returns _____null______.

    2. Applied to a NODE of type __Text_____, getNodeValue() returns __ the text contents.

    3. Applied to a NODE of type ___Attr___, getNodeValue() returns the value of the attribute.

  4. (10 points) The single most important difference between SAX and DOM is what happens to the XML as it is read in. What does DOM do?

    Creates a tree in memory.


  5. (10 points) NamedNodeMap is not a subinterface of Map. Give a possible explanation for why this is so.

    DOM was not defined specifically for Java, so it uses different operations than Java's Map interface provides.


  6. (10 points) What does it mean to say that an XML file is valid?

    It is well formed and conforms to a DTD (or to some other XML schema).