MIT/GNU Scheme implements XML names in a slightly complex way. Unfortunately, this complexity is a direct consequence of the definition of XML names rather than a mis-feature of this implementation.
The reason that XML names are complex is that XML namespace support, which was added after XML was standardized, is not very well integrated with the core XML definition. The most obvious problem is that names can’t have associated namespaces when they appear in the DTD of a document, even if the body of the document uses them. Consequently, it must be possible to compare non-associated names with associated names.
An XML name consists of two parts: the qname, which is a symbol, possibly including a namespace prefix; and the Uniform Resource Identifier (URI), which identifies an optional namespace.
Creates and returns an XML name. Qname must be a symbol
whose name satisfies
string-is-xml-name?. Uri must satisfy
returned value is an XML name that satisfies
If uri is the null namespace (satisfies
null-xml-namespace-uri?), the returned value is a symbol
equivalent to qname. This means that an ordinary symbol can be
used as an XML name when there is no namespace associated with
For convenience, qname may be a string, in which case it is
converted to a symbol using
For convenience, uri may be any object that
->uri is able
to convert to a URI record, provided the resulting
URI meets the above restrictions.
#t if object is an XML name, and
Returns the symbol part of xml-name.
Returns the URI of xml-name. The result always satisfies
Returns the qname of xml-name as a string. Equivalent to
(symbol->string (xml-name->symbol xml-name))
The next two procedures get the prefix and local part of an XML name, respectively. The prefix of an XML name is the part of the qname to the left of the colon, while the local part is the part of the qname to the right of the colon. If there is no colon in the qname, the local part is the entire qname, and the prefix is the null symbol (i.e. ‘||’).
Returns the prefix of xml-name as a symbol.
Returns the local part of xml-name as a symbol.
The next procedure compares two XML names for equality. The rules for equality are slightly complex, in order to permit comparing names in the DTD with names in the document body. So, if both of the names have non-null namespace URIs, then the names are equal if and only if their local parts are equal and their URIs are equal. (The prefixes of the names are not considered in this case.) Otherwise, the names are equal if and only if their qnames are equal.
#t if xml-name-1 and xml-name-2 are the same
These next procedures define the data abstraction for qnames. While
qnames are represented as symbols, only symbols whose names satisfy
string-is-xml-name? are qnames.
String must satisfy
string-is-xml-name?. Returns the qname
corresponding to string (the symbol whose name is string).
#t if object is a qname, otherwise returns
Returns the prefix of qname as a symbol.
Returns the local part of qname as a symbol.
The prefix of a qname or XML name may be absent if there is no colon in the name. The absent, or null, prefix is abstracted by the next two procedures. Note that the null prefix is a symbol, just like non-null prefixes.
Returns the null prefix.
#t if object is the null prefix, otherwise returns
The namespace URI of an XML name may be null, meaning that there is no namespace associated with the name. This namespace is represented by a relative URI record whose string representation is the null string.
Returns the null namespace URI record.
#t if object is the null namespace URI
record, otherwise returns
The following values are two distinguished URI records.
xml-uri is the URI reserved for use by the
XML recommendation. This URI must be used with the
xmlns-uri is the URI reserved for use by the
XML namespace recommendation. This URI must be used
with the ‘xmlns’ prefix.