XML Elements of Style - Errata

Chapter 2

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:

<!DOCTYPE rootElement>

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.

Chapter 3

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.

Chapter 10

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.

Chapter 11

On page 76, the a-dtype attribute declaration for the bill element should probably be declared as #FIXED for consistency. (Thanks to Tom Cargill.)

Chapter 25

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