Next: XML Structure, Previous: XML Output, Up: XML Support
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 eitherabsolute-uri?
ornull-xml-namespace-uri?
. The returned value is an XML name that satisfiesxml-name?
.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 the name.For convenience, qname may be a string, in which case it is converted to a symbol using
make-xml-qname
.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.
Returns the URI of xml-name. The result always satisfies
absolute-uri?
ornull-xml-namespace-uri?
.
Returns the qname of xml-name as a string. Equivalent to
(symbol-name (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. `||').
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.
Returns
#t
if xml-name-1 and xml-name-2 are the same name, and#f
otherwise.
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).
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
#t
if object is the null prefix, otherwise returns#f
.
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
#t
if object is the null namespace URI record, otherwise returns#f
.
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 `xml' prefix.