Sams Teach Yourself XML in 21 Days

Sams Teach Yourself XML in 21 Days

By Steven Holzner

Workshop

This workshop tests whether you understand the concepts discussed today. It's a good idea to make sure you can answer these questions before pressing on to tomorrow's work. Answers to the quiz can be found in Appendix A, "Quiz Answers."

Quiz

  1. What keyword do you use in an <!ATTLIST> element to make an attribute optional?
  2. What keyword do you use in an <!ATTLIST> element to make sure an attribute always has the same value?
  3. How can you declare a required name attribute, an optional address attribute, and an optional phone attribute for an element named <friend>? Each of these attributes should hold simple character data.
  4. How can you restrict an attribute named married in an element named <relative> to values of "yes" or "no", making the default "no"?
  5. How can you declare an external unparsed entity named mountains that corresponds to the image file mountains.jpg?

Exercises

  1. Create a new XML document that uses a DTD to declare an optional CDATA attribute named date that holds dates in the form 4/1/05, an attribute called sex that can take the values "male" and "female" only, and a required CDATA name attribute. Test your work by using an online XML validator.
  2. Parameterize the DTD you created in Exercise 1 so that you can include all the attributes created in that exercise by setting a parameter named includer to INCLUDE or exclude them by setting that parameter to IGNORE.

Share ThisShare This

Informit Network