Network Working Group S. Hollenbeck
Request for Comments: 3470 VeriSign, Inc.
BCP: 70 M. Rose
Category: Best Current Practice Dover Beach Consulting, Inc.
L. Masinter
Adobe Systems Incorporated
January 2003
Guidelines for the Use of Extensible Markup Language (XML)
within IETF Protocols
Status of this Memo
This document specifies an Internet Best Current Practices for the
Internet Community, and requests discussion and suggestions for
improvements. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2003). All Rights Reserved.
Abstract
The Extensible Markup Language (XML) is a framework for structuring
data. While it evolved from Standard Generalized Markup Language
(SGML) -- a markup language primarily focused on structuring
documents -- XML has evolved to be a widely-used mechanism for
representing structured data.
There are a wide variety of Internet protocols being developed; many
have need for a representation for structured data relevant to their
application. There has been much interest in the use of XML as a
representation method. This document describes basic XML concepts,
analyzes various alternatives in the use of XML, and provides
guidelines for the use of XML within IETF standards-track protocols.
Table of Contents
Conventions Used In This Document . . . . . . . . . . . . . . . . 2
1. Introduction and Overview . . . . . . . . . . . . . . . . . 2
1.1 Intended Audience. . . . . . . . . . . . . . . . . . . 3
1.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 XML Evolution . . . . . . . . . . . . . . . . . . . . 3
1.4 XML Users, Support Groups, and Additional
Information. . . . . . . . . . . . . . . . . . . . . . 4
2. XML Selection Considerations . . . . . . . . . . . . . . . . 4
3. XML Alternatives . . . . . . . . . . . . . . . . . . . . . . 5
Hollenbeck, et al. Best Current Practice [Page 1]
RFC 3470 XML within IETF Protocols January 2003
4. XML Use Considerations and Recommendations . . . . . . . . . 7
4.1 XML Syntax and Well-Formedness . . . . . . . . . . . . 7
4.2 XML Information Set . . . . . . . . . . . . . . . . . 7
4.3 Syntactic Restrictions . . . . . . . . . . . . . . . . 8
4.4 XML Declarations . . . . . . . . . . . . . . . . . . . 9
4.5 XML Processing Instructions . . . . . . . . . . . . . 9
4.6 XML Comments . . . . . . . . . . . . . . . . . . . . . 10
4.7 Validity and Extensibility . . . . . . . . . . . . . . 10
4.8 Semantics as Well as Syntax. . . . . . . . . . . . . . 12
4.9 Namespaces . . . . . . . . . . . . . . . . . . . . . . 12
4.9.1 Namespaces and Attributes. . . . . . . . . . . . 13
4.10 Element and Attribute Design Considerations. . . . . . 14
4.11 Binary Data and Text with Control Characters . . . . . 16
4.12 Incremental Processing . . . . . . . . . . . . . . . . 16
4.13 Entity Declarations and Entity References . . . . . . 16
4.14 External References . . . . . . . . . . . . . . . . . 17
4.15 URI Processing . . . . . . . . . . . . . . . . . . . . 17
4.16 White Space . . . . . . . . . . . . . . . . . . . . . 18
4.17 Interaction with the IANA . . . . . . . . . . . . . . 19
5. Internationalization Considerations . . . . . . . . . . . . 19
5.1 Character Sets and Encodings . . . . . . . . . . . . . 19
5.2 Language Declaration . . . . . . . . . . . . . . . . . 20
5.3 Other Internationalization Considerations . . . . . . 20
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . 21
7. Security Considerations . . . . . . . . . . . . . . . . . . 21
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 22
9. Normative References . . . . . . . . . . . . . . . . . . . . 22
10. Informative References . . . . . . . . . . . . . . . . . . . 23
11. Authors' Addresses . . . . . . . . . . . . . . . . . . . . . 27
12. Full Copyright Statement . . . . . . . . . . . . . . . . . . 28
Conventions Used In This Document
This document recommends, as policy, what specifications for Internet
protocols -- and, in particular, IETF standards track protocol
documents -- should include as normative language within them. The
capitalized keywords "SHOULD", "MUST", "REQUIRED", etc. are used in
the sense of how they would be used within other documents with the
meanings as specified in BCP 14, RFC 2119 [1].
1. Introduction and Overview
The Extensible Markup Language (XML, [8]) is a framework for
structuring data. While it evolved from the Standard Generalized
Markup Language (SGML, [30]) -- a markup language primarily focused
on structuring documents -- XML has evolved to be a widely-used
mechanism for representing structured data in protocol exchanges.
See "XML in 10 points" [47] for an introduction to XML.
Hollenbeck, et al. Best Current Practice [Page 2]
RFC 3470 XML within IETF Protocols January 2003
1.1 Intended Audience
Many Internet protocol designers are considering using XML and XML
fragments within the context of existing and new Internet protocols.
This document is intended as a guide to XML usage and as IETF policy
for standards track documents. Experienced XML practitioners will
likely already be familiar with the background material here, but the
guidelines are intended to be appropriate for those readers as well.
1.2 Scope
This document is intended to give guidelines for the use of XML
content within a larger protocol. The goal is not to suggest that
XML is the "best" or "preferred" way to represent data; rather, the
goal is to lay out the context for the use of XML within a protocol
once other factors point to XML as a possible data representation
solution. The Common Name Resolution Protocol (CNRP, [24]) is an
example of a protocol that would be addressed by these guidelines if
it were being newly defined. This document does not address the use
of protocols like SMTP or HTTP to send XML documents as ordinary
email or web content.
There are a number of protocol frameworks already in use or under
development which focus entirely on "XML protocol" -- the exclusive
use of XML as the data representation in the protocol. For example,
the World Wide Web Consortium (W3C) is developing an XML Protocol
framework based on SOAP ([45] and [46]). The applicability of such
protocols is not part of the scope of this document.
In addition, there are higher-level representation frameworks, based
on XML, that have been designed as carriers of certain classes of
information; for example, the Resource Description Framework (RDF,
[38]) is an XML-based representation for logical assertions. This
document does not provide guidelines for the use of such frameworks.
1.3 XML Evolution
XML 1.0 was originally published as a W3C recommendation in February
1998 [35], and was revised in a 2nd edition [8] in October 2000.
Several additional facilities have also been defined that layer on
the base specification. Although these additions are designed to be
consistent with XML 1.0, they have varying levels of stability,
consensus, and implementation. Accordingly, this document identifies
the major evolutionary features of XML and makes suggestions as to
the circumstances in which each feature should be used.
Hollenbeck, et al. Best Current Practice [Page 3]
RFC 3470 XML within IETF Protocols January 2003
1.4 XML Users, Support Groups, and Additional Information
There are many XML support groups, with some devoted to the entire
XML industry [51], some devoted to developers [52], some devoted to
the business applications of XML [53], and many, many groups devoted
to the use of XML in a particular context.
It is beyond the scope of this document to provide a comprehensive
list of referrals. Interested readers are directed to the three
references above as starting points, as well as their favorite
Internet search engine.
2. XML Selection Considerations
XML is a tool that provides a means towards an end. Choosing the
right tool for a given task is an essential part of ensuring that the
task can be completed in a satisfactory manner. This section
describes factors to be aware of when considering XML as a tool for
use in IETF protocols:
1. XML is a meta-markup language that can be used to define markup
languages for specific domains and problem spaces.
2. XML provides both logical structure and physical structure to
describe data. Data framing is built-in.
3. XML instances can be validated against the formal definition of a
protocol specification.
4. XML supports internationalization.
5. XML is extensible. Unlike some other markup languages (such as
HTML), new tags (and thus new protocol elements) can be defined
without requiring changes to XML itself.
6. XML is still evolving. The formal specifications are still being
influenced and updated as use experience is gained and applied.
7. XML does not provide native mechanisms to support detailed data
typing. Additional mechanisms (such as those described in
Section 4.7) are required to specify abstract protocol data
types.
8. XML is text-based, so XML fragments are easily created, edited,
and managed using common utilities. Further, being text-based
means it more readily supports incremental development,
Hollenbeck, et al. Best Current Practice [Page 4]
RFC 3470 XML within IETF Protocols January 2003
debugging, and logging. A simple "canned" XML fragment can be
embedded within a program as a string constant, rather than
having to be constructed.
9. Binary data has to be encoded into a text-based form to be
represented in XML.
10. XML is verbose when compared with many other structured data
representation languages. A representation with element
extensibility and human readability typically requires more bits
when compared to one optimized for efficient machine processing.
11. XML implementations are still relatively new. As designers and
implementers gain experience, it is not uncommon to find defects
in early and current products.
12. XML support is available in a large number of software
development utilities, available in both open source and
proprietary products.
13. XML processing speed can be an issue in some environments. XML
processing can be slower because XML data streams may be larger
than other representations, and the use of general purpose XML
parsers will add a software layer with its own performance costs
(though these costs can be reduced through consistent use of an
optimized parser). In some situations, processing XML requires
examining every byte of the entire XML data stream, with higher
overhead than with representations where uninteresting segments
can be skipped.
3. XML Alternatives
This document focuses on guidelines for the use of XML. It is useful
to consider why one might use XML as opposed to some other mechanism.
This section considers some other commonly used representation
mechanisms and compares XML to those alternatives.
For many fundamental protocols, the extensibility requirements are
modest, and the performance requirements are high enough that fixed
binary data blocks are the appropriate representation; mechanisms
such as XML merely add bloat. RFC 3252 [23] describes a humorous
example of XML as protocol bloat.
In addition, there are other representation and extensibility
frameworks that have been used successfully within communication
protocols. For example, Abstract Syntax Notation 1 (ASN.1) [28]
along with the corresponding Basic Encoding Rules (BER, [29]) are
part of the OSI communication protocol suite, and have been used in
Hollenbeck, et al. Best Current Practice [Page 5]
RFC 3470 XML within IETF Protocols January 2003
many subsequent communications standards (e.g., the ANSI Information
Retrieval protocol [27] and the Simple Network Management Protocol
(SNMP, [13]). The External Data Representation (XDR, [14]) and
variations of it have been used in many other distributed network
applications (e.g., the Network File System (NFS) protocol [22]).
With some ASN.1 encoding types, data types are explicit in the
representation, while with XDR, the data types of components are
described externally as part of an interface specification.
Many other protocols use data structures directly (without data
encapsulation) by describing the data structure with Backus Normal
Form (BNF, [25]); many IETF protocols use an Augmented Backus-Naur
Form (ABNF, [16]). The Simple Mail Transfer Protocol (SMTP, [21]) is
an example of a protocol specified using ABNF.
ASN.1, XDR, and BNF are described here as examples of alternatives to
XML for use in IETF protocols. There are other alternatives, but a
complete enumeration of all possible alternatives is beyond the scope
of this document.
Other representation methods may differ from XML in several important
ways:
Text Encoding and character sets: the character encoding used to
represent a formal specification. XML defines a consistent character
model based on the Universal Character Set (UCS, [31] and [33]), and
requires that XML parsers accept at least UTF-8 [4] and UTF-16 [20],
and allows for other encodings. While ASN.1 and XDR may carry
strings in any encoding, there is no common mechanism for defining
character encodings within them. Typically, ABNF definitions tend to
be defined in terms of octets or characters in ASCII.
Data Encoding: XML is defined as a sequence of characters, rather
than a sequence of bytes. XML Schema [42] includes mechanisms for
representing some data types (integer, date, array, etc.) but many
binary data types are encoded in Base64 [15] or hexadecimal. ASN.1
and XDR have rich mechanisms for encoding a wide variety of data
types.
Extensibility: XML has a rich extensibility model such that XML
specifications can frequently be versioned independently.
Specifications can be extended by adding new element names and
attributes (if done compatibly); other extensions can be added by
defining new XML namespaces [9], though there is no standard
mechanism in XML to indicating whether or not new extensions are
mandatory to recognize. Similarly, there are several techniques
available to extend ASN.1 specifications. XDR specifications tend to
not be independently extensible by different parties because the
Hollenbeck, et al. Best Current Practice [Page 6]
RFC 3470 XML within IETF Protocols January 2003
framing and data types are implicit and not self-describing. The
extensibility of BNF-based protocol elements needs to be explicitly
planned.
Legibility of protocol elements: As noted above, XML is text-based,
and thus carries the advantages (and disadvantages) of text-based
protocol elements. Typically this is shared with (A)BNF-defined
protocol elements. ASN.1 and XDR use binary encodings which are not
easily human readable.
4. XML Use Considerations and Recommendations
This section notes several aspects of XML and makes recommendations
for use. Since the 1998 publication of XML version 1 [35], an
editorial second edition [8] was published in 2000; this section
refers to the second edition.
4.1 XML Syntax and Well-Formedness
XML [8] is defined in terms of a concrete syntax: a sequence of
characters, using the characters "<", "=", "&", etc. as delimiters.
An instance is XML if and only if it is well-formed, i.e., all
character and markup data conforms to the structural rules defined in
section 2.1 of [8].
Character and markup data that is not well-formed is not XML; well-
formedness is the basis for syntactic compatibility with XML.
Without well-formedness, all of the advantages of using XML
disappear. For this reason, it is recommended that protocol
specifications explicitly require XML well-formedness ("MUST be
well-formed").
The IETF has a long-standing tradition of "be liberal in what you
accept" that might seem to be at odds with this recommendation.
Given that XML requires well-formedness, conforming XML parsers are
intolerant of well-formedness errors. When specifying the handing of
erroneous XML protocol elements, a protocol design must never
recommend attempting to partially interpret non-well-formed instances
of an element which is required to be XML. Reasonable behaviors in
such a scenario could include attempting retransmission or aborting
an in-progress session.
4.2 XML Information Set
In addition to the concrete syntax of XML, there is an abstract model
of XML content known as the "Information Set" (infoset) [37]. One
might think of an XML parser as consuming the concrete syntax and
producing an XML Information Set for further processing.
Hollenbeck, et al. Best Current Practice [Page 7]
RFC 3470 XML within IETF Protocols January 2003
In typical use of XML, the definition of allowable XML documents is
often defined in terms of the Information Set of the XML and not the
concrete syntax. The notion is that any syntactic representation
which yielded the same information set would be treated equivalently.
It some cases, protocols have been defined solely in terms of the XML
Information Set, or by allowing other concrete syntax
representations. However, since the context of XML embedded within
other Internet protocols requires an unambiguous definition of the
concrete syntax, defining an XML protocol element in terms of its XML
Information Set alone and allowing other concrete syntax
representations is out of scope for this document.
4.3 Syntactic Restrictions
In some circumstances a protocol designer may be tempted to define an
XML-based protocol element as "XML", but at the same time imposing
additional restrictions beyond those imposed by the XML
recommendation itself -- for example, restricting the document
character encoding, or avoiding CDATA sections, character entity
references, imposing additional restrictions on use of white space,
etc. The general category of restrictions addressed by this section
are ones that would allow some but not other of the set of syntactic
representations which have the same canonical representation
according to canonical XML described in RFC 3076 [6].
Making these kinds of restrictions in a protocol definition may have
the disadvantage that an implementer of the protocol may not be able
to use an otherwise conforming XML processor to parse the XML-based
protocol elements. In some cases, the motivation for subsetting XML
is to allow implementers to build special-purpose processors that are
lighter weight than a full-scale conforming XML processor. There are
a number of good, conforming XML parsers that are small, fast, and
free, while special-purpose processors have frequently been known to
fail to handle some cases of legal XML syntax.
In general, such syntactic restrictions should be avoided. In
circumstances where restrictions on the variability of the syntactic
representation of XML is necessary for one reason or another,
designers should consider using "Canonical XML" [6] as the definition
of the protocol element, since all such variability has been removed.
Some specific issues are discussed in Section 4.4, Section 4.13, and
Section 5.1 below.
Hollenbeck, et al. Best Current Practice [Page 8]
RFC 3470 XML within IETF Protocols January 2003
4.4 XML Declarations
An XML declaration (defined in section 2.8 of [8]) is a small header
at the beginning of an XML data stream that indicates the XML version
and the character encoding used. For example,
specifies the use of XML version 1 and UTF-8 character encoding.
In some uses of XML as an embedded protocol element, the XML used is
a small fragment in a larger context, where the XML version is fixed
at "1.0" and the character encoding is known to be "UTF-8". In those
cases, an XML declaration might add extra overhead. In cases where
the XML is a larger component which may find its way alone as an
external entity body (transported as a MIME message, for example),
the XML declaration is an important marker and is useful for
reliability and extensibility. The XML declaration is also an
important marker for character set/encoding (see Section 5.1), if any
encoding other than UTF-8 or UTF-16 is used. Note that in the case
of UTF-16, XML requires that the entity starts with a Byte Order Mark
(BOM), which is not part of the character data. Note that the XML
Declaration itself is not part of the XML document's Information Set.
Protocol specifications must be clear about use of XML declarations.
XML [8] notes that "XML documents should begin with an XML
declaration which specifies the version of XML being used." In
general, an XML declaration should be encouraged ("SHOULD be
present") and must always be allowed ("MAY be sent"). An XML
declaration should be required in cases where, if allowed, the
character encoding is anything other than UTF-8 or UTF-16.
4.5 XML Processing Instructions
An XML processing instruction (defined in section 2.6 of [8]) is a
component of an XML document that signals extra "out of band"
information to the receiver; a common use of XML processing
instructions are for document applications. For example, the XML2RFC
application used to generate this document and described in RFC 2629
[19] supports a "table of contents" processing instruction:
As described in section 2.6 of [8], processing instructions are not
part of the document's character data, but must be passed through to
the application. As a consequence, it is recommended that processing
instructions be ignored when encountered in normal protocol
processing. It is thus also recommended that processing instructions
Hollenbeck, et al. Best Current Practice [Page 9]
RFC 3470 XML within IETF Protocols January 2003
not be used to define normative protocol data structures or
extensions for the following reasons:
o Processing instructions are not namespace aware; there is no way
to qualify a processing instruction target with a namespace.
o Processing instruction use can not be constrained by most schema
languages,
o Character references are not recognized within a processing
instruction.
o Processing instructions don't have any XML-defined structure
beyond the division between the target and everything else. This
means that applications typically have to parse the content of the
processing instruction in a system-dependent way; if the content
was provided within an element instead, the structure could be
expressed in the XML and the parsing could be done by the XML
parser.
4.6 XML Comments
An XML comment (defined in section 2.5 of [8]) is a component of an
XML document that provides descriptive information that is not part
of the document's character data. XML comments, like comments used
in programming languages, are often used to provide explanatory
information in human-understandable terms. An example:
XML comments can be ignored by conformant processors. As a
consequence, it is strongly recommended that comments not be used to
define normative protocol data structures or extensions. It is thus
also strongly recommended that comments be ignored if encountered in
normal protocol processing.
4.7 Validity and Extensibility
One important value of XML is that there are formal mechanisms for
defining structural and data content constraints; these constrain the
identity of elements or attributes or the values contained within
them. There is more than one such formalism:
o A "Document Type Definition" (DTD) is defined in section 2.8 of
[8]; the concept came from a similar mechanism for SGML. There is
significant experience with using DTDs, including in IETF
protocols.
Hollenbeck, et al. Best Current Practice [Page 10]
RFC 3470 XML within IETF Protocols January 2003
o XML Schema (defined in [41] and [42]) provides additional features
to allow a tighter and more precise specification of allowable
protocol syntax and data type specifications.
o There are also a number of other mechanisms for describing XML
instance validity; these include, for example, Schematron [49] and
RELAX NG [48]. Part 2 of the ISO/IEC Document Schema Definition
Language (DSDL, [32]) standard is based on RELAX NG.
There is ongoing discussion (and controversy) within the XML
community on the use and applicability of various validity constraint
mechanisms. The choice of tool depends on the needs for
extensibility or for a formal language and mechanism for constraining
permissible values and validating adherence to the constraints.
There are cases where protocols have defined validity using one or
another validity mechanism, but the protocol definitions have not
insisted that all corresponding protocol elements be "valid". The
decision depends in part on the design for protocol extensibility.
Each formalism has different ways of allowing for future extensions;
in addition, a protocol design may have its own versioning mechanism,
way of updating the schema, or pointing to a new one. For example,
the use of XML namespaces (Section 4.9) with XML Schema allows other
kinds of extensibility without compromising schema validity.
No matter what formalism is chosen, there are usually additional
syntactic constraints, and inevitably additional semantic
constraints, on the validity of XML elements that cannot be expressed
in the formalism.
This document makes the following recommendations for the definition
of protocols using XML:
o Protocols should use an appropriate formalism for defining
validity of XML protocol elements.
o Protocols may or may not insist that all corresponding protocol
elements be valid, according to the validity mechanism chosen; in
either case, the extensibility design should be clear. What
happens if the data is not valid?
o As described in Section 3 there is no standard mechanism in XML
for indicating whether or not new extensions are mandatory to
recognize. XML-based protocol specifications should thus
explicitly describe extension mechanisms and requirements to
recognize or ignore extensions.
Hollenbeck, et al. Best Current Practice [Page 11]
RFC 3470 XML within IETF Protocols January 2003
An idealized model for XML processing might first check for well-
formedness; if OK, apply the primary formalism and, if the instances
"passes", apply the other constraints so that the entire set (or as
much as is machine processable) can be checked at the same time.
However, it is reasonable to allow conforming implementations to
avoid doing validation at run-time and rely instead on ad-hoc code to
avoid the higher expense, for example, of schema validation,
especially given that there will likely be additional hand-crafted
semantic validation.
4.8 Semantics as Well as Syntax
While the definition of an XML protocol element using a validity
formalism is useful, it is not sufficient. XML by itself does not
supply semantics. Any document defining a protocol element with XML
MUST also have sufficient prose in the document describing the
semantics of whatever XML the document has elected to define.
4.9 Namespaces
XML namespaces, defined in [9], provide a means of assigning markup
to a specific vocabulary. If two elements or attributes from
different vocabularies have the same name, they can be distinguished
unambiguously if they belong to different namespaces. Additionally,
namespaces provide significant support for protocol extensibility as
they can be defined, reused, and processed dynamically.
Markup vocabulary collisions are very possible when namespaces are
not used to separate and uniquely identify vocabularies. Protocol
definitions should use existing XML namespaces where appropriate.
When a new namespace is needed, the "namespace name" is a URI that is
used to identify the namespace; it's also useful for that URI to
point to a description of the namespace. Typically (and recommended
practice in W3C) is to assign namespace names using persistent http
URIs.
In the case of namespaces in IETF standards-track documents, it would
be useful if there were some permanent part of the IETF's own web
space that could be used for this purpose. In lieu of such, other
permanent URIs can be used, e.g., URNs in the IETF URN namespace (see
[11] and [12]). Although there are instances of IETF specifications
creating new URI schemes to define XML namespaces, this practice is
strongly discouraged.
Hollenbeck, et al. Best Current Practice [Page 12]
RFC 3470 XML within IETF Protocols January 2003
4.9.1 Namespaces and Attributes
There is a frequently misunderstood aspect of the relationship
between unprefixed attributes and the default XML namespace - the
natural assumption is that an unprefixed attribute is qualified by
the default namespace, but this is not true. Rather, the unprefixed
attribute belongs to no namespace at all. Thus, in the following
example:
Total: