W3C

Using Qualified Names (QNames) as Identifiers in Content

[Editor’s Draft] TAG Finding 03 November 2003

This version:
http://www.w3.org/2001/tag/doc/qnameids-2003-11-03
Latest version:
http://www.w3.org/2001/tag/doc/qnameids
Previous versions:
http://www.w3.org/2001/tag/doc/qnameids-2002-07-15 http://www.w3.org/2001/tag/doc/qnameids-2002-06-17 http://www.w3.org/2001/tag/doc/qnameids-2002-06-04 http://www.w3.org/2001/tag/doc/qnameids-2002-04-30
Editor:
Norman Walsh, Sun Microsystems, Inc. <Norman.Walsh@Sun.COM>

This document is also available in these non-normative formats: XML and 2003-07-15 Diff.


Abstract

The question that prompted this finding was "are QNames acceptable replacements for URIs as identifiers within specifications?" This finding documents the TAG's opinion on the use of QNames as identifiers.

Status of this Document

This document has been developed for discussion by the W3C Technical Architecture Group. This finding addresses issue qnameAsId-18.

This finding was accepted by the TAG at its 22 July 2002 teleconference. The TAG originally reached consensus on this finding at its 15 July 2002 teleconference.

Additional TAG findings, both approved and in draft state, may also be available. The TAG expects to incorporate this and other findings into a Web Architecture Document that will be published according to the process of the W3C Recommendation Track.

Please send comments on this finding to the publicly archived TAG mailing list www-tag@w3.org (archive).

Table of Contents

1 Preface
2 QNames as Identifiers
3 QNames in XML
    3.1 Prefixes in Other Contexts
4 QNames in Other Specifications
5 Namespace Bindings
6 Architectural Observations
7 Architectural Statement
8 References


1 Preface

This TAG Finding documents a portion of the web architecture where conflicting requirements and design goals intersect. It is a simple matter of fact that specifications which have chosen one set of design criteria interoperate less well with specifications that have chosen a different set.

Given that there are existing specifications which exhibit incompatible designs and strong arguments in favor of each design, the TAG elects not to assert architectural principles that would be in direct conflict with some significant set of specifications.

It's possible that these issues could be addressed in the scope of some larger, more global redesign of, for example, XML, but no short-term solution presents itself

2 QNames as Identifiers

This finding is concerned with the use of qualified names (QNames) as identifiers. That is, the contexts in which a colonized name can be understood to be a QName.

A related TAG issue, rdfmsQnameUriMapping-6, concerns the mechanism by which one can (or can not) construct a URI for a particular QName. We do not consider that issue in this finding.

3 QNames in XML

Qualified names were introduced by [XML Namespaces]. They were defined for element and attribute names (only) and provide a mechanism for concisely identifying a URI/local-name pair. For example, in the following document:

<?xml version='1.0'?>
<doc xmlns:x="http://example.com/ns/foo">
<x:p/>
</doc>

The QName "x:p" is a concise, unambiguous name for the URI/local-name pair {"http://example.com/ns/foo", "p"}.

When used solely in element and attribute names, all QNames are identified by the XML processor and can logically be replaced by the URI/local-name pair they identify.

3.1 Prefixes in Other Contexts

At the request of the XML Schema Working Group, the XML Core Working Group is producing an erratum to [XML Namespaces] to clarify the meaning of colons in other contexts.

In particular, this erratum makes it clear that entity names, processing instruction targets, and notation names are not QNames and they may not include any colons. Documents that do not satisfy this constraint are not namespace well-formed. Furthermore, the values of attributes of type ID, IDREF(S), ENTITY(IES), and NOTATION are also forbidden from containing colons. Documents that do not satisfy this constraint are not namespace valid.

A colon that introduces a namespace validity or namespace well-formedness error into a document does not introduce a QName. In other words, the term "identifier" in this finding is not related to XML identifiers of type ID since they cannot be QNames.

4 QNames in Other Specifications

Other specifications, starting with [XSLT], have taken QNames and employed them in contexts other than element and attribute names. Specifically, QNames have been used in attribute values and element content.

For example, in the following document, "x:p" is understood to be a QName even though it appears in an attribute value, not an element or attribute name.

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:x="http://example.com/ns/foo"
                version="1.0">

<xsl:output method="html"/>

<xsl:template match="x:p">
  <p>
    <xsl:apply-templates/>
  </p>
</xsl:template>

</xsl:stylesheet>
</doc>

In attribute values and element content, QNames are often used to identify a particular element type; they are, in principle, using QNames as they were intended. However, some specifications use QNames as shortcuts for unique identifiers derived from a URI/local-name pair that have no relationship to element or attribute types.

Using a QName as a shortcut for a URI/local-name pair is often convenient, but it carries a price. There is no single, accepted way to convert QNames into URI/local-name pairs or vice versa. Different specifications have chosen different algorithms. This means that even if a QName can be identified in content, it may be difficult or impossible to determine what URI/local-name it represents. At the very least, the mapping depends on the context in which it occurs. Therefore, at the very least, it is important for specifications to identify the mapping algorithm that they have chosen.

Principle

Specifications that use QNames to represent URI/local-name pairs MUST describe the algorithm that is used to map between them.

We observe also that there is an overlap in the lexical space of QNames and URIs.

Good Practice

Specifications that use QNames to represent URI/local-name pairs SHOULD NOT allow both forms in attribute values or element content where they would be indistinguishable.

5 Namespace Bindings

Some specifications rely on the in-scope namespace bindings in the XML document to associate prefixes with namespace names. Other specifications rely on application-specific mechanisms.

Using the in-scope namespace bindings has the advantage that it theoretically allows a generic processor to interpret QNames in content without having to be aware of any application-specific mechanisms. The alternative, where every specification defines its own mechansism, could clearly lead to a badly fragmented web.

However, there is at least one application where a compelling argument has been made for requiring an alternative mechanism for defining namespace bindings. That application is [XPointer Framework].

It is an architectural principle of URIs that they be context-independent. It follows that the QNames that appear in an XPointer must not refer to in-scope namespaces as this would make transcription impossible in the general case.

We must therfore accept that there are some applications which use in-scope namespaces and some which use their own mechanisms.

6 Architectural Observations

The TAG makes the following observations:

7 Architectural Statement

The TAG recognizes that there are pragmatic reasons why it is desireable to provide the same kind of URI/local-name shortcuts that QNames provide for element and attribute names in other contexts. In addition, the practice is already well established. Therefore, the TAG accepts that it is reasonable to use QNames in this way.

Specifications that have no compelling reason to use QNames where URIs would suffice, for example formats that are not expected to be edited by hand or formats where human readability is not a significant factor, can avoid an entire set of problems by simply using URIs.

The TAG encourages designers to consider the ramifications of their use of QNames carefully as it may have a dramatic impact on the extent to which their specification interoperates with other specifications.

8 References

XPointer Framework
Paul Grosso, Eve Maler, Jonathan Marsh, Norman Walsh, editors. XPointer Framework. World Wide Web Consortium, 2002. (See http://www.w3.org/TR/xptr-framework/.)
XML Datatypes
Paul V. Biron and Ashok Malhotra, editors. XML Schema Part 2: Datatypes. World Wide Web Consortium, 2000. (See http://www.w3.org/TR/xmlschema-2/.)
XML Namespaces
Tim Bray, Dave Hollander, Andrew Layman, editors. Namespaces in XML. World Wide Web Consortium, 1999. (See http://www.w3.org/TR/REC-xml-names/.)
XSLT
James Clark, editor. XML Transformations (XSLT) Version 1.0. World Wide Web Consortium, 1999. (See http://www.w3.org/TR/xslt.)