There is a recurring mistake throughout this chapter, the result of my having misread production 23 of the XML 1.0 specification. I had read it as making the version info optional, producing the frequently-seen <?xml?>, but in fact it is required. This means that the minimal declaration shown at the bottom of page 7 is incorrect - it should read
<?xml version="1.0"?>. The first full paragraph at the top of page 8 is incorrect in saying that all parameters are optional, as version is required. The first declaration at the top of page 9, which is described as legal, is not. It should read
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>. (Thanks to Edd Dumbill.)
I also omitted one variant of the DOCTYPE declaration, which omits both the internal and external DTD subsets. DOCTYPEs may identify only the root element, and nothing else:
The root element name is required, but none of the other possible contents are necessary. It isn't a remarkably useful syntax, but it may serve as a convenient placeholder.
The second-to-last paragraph in the chapter, describing the rules for attributes without prefixes, is not quite accurate, though the recommended action will produce the correct results. Attributes without prefixes may or may not be considered to 'inherit' the namespace of the element holding them, depending on the application. This recent post from Tim Bray explains the logic behind this approach. If you want your attributes to be recognized reliably across any application, you'll be best off applying prefixes to attribute names. 'Global' attributes, a poorly defined category that roughly corresponds to the kind of attributes used by XLink, should always be prefixed.
On page 73, the description of attribute whitespace normalization is oversimplified. Attributes defined as CDATA - and all attributes in documents without a DTD, or with a DTD that hasn't been retrieved by a non-validating parser - are treated differently. All tabs, spaces, CRLF combinations, CR characters, and LF characters are converted to spaces, but no trimming takes place.
On page 76, the a-dtype attribute declaration for the bill element should probably be declared as #FIXED for consistency. (Thanks to Tom Cargill.)
The discussion on page 203-205 refers to a situation that may be avoidable if you are using a parser that supports the DOM Level 2 Core's DocumentType Extended Interface. (Level 1 doesn't provide enough information.) Your application will have to check the details of the document type definition for each document as it is parsed to verify that it in fact conforms to the expected document type definition. You'll still need to document this requirement for XML applications where this level of conformance is required. (Thanks to Tom Cargill.)
More recently, Mark Wutka has developed a DTD parser that might also be helpful in these cases.
Return to description