Q What is the difference between well-formed and valid XML?
A Well-formed XML is syntactically perfectit conforms with the basic rules for all XML documents. Valid XML is well-formed and it complies with the constraints imposed by an associated structural schema.
Q What are some of the constraints that a programmer can impose by creating a schema for an XML document?
A A schema enforces the name and structure of the root element, including specification of all of the child elements. The programmer can ensure the exact order and quantity of each element and predetermine which elements are required or optional. The schema can dictate which elements have attributes and determine the acceptable values for the attributes, along with any defaults. As in the case of elements, attributes can be made to be required or optional.
Q What schema languages are in use by XML document authors?
A Several forms of schema languages are in use currently. The Document Type Definition (DTD) language has survived from the days of SGML and will be covered tomorrow. Microsoft has released the XML Data Reduced (XDR) language as a schema dialect of XML (to be covered on Day 5). The W3C is working to coalesce the XML dialects of schemata into a single working form called the XML Schema Definition (XSD) language, which will be presented on Day 6.
Q Is it possible to use schemata to control data types in an XML data stream?
A XDR and XSD have ready means for constraining data types. The DTD approach can't handle data type rules as easily. Programmers determined early in the life cycle of XML evolution that data type validation was essential for XML to be used in e-commerce and e-business transaction models.
Q What is the difference between document structure and data structure?
A Document structure provides a reader with an organized means of quickly following the path of information delivery desired by the author. Data structures reflect the content and provide computer applications with a roadmap, not unlike a keyword index, to the data stored in various containers and sub-containers within the context of the whole document.
Q What is a parser and what does it have to do with validity?
A A parser is a software application (known by the W3C as an XML processor) that interprets a text document one character at a time. There are two generic types of parsers used with XML. One, a non-validating parser, is only capable of ensuring that a document is well-formed; that is, it satisfies the basic XML rules for syntax. A validating parser ensures that a document is well-formed and then applies the document content or business rule constraints defined by any associated schemata to ensure that the document is also valid.
The exercise is provided so that you can test your knowledge of what you learned today. The answer is in Appendix A.
At the end of Day 2, the exercise called for you to correct a poorly formed XML document and make it well-formed. The document described two albums in a music collection with elements for cd, title, artist, and tracks. You would like to create a valid music collection markup language, which you will refer to as MCML. Based on the well-formed solution to the previous exercise, create a tree diagram for MCML and write down some of the business rules that might be used to enforce validity.