Copyright © 1995-2005 Opera Software AS. All rights reserved.
This file is part of the Opera web browser. It may not be distributed
under any circumstances.
$Id$
"XML names" are the names of elements and attributes in XML documents. They can be represented in a couple of different ways:
The "qualified name" form is mostly only used while parsing (either
while parsing the XML source or while handling attributes whose
values are qualified names.) Since it doesn't contain enough
information to have any real meaning, it shouldn't be used directly.
In particular: one should never assume that a namespace prefix
has any particular meaning unless that namespace prefix has been
declared (the namespace prefixes
xml
and
xmlns
are of course exempt from this rule, they always have the same
meaning.
The "expanded name" form should be used when only the meaning of the name is interesting, not how it was expressed in the XML source. This is usually the case when one parses XML.
The "complete name" form should be used when both the meaning of the name and how it was expressed in the XML source is interesting. Examples of when this is the case are when parsing documents that will be accessible from DOM (the prefix must be known in order to implement the property Node.prefix) and when parsing XSLT (literal result elements, when instantiated, will be created with the same prefix as was used in the XSLT stylesheet source.)
Four classes are used to represent expanded names and complete names: XMLExpandedName, XMLExpandedNameN, XMLCompleteName and XMLCompleteNameN. The classes XMLExpandedName and XMLCompleteName deal with null-terminated strings and can optionally own the string values while the classes XMLExpandedNameN and XMLCompleteNameN deal with unterminated strings with explicit length.
The N-versions are useful since they can be constructed from a qualified name without memory allocation or copying. To create a null-terminated version of the name one can first create an explicit length version from a qualified name and then initialize the null-terminated version from it. When constructing expanded or complete names from qualified names one of course need to resolve prefixes into namespace URIs using the namespace declarations in scope. See the XML namespaces document for more details on how to do that.