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

  1. a) yearBorn : Valid
  2. b) year.Born : Valid
  3. c) year Born : Not valid
  4. d) year-Born1 : Valid
  5. e) 2_year_born : Invalid
  6. f) _year_born_ : Valid

15.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 the programmer can use any valid name but should avoid ones that begin with the reserved word xml.
  7. The pound character(#), dollar sign($), ampersand(&) and angle brackets(< and >) are examples of XML reserved characters. False : XML reserved characters include the ampersand (&), the left angle bracket (<) and the right angle bracket (>), but not # and $.
  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.
  10. True
  11. DTDs are written using an XML vocabulary.False : DTDs uses EBNF.
  12. 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.

15.3 Fill in the blanks for 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 a XSL document.
  7. XSL element xsl:for-each selects specfic XML elements using repetition.
  8. Nodes that contain other nodes are called parent nodes.
  9. Nodes that are peers are called sibling nodes.

15.4 In Fig. 15.2, we subdivided the author element into more detailed pieces. How might you subdivide the date element? Use the date May 5, 2005, as an example.

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

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

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

15.6 Write an XPath expression that locates contact nodes in letter.xml.

  1. /letter/contact

15.7 (Nutrition Information XML Document) Create an XML document that marks up the nutrition facts for a package of Grandma White's cookies. A package of cookies has a serving size of 1 package and the following nutritional value per serving:

  1. 260 calories
  2. 100 fat calories
  3. 11 grams of fat
  4. 2 grams of saturated fat
  5. 5 milligrams of cholesterol
  6. 210 milligrams of sodium
  7. 36 grams of total carbohydrates
  8. 2 grams of fiber
  9. 15 grams of sugars
  10. and 5 grams of protein

Name this document nutrition.xml. Load the XML document into Internet Explorer.
[Hint: Your markup should contain elements describing the product name, serving size/amount, calories, sodium, cholesterol, proteins, etc. Mark up each nutrition fact/ingredient listed above.]

  1. nutrition.xlm

15.8 (Nutrition Information XML Schema) Write an XML Schema document (nutrition.xsd) specifying the structure of the XML document created in Exercise 15.7

  1. untition.xsd