XML technologies / XML / Python & XML / XML basics / Physical structures

(Excerpt from "Python & XML" by Christopher A. Jones & Fred L. Drake, Jr.)

XML text is stored in entities. Entities are defined in various ways, usually by a filename or URI. There are no restrictions here, however, and many systems use alternative ways of storing entities; many reside quite happily in databases, for example. Many XML documents contain more than one entity. Perhaps the most common case is that the document resides in one entity and its type definition in another. As documents grow, they often contain more entities. This is probably more common in document-oriented XML applications than in data communication applications.

Entities normally have names in one or more global namespaces. XML requires entities to be assigned system identifiers, which are always URIs. The term comes from the SGML community, where system identifiers were used to specify storage locations in a syntax understood by the tools in use. Another global namespace is shared with the SGML world. The identifiers in this space are called formal public identifiers (formal public identifiers or FPIs). Use of this namespace is very limited in the XML world because it cannot always be readily mapped to URLs that provide access to arbitrary resources; there are ways to do so, however. FPIs are used occasionally, and the PyXML package provides some support for them.

Entities serve several purposes in XML:

Document entities

Whatever the application, every document starts somewhere. XML also guarantees that documents end in the same entity. The entity containing the start of the document is called the document entity. It is of interest because it is the only entity allowed to be completely anonymous. An application can pass the contents of an entity directly to the XML parser so it can process it without having to extract the text from a file or another local or remote data source.

External entities

Other physical storage units contributing to a document are external entities. They can contain all or part of the document’s type specification, but may also contain document content. Although external entities are defined by their system identifiers and formal public identifiers, most are given local names to make them easier to reference.

External DTD subset

If a document contains a document type declaration specifying an external document type subset, that subset is supplied in an entity. This entity is special in that it has no local name, but is otherwise an ordinary external entity.

Associated resources

Some documents refer to other documents without making them part of themselves. Whether these external resources are actually entities is not always clear when they are not referenced by a name defined in an entity declaration. A typical example is resources identified by a URI in the attribute href of the element a in HTML. They are not referenced by a named entity, and when the reference is established it is not always clear exactly what the associated resource will contain. The fact that the external resource is identified as the target of a link matters to the document establishing that link.

  

 

 

 

back to top