Web Resources

Answers to Self Review Exercises

Sections 19.119.6

19.1

a, b, d, f. [Choice c is incorrect because it contains a space. Choice e is incorrect because the first character is a number.]

19.2

a) True. b) 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. c) True. d) True. e) False. XML does support namespaces. f) 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.). g) False. XML reserved characters include the ampersand (&), the left-angle bracket (<) and the right-angle bracket (>), but not # and $.

19.3

a) Namespaces. b) Processing instructions. c) MSXML. d) xsl:output. e) schema. f) xsl:stylesheet. g) xsl:for-each.

19.4

a) False. XML is case sensitive. b) True. c) False. DTDs use EBNF grammar, which is not XML syntax. d) 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.

 
19.5

May 5 2005 .  

Sections 19.719.10

19.6

"text/xsl" href = "wap.xsl"?>

19.7

a) parent. b) sibling. c)abstract.

19.8

/letter/contact.

19.9

Method Select receives as an argument either an XPathExpression or a string containing an XPathExpression, to select nodes referenced by the navigator.

Exercises

Sections 19.119.6

19.10

(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: 260 calories, 100 fat calories, 11 grams of fat, 2 grams of saturated fat, 5 milligrams of cholesterol, 210 milligrams of sodium, 36 grams of total carbohydrates, 2 grams of fiber, 15 grams of sugars 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.]

19.11

(Nutrition Information XML Schema) Write an XML Schema document (nuTRition.xsd) specifying the structure of the XML document created in Exercise 19.10.

Sections 19.719.10

19.12

(Nutrition Information XSL Style Sheet) Write an XSL style sheet for your solution to Exercise 19.10 that displays the nutritional facts in an XHTML table. Modify Fig. 19.30 (transformTest.cs) to output an XHTML file, nutrition.html. Render nutrition.html in a Web browser.

19.13

(Validation Against Multiple Schemas) Alter Fig. 19.28 (ValidationTest.cs) to validate a selected XML file against multiple schemasbook.xsd and nutrition.xsd (Exercise 19.11). Allow the user to select either book.xml, fail.xml or nuTRition.xml (Exercise 19.10). [Hint: You can add multiple schema documents to an XmlSchemaSet.]

19.14

(XmlReaderTest Modification) Modify XmlReaderTest (Fig. 19.22) to display article.xml (Fig. 19.2) in a TReeView instead of in a TextBox.

19.15

(Sorting XSLT Modification) Modify Fig. 19.19 (sorting.xsl) to sort by the number of pages rather than by chapter number. Save the modified document as sorting_byPage.xsl.

19.16

(transformTest Modification) Modify TRansformTest (Fig. 19.30) to use sorting.xml (Fig. 19.18), sorting.xsl (Fig. 19.19) and sorting_byPage.xsl (from Exercise 19.15). Display the result of transforming sorting.xml into two XHTML files, sorting_byChapter.html and sorting_byPage.html. [Hint: Remove the xml:stylesheet processing instruction from line 5 of sorting.xml before attempting to transform the file programmatically.]

Database, SQL and ADO NET

Категории