XML technologies / XML / Python & XML / Getting started with Python and XML / The XML specifications
(Excerpt from “Python & XML” by Christopher A. Jones & Fred L. Drake, Jr.)
The press often announces that XML “now supports” some industry-specific application. The resulting article is often confusing, offering a morsel about an industry consortium publishing a new specification for an XML-based language to support data interoperability within its industry. With our technical understanding, we generally see that it does not apply to our own work, or that the specification is still too much of a draft to be useful. Our managers will probably agree, or have their private reasons for disagreeing. Higher up the corporate ladder, however, confusion about XML often increases. This sometimes leads to calls to adopt XML, all too often with a list of extra specifications not intended to work together, or to the conclusion that XML is still too immature for serious use.
We therefore need to consider what we can work with while meeting these criteria:
It must make technical sense for our application.
It must be defined well enough to implement.
We must be able to explain and justify it at least to our immediate manager.
Senior management must not panic.
As technically minded people, we may have to ignore the last point; this book certainly does not cover it. Indeed, most of this cannot really be addressed in technical material. Many specifications exist at different stages of maturity, most specific to one industry or another. We can, however, identify the fundamental specifications you will need regardless of industry or other requirements.
The XML 1.0 Recommendation
The XML specification itself is a document created and maintained by the W3C. At the time of writing, the current version is Extensible Markup Language (XML) 1.0 (Second Edition). (The second edition differs from the first only in textual corrections and clarifications; the specification itself is stable.)
(data2type editorial note: The current W3C XML standard is XML 1.1, as of February 2015.)
XML is not itself a markup language but a metalanguage for defining particular markup languages. In this respect it inherited much from SGML. The specification covers five aspects of markup languages:
the set of structural forms that can be marked up
the particular syntax of markup components
a schema language for defining particular languages
a definition of validity constraints
minimum requirements for processing tools
Unlike SGML, XML can be used without formally defining a particular markup language in any way. Whether that is useful for your applications is another question, but it has significantly accelerated acceptance of XML technologies in some developer communities. This may be because entry into the XML universe is inexpensive. You can begin without knowing some of the specification’s esoteric parts, and prototype development can start without enormous amounts of advance planning.
XML basics introduces the most frequently used parts of the specification and examines those most important to this book’s readers in greater detail. If particular details interest you, take the time to read the relevant sections of the specification. Although sometimes a little cumbersome, it is generally not especially difficult to read.
Namespaces in XML
Although XML 1.0 defines particular syntactic aspects of XML and a way to create document types, it does not explain how to combine components of several document types. The recommendation Namespaces in XML, hereafter called namespaces, covers the syntactic and structural mechanics of combining structural components from different specifications, but says little about the meaning of the resulting combinations. For that it refers to specifications not yet written when the recommendation was published.
This recommendation further restricts the syntax of conforming documents. It lets a document identify the source of each element or attribute by placing it in a namespace. Each namespace encompasses element and attribute definitions. How these are defined is outside this specification, so validation of an arbitrary document using namespaces is not entirely settled. XML 1.0 can define a document type with some namespace support, but such a schema loses much of the namespace specification’s flexibility. It must, for example, prescribe the prefixes bound to each namespace, whereas namespaces allow the document, rather than the schema, to choose prefixes. Alternative schema languages with better namespace support have already been defined; they are briefly discussed in XML basics.
XML as a foundation
Like its predecessor SGML, XML lets you define languages meeting your application’s requirements. By specifying the exact syntax of grammatical elements, such as the characters marking an element’s beginning, it reduces the effort of writing conforming software. Components needed to extract application data from XML are much smaller and easier to use than their SGML equivalents.
The additional specifications so eagerly discussed by the trade press whenever a new version appears generally define new languages from the basic XML and namespace recommendations. They are often documented through schemas or committee-produced documents describing intended usage. Every industry has at least one consortium partly concerned with data exchange among its various participants—doctors, pharmacies and hospitals in healthcare, for example—so many standards take this form. Many XML standards derive from earlier attempts to use older industry-specific SGML languages; many others are new.
Copyright © 2002 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “Python & XML” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de