Chapter 14

14.1 Which of the following are valid XML element names? (Select all that apply.)

  1. yearBorn Valid
  2. year.Born Valid
  3. year Born Invalid (space)
  4. year-Born1 Valid
  5. 2_year_born Invalid (first character is number)
  6. _year_born_ Valid

14.2 State which of the following statements are true and which are false. If false, explain why.

  1. XML is a technology for creating markup languages. True.
  2. XML markup is delimited by forward and backward slashes (/ and \). False. In an XML document, markup text is delimited by tags enclosed in angle brackets (< and >) with a forward slash just after the < in the end tag.
  3. All XML start tags must have corresponding end tags. True.
  4. Parsers check an XML document's syntax. True.
  5. XML does not support namespaces. False. XML does support namespaces.
  6. When creating XML elements, document authors must use the set of XML tags provided by the W3C. False. When creating tags, document authors can use any valid name but should avoid ones that begin with the reserved word xml (also XML, Xml, etc.)
  7. The pound character (#), dollar sign ($), ampersand (&) and angle brackets (< and >) are examples of XML reserved characters.
  8. XML is not case sensitive. False. XML is case sensitive.
  9. XML Schemas are better than DTDs, because DTDs lack a way of indicating what specific type of data (e.g., numeric, text) an element can contain and DTDs are not themselves XML documents. True.
  10. DTDs are written using an XML vocabulary. False. DTDs use EBNF grammer, which is not XML syntax.
  11. Schema is a technology for locating information in an XML document. False. XPath is a technology for locating information in an XML document. XML Schema provides a means for type checking XML documents and verifying their validity.

14.3 Fill in the blanks in each of the following:

  1. Namespaces help prevent naming collisions.
  2. Processing instructions embed application-specific information into an XML document.
  3. MSXML is Microsoft's XML parser.
  4. XSL element xsl:output writes a DOCTYPE to the result tree.
  5. XML Schema documents have root element schema.
  6. XSL element xsl:stylesheet is the root element in an XSL document.
  7. XSL element xsl:for-each selects specific XML elements using repetition.
  8. Nodes that contain other nodes are called parent nodes.
  9. Nodes that are peers are called sibling nodes.

14.4 How might you subdivide the date element?

<date>
   <day>5</day>
   <month>May</month>
   <year>2005</year>
</date>

14.5 Write a processing instruction that includes style sheet wap.xsl

<xsl:stylesheet type = "text/xsl" href = "wap.xsl" />

14.6 Write an XPath expression that locates contact nodes in letter.xml (Fig. 14.4).

/letter/contact.

14.7 Create an XML document that marks up the nutrition facts for a package of Grandma White's cookies.

14.8 Write an XML Schema document (nutrition.xsd) specifying the structure of the XML document created in Exercise 14.7.

14.9 Write an XSL style sheet for your solution to Exercise 14.7 that displays the nutritional facts in an XHTML table. Modify Fig. 14.38 to output the results.

Home