XML Namespace - Namespaces in APIs and XML Object Models

Namespaces in APIs and XML Object Models

Different specifications have taken different approaches on how namespace information is presented to applications.

Nearly all programming models allow the name of an element or attribute node to be retrieved as a three-part name: the local name, the namespace prefix, and the namespace URI. Applications should avoid attaching any significance to the choice of prefix, but the information is provided because it can be helpful to human readers. Names are considered equal, if the namespace URI and local name match.

In addition, most models provide some way of determining which namespaces have been declared for a given element. This information is needed because some XML vocabularies allow qualified names (containing namespace prefixes) to appear in the content of elements or attributes, as well as in their names. There are three main ways this information can be provided:

  • As attribute nodes named "xmlns" or "xmlns:xxx", exactly as the namespaces are written in the source XML document. This is the model presented by DOM.
  • As namespace declarations: distinguished from attributes, but corresponding one-to-one with the relevant attributes in the source XML document. This is the model presented by JDOM.
  • As in-scope namespace bindings: in this model, the application is able to determine which namespaces are in scope for any given element, but is not able to determine which elements contain the actual declarations. This is the model used in XPath, XSLT, and XQuery.

Read more about this topic:  XML Namespace

Famous quotes containing the words object and/or models:

    It is the object of learning, not only to satisfy the curiosity and perfect the spirits of ordinary men, but also to advance civilization.
    Woodrow Wilson (1856–1924)

    The greatest and truest models for all orators ... is Demosthenes. One who has not studied deeply and constantly all the great speeches of the great Athenian, is not prepared to speak in public. Only as the constant companion of Demosthenes, Burke, Fox, Canning and Webster, can we hope to become orators.
    Woodrow Wilson (1856–1924)