Guidelines for the Use of Extensible Markup Language (XML) within IETF Protocols
RFC 3470 устанавливает лучшую современную практику использования XML в документах протоколов IETF, проходящих стандартизацию. Документ помогает выбрать XML с учётом расширяемости, интернационализации, типизации, производительности, объёма данных и альтернативных представлений. XML-элемент, определённый как XML, MUST быть корректно сформированным; документ, определяющий XML-элемент протокола, MUST достаточно полно описывать его семантику. Реализации MUST особенно тщательно обеспечивать устойчивость XML-обработки к некорректному XML, переполнениям буфера, злоупотреблению объявлениями сущностей и подобным угрозам; требуемый набор защитных сервисов зависит от модели угроз протокола.
Рабочая группа по сетям S. Hollenbeck
Запрос комментариев: 3470 VeriSign, Inc.
BCP: 70 M. Rose
Категория: Лучшая современная практика Dover Beach Consulting, Inc.
L. Masinter
Adobe Systems Incorporated
Январь 2003
Рекомендации по использованию Extensible Markup Language (XML)
в протоколах IETF
Статус данного меморандума
Этот документ устанавливает Лучшую современную практику Интернета для
интернет-сообщества и запрашивает обсуждение и предложения по
улучшениям. Распространение данного меморандума не ограничено.
Уведомление об авторских правах
Copyright (C) The Internet Society (2003). Все права защищены.
Аннотация
Extensible Markup Language (XML) — это основа для структурирования
данных. Хотя XML произошёл от Standard Generalized Markup Language
(SGML) — языка разметки, в первую очередь ориентированного на
структурирование документов, — XML стал широко используемым механизмом
представления структурированных данных.
Разрабатывается большое разнообразие интернет-протоколов; многим из них
требуется представление структурированных данных, относящихся к их
применению. Использование XML в качестве метода представления вызвало
большой интерес. Этот документ описывает основные понятия XML,
анализирует различные альтернативы использования XML и даёт рекомендации
по применению XML в протоколах IETF, находящихся на пути стандартизации.
Содержание
Используемые в данном документе соглашения . . . . . . . . . . . . . 2
1. Введение и обзор . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Предполагаемая аудитория . . . . . . . . . . . . . . . . 3
1.2 Область применения . . . . . . . . . . . . . . . . . . 3
1.3 Эволюция XML . . . . . . . . . . . . . . . . . . . . . 3
1.4 Пользователи XML, группы поддержки и дополнительная
информация . . . . . . . . . . . . . . . . . . . . . . 4
2. Факторы выбора XML . . . . . . . . . . . . . . . . . . . . . 4
3. Альтернативы XML . . . . . . . . . . . . . . . . . . . . . . 5
Hollenbeck, et al. Лучшая современная практика [Страница 1]
RFC 3470 XML в протоколах IETF Январь 2003
4. Особенности использования XML и рекомендации . . . . . . . . . 7
4.1 Синтаксис XML и правильная сформированность . . . . . . . 7
4.2 Информационное множество XML . . . . . . . . . . . . . . 7
4.3 Синтаксические ограничения . . . . . . . . . . . . . . . 8
4.4 Объявления XML . . . . . . . . . . . . . . . . . . . . . 9
4.5 Инструкции обработки XML . . . . . . . . . . . . . . . . 9
4.6 Комментарии XML . . . . . . . . . . . . . . . . . . . . 10
4.7 Валидность и расширяемость . . . . . . . . . . . . . . . 10
4.8 Семантика наряду с синтаксисом . . . . . . . . . . . . . 12
4.9 Пространства имён . . . . . . . . . . . . . . . . . . . 12
4.9.1 Пространства имён и атрибуты . . . . . . . . . . . 13
4.10 Особенности проектирования элементов и атрибутов . . . . . 14
4.11 Двоичные данные и текст с управляющими символами . . . . . 16
4.12 Инкрементальная обработка . . . . . . . . . . . . . . . . 16
4.13 Объявления сущностей и ссылки на сущности . . . . . . . . 16
4.14 Внешние ссылки . . . . . . . . . . . . . . . . . . . . . 17
4.15 Обработка URI . . . . . . . . . . . . . . . . . . . . . 17
4.16 Пробельные символы . . . . . . . . . . . . . . . . . . . 18
4.17 Взаимодействие с IANA . . . . . . . . . . . . . . . . . 19
5. Соображения интернационализации . . . . . . . . . . . . . . . 19
5.1 Наборы символов и кодировки . . . . . . . . . . . . . . 19
5.2 Объявление языка . . . . . . . . . . . . . . . . . . . 20
5.3 Другие соображения интернационализации . . . . . . . . . 20
6. Соображения IANA . . . . . . . . . . . . . . . . . . . . . . 21
7. Соображения безопасности . . . . . . . . . . . . . . . . . . 21
8. Благодарности . . . . . . . . . . . . . . . . . . . . . . . 22
9. Нормативные ссылки . . . . . . . . . . . . . . . . . . . . . 22
10. Информативные ссылки . . . . . . . . . . . . . . . . . . . . 23
11. Адреса авторов . . . . . . . . . . . . . . . . . . . . . . . 27
12. Полное заявление об авторских правах . . . . . . . . . . . . . 28
Используемые в данном документе соглашения
В качестве политики данный документ рекомендует, какой нормативный язык
спецификациям интернет-протоколов следует включать в себя — и, в
частности, документам протоколов IETF, находящимся на пути
стандартизации. Ключевые слова прописными буквами «SHOULD», «MUST»,
«REQUIRED» и т. д. используются в том смысле, в каком они использовались
бы в других документах, со значениями, установленными в BCP 14, RFC 2119
[1].
1. Введение и обзор
Extensible Markup Language (XML, [8]) — это основа для структурирования
данных. Хотя XML произошёл от Standard Generalized Markup Language
(SGML, [30]) — языка разметки, в первую очередь ориентированного на
структурирование документов, — XML стал широко используемым механизмом
представления структурированных данных при обмене по протоколам. Введение
в XML см. в «XML in 10 points» [47].
Hollenbeck, et al. Лучшая современная практика [Страница 2]
RFC 3470 XML в протоколах IETF Январь 2003
1.1 Предполагаемая аудитория
Многие разработчики интернет-протоколов рассматривают использование XML
и XML-фрагментов в контексте существующих и новых интернет-протоколов.
Этот документ предназначен как руководство по использованию XML и как
политика IETF для документов на пути стандартизации. Опытные специалисты
по XML, вероятно, уже знакомы с приведёнными здесь базовыми материалами,
однако рекомендации также предназначены для таких читателей.
1.2 Область применения
Этот документ предназначен для предоставления рекомендаций по
использованию содержимого XML в составе более крупного протокола. Цель
состоит не в том, чтобы утверждать, что XML является «лучшим» или
«предпочтительным» способом представления данных; напротив, цель состоит
в изложении контекста использования XML в протоколе, когда другие факторы
указывают на XML как на возможное решение для представления данных.
Common Name Resolution Protocol (CNRP, [24]) является примером протокола,
к которому применялись бы эти рекомендации, если бы он определялся вновь.
Этот документ не рассматривает использование таких протоколов, как SMTP
или HTTP, для отправки XML-документов в качестве обычного содержимого
электронной почты или веб-содержимого.
Уже используется или разрабатывается ряд протокольных каркасов, полностью
сосредоточенных на «протоколе XML» — исключительном использовании XML как
представления данных в протоколе. Например, World Wide Web Consortium
(W3C) разрабатывает каркас XML Protocol, основанный на SOAP ([45] и [46]).
Применимость таких протоколов не входит в область применения данного
документа.
Кроме того, существуют основанные на XML каркасы представления более
высокого уровня, разработанные как носители определённых классов
информации; например, Resource Description Framework (RDF, [38]) — это
основанное на XML представление логических утверждений. Этот документ не
предоставляет рекомендаций по использованию таких каркасов.
1.3 Эволюция XML
XML 1.0 первоначально был опубликован как рекомендация W3C в феврале
1998 года [35], а в октябре 2000 года был пересмотрен во 2-м издании [8].
Также был определён ряд дополнительных средств, надстраиваемых над базовой
спецификацией. Хотя эти дополнения спроектированы совместимыми с XML 1.0,
они обладают различными уровнями стабильности, консенсуса и реализации.
Соответственно, этот документ определяет основные эволюционные возможности
XML и предлагает обстоятельства, в которых следует использовать каждую из
них.
Hollenbeck, et al. Лучшая современная практика [Страница 3]
RFC 3470 XML в протоколах IETF Январь 2003
1.4 Пользователи XML, группы поддержки и дополнительная информация
Существует много групп поддержки XML: некоторые посвящены всей индустрии
XML [51], некоторые — разработчикам [52], некоторые — деловым применениям
XML [53], а также имеется множество, множество групп, посвящённых
использованию XML в конкретном контексте.
Предоставление исчерпывающего списка ссылок выходит за рамки данного
документа. Заинтересованным читателям в качестве отправных точек
предлагаются три приведённые выше ссылки, а также их предпочитаемая
интернет-поисковая система.
2. Факторы выбора XML
XML — это инструмент, предоставляющий средство для достижения цели. Выбор
правильного инструмента для данной задачи является существенной частью
обеспечения возможности удовлетворительного выполнения задачи. В этом
разделе описываются факторы, о которых следует знать при рассмотрении XML
как инструмента для применения в протоколах IETF:
1. XML является метаязыком разметки, который можно использовать для
определения языков разметки для конкретных предметных областей и
пространств задач.
2. XML предоставляет как логическую, так и физическую структуру для
описания данных. Кадрирование данных встроено.
3. Экземпляры XML могут быть проверены на соответствие формальному
определению спецификации протокола.
4. XML поддерживает интернационализацию.
5. XML расширяем. В отличие от некоторых других языков разметки (таких
как HTML), новые теги (и, следовательно, новые элементы протокола)
могут определяться без внесения изменений в сам XML.
6. XML всё ещё развивается. Формальные спецификации продолжают
формироваться и обновляться по мере накопления и применения опыта
использования.
7. XML не предоставляет встроенных механизмов для поддержки подробной
типизации данных. Для задания абстрактных типов данных протокола
требуются дополнительные механизмы (такие как описанные в разделе 4.7).
8. XML основан на тексте, поэтому XML-фрагменты легко создавать,
редактировать и сопровождать с использованием распространённых
утилит. Кроме того, текстовая основа означает, что XML проще
поддерживает инкрементальную разработку,
Hollenbeck, et al. Лучшая современная практика [Страница 4]
RFC 3470 XML в протоколах IETF Январь 2003
отладку и журналирование. Простой «заготовленный» XML-фрагмент можно
встроить в программу как строковую константу, вместо того чтобы
конструировать его.
9. Чтобы представить двоичные данные в XML, их необходимо закодировать в
текстовую форму.
10. XML многословен по сравнению со многими другими языками представления
структурированных данных. Представление с расширяемостью элементов и
читаемостью для человека обычно требует больше битов по сравнению с
представлением, оптимизированным для эффективной машинной обработки.
11. Реализации XML всё ещё относительно новы. По мере того как разработчики
и реализаторы получают опыт, нередко обнаруживаются дефекты в ранних и
текущих продуктах.
12. Поддержка XML доступна во множестве средств разработки программного
обеспечения, представленных как продуктами с открытым исходным кодом,
так и проприетарными продуктами.
13. Скорость обработки XML в некоторых средах может быть проблемой.
Обработка XML может быть медленнее, поскольку потоки данных XML могут
быть больше других представлений, а использование XML-анализаторов
общего назначения добавляет программный слой с собственными затратами
производительности (хотя эти затраты можно сократить последовательным
применением оптимизированного анализатора). В некоторых ситуациях
обработка XML требует проверки каждого байта всего потока данных XML,
с большими накладными расходами, чем у представлений, в которых
неинтересующие сегменты можно пропускать.
3. Альтернативы XML
Этот документ сосредоточен на рекомендациях по использованию XML. Полезно
рассмотреть, почему можно использовать XML, а не какой-либо другой
механизм. В данном разделе рассматриваются некоторые другие широко
используемые механизмы представления и сопоставляется XML с этими
альтернативами.
Для многих фундаментальных протоколов требования к расширяемости умеренны,
а требования к производительности достаточно высоки, чтобы подходящим
представлением были блоки двоичных данных фиксированного формата; такие
механизмы, как XML, лишь добавляют раздувание. RFC 3252 [23] описывает
шуточный пример XML как раздувания протокола.
Кроме того, в коммуникационных протоколах успешно использовались другие
каркасы представления и расширяемости. Например, Abstract Syntax Notation 1
(ASN.1) [28] вместе с соответствующими Basic Encoding Rules (BER, [29])
являются частью набора коммуникационных протоколов OSI и использовались во
многих последующих стандартах связи (например, в протоколе ANSI Information
Retrieval [27] и Simple Network Management Protocol (SNMP, [13]). External
Data Representation (XDR, [14]) и его варианты использовались во многих
других распределённых сетевых приложениях (например, в протоколе Network
File System (NFS) [22]). При некоторых типах кодирования ASN.1 типы данных
явным образом присутствуют в представлении, тогда как в XDR типы данных
компонентов описываются внешним образом как часть спецификации интерфейса.
Многие другие протоколы используют структуры данных непосредственно (без
инкапсуляции данных), описывая структуру данных с помощью Backus Normal Form
(BNF, [25]); многие протоколы IETF используют Augmented Backus-Naur Form
(ABNF, [16]). Simple Mail Transfer Protocol (SMTP, [21]) является примером
протокола, специфицированного с использованием ABNF.ASN.1, XDR и BNF описаны здесь как примеры альтернатив XML для использования в протоколах IETF. Существуют и другие альтернативы, однако полное перечисление всех возможных альтернатив выходит за рамки настоящего документа.
Другие методы представления могут отличаться от XML несколькими важными свойствами:
Кодирование текста и наборы символов: кодировка символов, используемая для представления формальной спецификации. XML определяет согласованную модель символов, основанную на Universal Character Set (UCS, [31] и [33]), и требует, чтобы XML-парсеры принимали как минимум UTF-8 [4] и UTF-16 [20], а также допускает другие кодировки. Хотя ASN.1 и XDR могут передавать строки в любой кодировке, в них нет общего механизма для определения кодировок символов. Как правило, определения ABNF формулируются в терминах октетов или символов ASCII.
Кодирование данных: XML определяется как последовательность символов, а не как последовательность байтов. XML Schema [42] включает механизмы представления некоторых типов данных (целое число, дата, массив и т. д.), но многие двоичные типы данных кодируются в Base64 [15] или в шестнадцатеричном виде. ASN.1 и XDR имеют развитые механизмы кодирования широкого разнообразия типов данных.
Расширяемость: XML имеет развитую модель расширяемости, благодаря которой спецификации XML часто могут версионироваться независимо. Спецификации могут расширяться добавлением новых имён элементов и атрибутов (если это сделано совместимым образом); другие расширения могут добавляться определением новых пространств имён XML [9], хотя в XML нет стандартного механизма для указания того, обязательно ли распознавать новые расширения. Аналогично, для расширения спецификаций ASN.1 доступны несколько методов. Спецификации XDR, как правило, не могут независимо расширяться разными сторонами, поскольку кадрирование и типы данных являются неявными и не самоописываются.
Hollenbeck, et al. Best Current Practice [Page 6]
RFC 3470 XML within IETF Protocols January 2003
Расширяемость элементов протокола, основанных на BNF, должна быть явно спланирована.
Читаемость элементов протокола: как отмечено выше, XML основан на тексте и поэтому обладает преимуществами (и недостатками) текстовых элементов протокола. Обычно это свойство разделяют элементы протокола, определённые посредством (A)BNF. ASN.1 и XDR используют двоичные кодировки, которые человеку нелегко читать.
4. Соображения и рекомендации по использованию XML
В этом разделе отмечаются несколько аспектов XML и даются рекомендации по его использованию. После публикации XML версии 1 [35] в 1998 году в 2000 году было опубликовано редакционное второе издание [8]; в этом разделе имеется в виду второе издание.
4.1 Синтаксис XML и корректная сформированность
XML [8] определяется через конкретный синтаксис: последовательность символов, использующую символы «<», «=», «&» и т. д. в качестве разделителей. Экземпляр является XML тогда и только тогда, когда он корректно сформирован, то есть все символьные данные и данные разметки соответствуют структурным правилам, определённым в разделе 2.1 документа [8].
Символьные данные и данные разметки, которые не являются корректно сформированными, не являются XML; корректная сформированность — основа синтаксической совместимости с XML. Без корректной сформированности все преимущества использования XML исчезают. Поэтому рекомендуется, чтобы спецификации протоколов явно требовали корректной сформированности XML («ДОЛЖЕН (MUST) быть корректно сформирован»).
IETF имеет давнюю традицию «быть либеральным в том, что принимаешь», которая может показаться противоречащей этой рекомендации. Поскольку XML требует корректной сформированности, соответствующие XML-парсеры нетерпимы к ошибкам корректной сформированности. При определении обработки ошибочных XML-элементов протокола проектирование протокола никогда не должно рекомендовать попытку частично интерпретировать некорректно сформированные экземпляры элемента, который должен быть XML. Разумное поведение в таком сценарии может включать попытку повторной передачи или прерывание сеанса, находящегося в процессе выполнения.
4.2 Информационный набор XML
Помимо конкретного синтаксиса XML существует абстрактная модель содержимого XML, известная как «Information Set» (infoset) [37]. XML-парсер можно представлять как средство, которое потребляет конкретный синтаксис и создаёт XML Information Set для дальнейшей обработки.
Hollenbeck, et al. Best Current Practice [Page 7]
RFC 3470 XML within IETF Protocols January 2003
При типичном использовании XML определение допустимых XML-документов часто формулируется в терминах Information Set XML, а не конкретного синтаксиса. Идея состоит в том, что любое синтаксическое представление, порождающее тот же информационный набор, рассматривалось бы как эквивалентное.
В некоторых случаях протоколы определялись исключительно в терминах XML Information Set либо с допущением представлений в другом конкретном синтаксисе. Однако, поскольку контекст XML, встроенного в другие интернет-протоколы, требует однозначного определения конкретного синтаксиса, определение элемента XML-протокола только в терминах его XML Information Set и допущение представлений в другом конкретном синтаксисе выходят за рамки настоящего документа.
4.3 Синтаксические ограничения
В некоторых обстоятельствах разработчик протокола может испытать соблазн определить элемент протокола на основе XML как «XML», но одновременно наложить дополнительные ограничения сверх налагаемых самой рекомендацией XML — например, ограничить кодировку символов документа, избегать разделов CDATA, ссылок на символьные сущности, налагать дополнительные ограничения на использование пробельных символов и т. д. Общая категория ограничений, рассматриваемых в этом разделе, — это такие ограничения, которые допускали бы одни, но не другие синтаксические представления из множества представлений, имеющих одно и то же каноническое представление согласно каноническому XML, описанному в RFC 3076 [6].
Введение таких ограничений в определение протокола может иметь тот недостаток, что реализатор протокола не сможет использовать в остальном соответствующий XML-процессор для разбора элементов протокола на основе XML. В некоторых случаях мотивом выделения подмножества XML является возможность для реализаторов создавать специализированные процессоры с меньшими требованиями к ресурсам, чем полнофункциональный соответствующий XML-процессор. Существует ряд хороших, соответствующих XML-парсеров, которые малы, быстры и бесплатны, тогда как специализированные процессоры часто оказывались неспособными обработать некоторые случаи допустимого синтаксиса XML.
В целом таких синтаксических ограничений следует избегать. В обстоятельствах, когда ограничения изменчивости синтаксического представления XML необходимы по той или иной причине, разработчикам следует рассмотреть использование «Canonical XML» [6] в качестве определения элемента протокола, поскольку вся такая изменчивость в нём устранена. Некоторые конкретные вопросы обсуждаются ниже, в разделе 4.4, разделе 4.13 и разделе 5.1.
Hollenbeck, et al. Best Current Practice [Page 8]
RFC 3470 XML within IETF Protocols January 2003
4.4 Объявления XML
Объявление XML (определённое в разделе 2.8 документа [8]) — это небольшой заголовок в начале потока данных XML, указывающий версию XML и используемую кодировку символов. Например,
<?xml version="1.0" encoding="UTF-8"?>
задаёт использование XML версии 1 и кодировки символов UTF-8.
При некоторых вариантах использования XML в качестве встроенного элемента протокола используемый XML представляет собой небольшой фрагмент в более широком контексте, где версия XML зафиксирована как «1.0», а кодировка символов заведомо является «UTF-8». В таких случаях объявление XML может создавать дополнительные накладные расходы. В случаях, когда XML является более крупным компонентом, который может самостоятельно оказаться телом внешней сущности (например, передаваемым как MIME-сообщение), объявление XML является важным маркером и полезно для надёжности и расширяемости. Объявление XML также является важным маркером набора символов/кодировки (см. раздел 5.1), если используется любая кодировка, отличная от UTF-8 или UTF-16. Следует отметить, что в случае UTF-16 XML требует, чтобы сущность начиналась с Byte Order Mark (BOM), не являющегося частью символьных данных. Следует отметить, что само XML Declaration не является частью Information Set XML-документа.
Спецификации протоколов должны ясно определять использование объявлений XML. В XML [8] отмечено, что «XML-документы следует начинать с объявления XML, указывающего используемую версию XML». В целом объявление XML следует поощрять («СЛЕДУЕТ (SHOULD) присутствовать») и всегда допускать («МОЖЕТ (MAY) быть отправлено»). Объявление XML следует требовать в случаях, когда при его допустимости кодировка символов является любой кодировкой, отличной от UTF-8 или UTF-16.
4.5 Инструкции обработки XML
Инструкция обработки XML (определённая в разделе 2.6 документа [8]) — это компонент XML-документа, передающий получателю дополнительную информацию «вне полосы»; распространённое применение инструкций обработки XML — приложения для работы с документами. Например, приложение XML2RFC, использованное для создания настоящего документа и описанное в RFC 2629 [19], поддерживает инструкцию обработки «table of contents»:
<?rfc toc="yes"?>
Как описано в разделе 2.6 документа [8], инструкции обработки не являются частью символьных данных документа, но должны передаваться приложению. Как следствие, рекомендуется игнорировать инструкции обработки при их обнаружении в обычной обработке протокола. Поэтому также рекомендуется не использовать инструкции обработки для определения нормативных структур данных протокола или расширений по следующим причинам:
Hollenbeck, et al. Best Current Practice [Page 9]
RFC 3470 XML within IETF Protocols January 2003
o Инструкции обработки не учитывают пространства имён; отсутствует способ квалифицировать цель инструкции обработки пространством имён.
o Использование инструкций обработки не может быть ограничено большинством языков схем,
o Ссылки на символы не распознаются внутри инструкции обработки.
o Инструкции обработки не имеют определённой XML структуры, кроме разделения между целью и всем остальным. Это означает, что приложения обычно вынуждены разбирать содержимое инструкции обработки способом, зависящим от системы; если бы содержимое было предоставлено внутри элемента, структура могла бы быть выражена в XML, а разбор мог бы выполняться XML-парсером.
4.6 Комментарии XML
Комментарий XML (определённый в разделе 2.5 документа [8]) — это компонент XML-документа, предоставляющий описательную информацию, которая не является частью символьных данных документа. Комментарии XML, подобно комментариям, используемым в языках программирования, часто применяются для предоставления поясняющей информации в понятных человеку терминах. Пример:
<!-- This is a example comment. -->
Комментарии XML могут игнорироваться соответствующими процессорами. Как следствие, настоятельно рекомендуется не использовать комментарии для определения нормативных структур данных протокола или расширений. Поэтому также настоятельно рекомендуется игнорировать комментарии при их обнаружении в обычной обработке протокола.
4.7 Валидность и расширяемость
Одно из важных достоинств XML состоит в наличии формальных механизмов определения ограничений структуры и содержимого данных; они ограничивают идентичность элементов или атрибутов либо значения, содержащиеся в них. Существует более одного такого формализма:
o «Document Type Definition» (DTD) определено в разделе 2.8 документа [8]; эта концепция возникла из аналогичного механизма для SGML. Накоплен значительный опыт использования DTD, в том числе в протоколах IETF.
Hollenbeck, et al. Best Current Practice [Page 10]
RFC 3470 XML within IETF Protocols January 2003
o XML Schema (определённая в [41] и [42]) предоставляет дополнительные возможности, позволяющие точнее и строже специфицировать допустимый синтаксис протокола и спецификации типов данных.
o Существует также ряд других механизмов описания валидности экземпляра XML; к ним относятся, например, Schematron [49] и RELAX NG [48]. Часть 2 стандарта ISO/IEC Document Schema Definition Language (DSDL, [32]) основана на RELAX NG.
В сообществе XML продолжается обсуждение (и полемика) использования и применимости различных механизмов ограничений валидности. Выбор инструмента зависит от потребностей в расширяемости либо в формальном языке и механизме ограничения допустимых значений и проверки соблюдения ограничений.
Известны случаи, когда протоколы определяли валидность с помощью того или иного механизма валидности, но определения протокола не настаивали на том, чтобы все соответствующие элементы протокола были «валидными». Решение отчасти зависит от проектирования расширяемости протокола. Каждый формализм располагает различными способами допущения будущих расширений; кроме того, проектирование протокола может предусматривать собственный механизм версионирования, способ обновления схемы или указания на новую схему. Например, использование пространств имён XML (раздел 4.9) совместно с XML Schema допускает другие виды расширяемости без нарушения валидности схемы.
Независимо от выбранного формализма обычно существуют дополнительные синтаксические ограничения и неизбежно дополнительные семантические ограничения валидности XML-элементов, которые не могут быть выражены в формализме.
Настоящий документ даёт следующие рекомендации для определения протоколов, использующих XML:
o Протоколам следует использовать подходящий формализм для определения валидности XML-элементов протокола. o Протоколы могут как требовать, так и не требовать, чтобы все соответствующие элементы протокола были действительными в соответствии с выбранным механизмом действительности; в любом случае проект расширяемости должен быть ясным. Что происходит, если данные недействительны?
o Как описано в разделе 3, в XML нет стандартного механизма для указания того, обязательно ли распознавать новые расширения. Поэтому спецификациям протоколов на основе XML следует явно описывать механизмы расширения, а также требования к распознаванию или игнорированию расширений.
Hollenbeck, et al. Best Current Practice [Page 11]
RFC 3470 XML within IETF Protocols January 2003
Идеализированная модель обработки XML могла бы сначала проверять правильность формирования; если всё в порядке, применять основной формализм и, если экземпляр «проходит» проверку, применять остальные ограничения, чтобы одновременно можно было проверить весь набор (или настолько большую его часть, насколько допускает машинная обработка).
Однако разумно разрешить соответствующим реализациям избегать выполнения валидации во время выполнения и вместо этого полагаться на специализированный код, чтобы избежать более высоких затрат, например затрат на валидацию схемы, особенно с учётом того, что, вероятно, потребуется дополнительная вручную созданная семантическая валидация.
4.8 Семантика наряду с синтаксисом
Хотя определение элемента протокола XML с использованием формализма действительности полезно, его недостаточно. XML сам по себе не предоставляет семантику. Любой документ, определяющий элемент протокола с помощью XML, ДОЛЖЕН (MUST) также содержать достаточное текстовое описание семантики того XML, который документ решил определить.
4.9 Пространства имён
Пространства имён XML, определённые в [9], предоставляют средство назначения разметки конкретному словарю. Если два элемента или атрибута из разных словарей имеют одно и то же имя, их можно однозначно различить, если они принадлежат разным пространствам имён. Кроме того, пространства имён существенно поддерживают расширяемость протоколов, поскольку их можно определять, повторно использовать и обрабатывать динамически.
Коллизии словарей разметки вполне возможны, когда пространства имён не используются для разделения и однозначной идентификации словарей. В определениях протоколов следует использовать существующие пространства имён XML там, где это уместно. Когда требуется новое пространство имён, «имя пространства имён» представляет собой URI, используемый для идентификации пространства имён; также полезно, чтобы этот URI указывал на описание пространства имён. Обычно (и в качестве практики, рекомендуемой W3C) имена пространств имён назначают с использованием постоянных http URI.
В случае пространств имён в документах IETF уровня стандартов было бы полезно иметь некоторую постоянную часть собственного веб-пространства IETF, которую можно было бы использовать для этой цели. При отсутствии такой части можно использовать другие постоянные URI, например URN в пространстве имён IETF URN (см. [11] и [12]). Хотя существуют примеры спецификаций IETF, создающих новые схемы URI для определения пространств имён XML, такая практика настоятельно не рекомендуется.
Hollenbeck, et al. Best Current Practice [Page 12]
RFC 3470 XML within IETF Protocols January 2003
4.9.1 Пространства имён и атрибуты
Часто неверно понимается один аспект связи между атрибутами без префикса и пространством имён XML по умолчанию: естественно предположить, что атрибут без префикса квалифицируется пространством имён по умолчанию, но это неверно. Напротив, атрибут без префикса вообще не принадлежит никакому пространству имён. Таким образом, в следующем примере:
<ns1:fox a="xxx" ns1:b="qqq"
xmlns="http://example.org"/>
<fox a="xxx" ns1:b="qqq"
xmlns="http://example.org" xmlns:ns1="http://example.org"/>
атрибут «a» не находится ни в каком пространстве имён, тогда как «ns1:b» находится в том же пространстве имён, что и содержащий его элемент. Конкретное описание связи между пространствами имён по умолчанию и атрибутами приведено в разделе 5.2 [9]. Практическое следствие связи между пространствами имён и атрибутами состоит в том, что необходимо позаботиться о том, чтобы ни один элемент не содержал нескольких атрибутов с идентичными именами либо с квалифицированными именами, имеющими одинаковую локальную часть и префиксы, связанные с идентичными именами пространств имён.
В приложениях XML выбор между атрибутами с префиксом и без префикса часто основывается на том, всегда ли они появляются внутри элементов одного и того же пространства имён (в этом случае используются имена без префикса и, следовательно, без пространства имён) либо требуется ли, чтобы они могли применяться к элементам в других произвольных пространствах имён (в этом случае используется имя с префиксом). Обе ситуации встречаются в языке XSLT [43]: хотя атрибуты не имеют префикса, когда они появляются внутри элементов в пространстве имён XSLT, например:
<xsl:value-of select="."/>
Hollenbeck, et al. Best Current Practice [Page 13]
RFC 3470 XML within IETF Protocols January 2003
они имеют префикс, когда появляются в элементах, не относящихся к XSLT, например атрибут «xsl:version» при использовании «literal result element stylesheets»:
<html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>Expense Report Summary</title>
</head>
<body>
<p>Total: <xsl:value-of select="exp-rep/total"/></p>
</body>
</html>
4.10 Соображения по проектированию элементов и атрибутов
XML предоставляет большую гибкость, позволяя разработчику использовать для передачи данных элементы, атрибуты или содержимое элементов. Этот раздел даёт представление о соображениях проектирования; в литературе по XML об этом написано много. Последовательное использование элементов, атрибутов и значений является важной характеристикой качественного проекта.
Атрибуты в целом предназначены для содержания метаданных, описывающих элемент, и поэтому подчиняются следующим ограничениям:
o Атрибуты не упорядочены,
o В данном элементе может быть не более одного экземпляра заданного атрибута, хотя атрибут может содержать несколько значений, разделённых пробельными символами ([8], разделы 2.3 и 3.3.1),
o Значения атрибутов не могут содержать внутреннюю разметку XML для предоставления внутренней структуры, и
o Значения атрибутов нормализуются ([8], раздел 3.3) перед обработкой.
Рассмотрим следующий пример, описывающий IP-адрес с использованием атрибута для описания значения адреса:
<address addrType="ipv4">10.1.2.3</address>
Hollenbeck, et al. Best Current Practice [Page 14]
RFC 3470 XML within IETF Protocols January 2003
Ту же информацию можно было бы закодировать, используя элемент <addrType> вместо атрибута «addrType»:
<address>
<addrType>ipv4</addrType>
<value>10.1.2.3</value>
</address>
Другой способ кодирования той же информации состоял бы в использовании разметки для «addrType»:
<address>
<addrType><ipv4/></addrType>
<value>10.1.2.3</value>
</address>
Выбор между этими проектами предполагает компромиссы, касающиеся, помимо прочего, вероятных моделей расширяемости и способности формализма надлежащим образом ограничивать значения. В первом примере атрибут можно рассматривать как метаданные элемента, который он изменяет, и как обеспечивающий своего рода «расширяемость элемента». Третий пример допускает другой вид расширяемости: пространство «ipv4» можно расширить, используя другие пространства имён, а элемент <ipv4> может включать дополнительную разметку.
Многие протоколы включают параметры, выбираемые из перечисляемого набора значений. Такие перечисляемые значения можно кодировать как элементы, атрибуты или строки внутри значений элементов. При любом проектировании протокола следует учитывать, как будет расширяться набор перечисляемых значений: пересмотром протокола, включением разных значений в разные пространства имён XML или учреждением реестра IANA (согласно RFC 2434 [18]). Кроме того, обычной практикой в XML является использование URI в качестве значения атрибута XML или содержимого.
Языки, описывающие синтаксическую действительность (включая XML Schema и DTD), часто предоставляют механизм задания «значений по умолчанию» для атрибута. Если элемент не задаёт значение атрибута, используется значение «по умолчанию». Этот документ не рекомендует использовать значения по умолчанию для атрибутов. Хотя использование этой возможности может уменьшить как размер, так и загромождённость документов XML, оно отрицательно влияет на программное обеспечение, которое не знает ограничений действительности документа (например, на трассировку пакетов или цифровую подпись).
Hollenbeck, et al. Best Current Practice [Page 15]
RFC 3470 XML within IETF Protocols January 2003
4.11 Двоичные данные и текст с управляющими символами
XML определён как поток символов, а не поток октетов. Не существует способа встроить необработанные двоичные данные непосредственно в поток данных XML; все двоичные данные должны кодироваться как символы. Возможен ряд кодировок; например, XML Schema [42] определяет кодировки с использованием десятичных цифр для целых чисел, Base64 [15] или шестнадцатеричных цифр. Кроме того, двоичные данные могут передаваться через некоторый другой канал связи, а ссылка на них может приводиться в самих данных XML с помощью URI.
Протоколам, которым необходим контейнер, способный содержать как структурные данные, так и большие объёмы двоичных данных, следует тщательно рассмотреть, подходит ли XML, поскольку кодировки Base64 и hex неэффективны. В противном случае протоколам следует использовать механизмы XML Schema для представления двоичных данных; кодировка Base64 лучше всего подходит для больших объёмов данных.
XML не допускает «управляющие» символы (0x00-0x1F), кроме TAB (0x09), CR (0x0A) и LF (0x0D). Их нельзя задавать даже с использованием ссылок на символьные сущности. В настоящее время нет общепринятого способа кодировать их в том, что в остальном является обычным текстом. Это означает, что строки, которые могли бы считаться «текстом» внутри элемента протокола, определённого ABNF, возможно, потребуется обрабатывать как двоичные данные в представлении XML либо, возможно, потребуется изобрести какой-либо иной механизм кодирования.
4.12 Инкрементальная обработка
В некоторых ситуациях возможно инкрементально обрабатывать документ XML по мере получения каждого тега; это аналогично процессу, при котором браузеры инкрементально отображают страницы HTML по мере их получения. Обратите внимание, что инкрементальную обработку трудно реализовать, если она чередуется между несколькими взаимодействиями. Иными словами, если протокол требует инкрементальной обработки в обоих направлениях двунаправленного потока, это может возложить необычную нагрузку на реализаторов протокола.
4.13 Объявления сущностей и ссылки на сущности
Помимо своей роли механизма действительности, XML DTD предоставляет средство для «объявлений сущностей» ([8], раздел 4.2). Объявление сущности определяет в DTD своего рода возможность макроса, при которой «ссылка на сущность» может использоваться для вызова и включения содержимого объявления сущности.
Hollenbeck, et al. Best Current Practice [Page 16]
RFC 3470 XML within IETF Protocols January 2003
Эта возможность добавляет сложность обработке XML и, по-видимому, более уместна для использования XML при обработке документов, чем при представлении данных. Поэтому этот документ рекомендует избегать объявлений сущностей в спецификациях протоколов.
С другой стороны, в XML встроены пять стандартных ссылок на сущности: "&", "<", ">", "'" и """. XML также позволяет записывать символьные данные с использованием числовых ссылок на сущности (используя значение Unicode [33] для символа). Ссылки на сущности обычно раскрываются до вычисления XML Information Set. Ограничение использования этих ссылок на сущности без необходимости ввело бы дополнительное синтаксическое ограничение (см. раздел 4.3); эти ссылки на сущности следует разрешать.
4.14 Внешние ссылки
При использовании XML в контексте протокола без состояния — будь то сам протокол (например, SOAP) либо просто содержимое, передаваемое существующим протоколом (например, XML/HTTP), — необходимо позаботиться о том, чтобы смысл сообщения не зависел от информации вне самого сообщения. XML предоставляет внешние сущности (см. раздел 4.13), которые являются простым способом сделать смысл сообщения зависимым от чего-либо внешнего. Использование языков схем, способных изменять Infoset, таких как XML Schema, является другим способом.
4.15 Обработка URI
Спецификация XML Base [36] определяет в пространстве имён XML атрибут «xml:base», предназначенный для влияния на «базу», используемую при обработке относительных URI, описанной в RFC 2396 [17]. Возможности xml:base по управлению обработкой URI могут быть полезны разработчикам протоколов, но если xml:base разрешён, необходимо ясно определить взаимодействие с любыми другими средствами протокола для установления контекста URI. Обратите внимание, что W3C объявил использование относительных URI в объявлениях пространств имён устаревшим; некоторые конкретные вопросы, связанные с относительными URI в объявлениях пространств имён и каноническим XML, приведены в разделе 1.3 RFC 3076 [6].Следует также отметить, что во многих случаях термин «URI» и синтаксическое использование URI в XML допускают не-ASCII-символы в URI. Например, тип данных XML Schema «anyURI» ([42], раздел 3.2.17) допускает непосредственное кодирование символов вне диапазона US-ASCII. Большинство современных протоколов и спецификаций IETF не допускают этот синтаксис. Спецификациям протоколов следует чётко указывать диапазон задаваемых символов, например добавляя ограничение на диапазон символов, разрешённых в типе данных схемы anyURI, либо указывая, что символы вне диапазона US-ASCII следует экранировать при передаче в старые протоколы или API.
Hollenbeck, et al. Best Current Practice [Page 17]
RFC 3470 XML within IETF Protocols January 2003
4.16 Пробельные символы
Предписанное XML поведение при обработке пробельных символов может быть источником недопонимания между разработчиками протоколов и реализаторами. В XML-экземплярах все пробельные символы считаются значимыми и по умолчанию видимы приложениям обработки. Рассмотрим этот пример из раздела 4.10:
<address>
<addrType><ipv4/></addrType>
<value>10.1.2.3</value>
</address>
Этот фрагмент содержит элемент <address> и два дочерних элемента. Он также содержит пробельные символы для целей красивого форматирования:
o по меньшей мере три разделителя строк, которые XML-процессор преобразует в символы новой строки (U+000A) (см. раздел 2.11 документа [8]), и
o один или более пробельных символов перед элементами <addrType> и <value>, которые XML-процессор сделает видимыми программному обеспечению, читающему экземпляр.
Реализаторы могут безопасно предположить, что могут игнорировать пробельные символы в приведённом выше примере, но пробельные символы, используемые для красивого форматирования, могут быть источником недопонимания в других ситуациях. Рассмотрим небольшое изменение элемента <value>:
<value>
10.1.2.3
</value>
где пробельные символы находятся с обеих сторон IP-адреса. XML-процессоры рассматривают пробельные символы, окружающие «10.1.2.3», как неотъемлемую часть элемента <value>. Неспособность распознать это поведение может привести к недопониманию и ошибкам как при проектировании, так и при реализации.
Все пробельные символы считаются значимыми в XML-экземплярах. Следовательно, рекомендуется, чтобы разработчики протоколов предоставляли конкретные указания по обработке пробельных символов в протоколах, использующих XML.
Hollenbeck, et al. Best Current Practice [Page 18]
RFC 3470 XML within IETF Protocols January 2003
4.17 Взаимодействие с IANA
Когда XML используется в протоколе IETF, существует несколько факторов, которые могут потребовать действий IANA, включая:
o Типы носителей XML. Фрагмент XML в элементе протокола иногда неразрывно связан с контекстом протокола, в котором он появляется, и, в частности, может быть непосредственно производным от реализаций конечного автомата протокола и/или входными данными для них. В случаях, когда XML-содержимое не имеет относящегося к делу значения вне исходного контекста протокола, нет причин регистрировать MIME-тип. Когда возможно, что XML-содержимое может интерпретироваться вне исходного контекста (например, когда это XML-содержимое хранится в файловой системе или туннелируется через другой протокол), MIME-тип может быть зарегистрирован, чтобы определить конкретный формат данных и дать подсказку о том, как они могут обрабатываться.
Если необходима MIME-маркировка, применимы рекомендации RFC 3023 [5]. В частности, если XML представляет новый язык или тип документа, следует зарегистрировать новый MIME-тип носителя по причинам, описанным в разделах 7 и A.1 RFC 3023. В ситуациях, когда XML используется для кодирования универсальных структурированных данных (например, в ориентированном на документы приложении, предусматривающем объединение XML с таблицей стилей), «application/xml» может быть уместным («МОЖЕТ использоваться» (MAY be used)). Тип носителя «text/xml» не рекомендуется («НЕ СЛЕДУЕТ использовать» (SHOULD NOT be used)) из-за вопросов, связанных с поведением отображения и наборами символов по умолчанию.
o Регистрация URI. Ведётся работа ([11], [12]) по созданию пространства имён URN специально для определения URI для имён пространств имён и других обозначаемых URI элементов протокола, используемых в документах IETF стандартизируемого направления; она также может установить политику IETF для такого использования.
5. Вопросы интернационализации
В этом разделе описываются вопросы интернационализации при использовании XML для представления данных в протоколах IETF. В дополнение к приведённым здесь рекомендациям также применяется политика IETF по использованию наборов символов и языков, описанная в RFC 2277 [3].
5.1 Наборы символов и кодировки
В протоколах IETF часто говорят о «наборе символов» или «charset» строки; это используется для обозначения как репертуара символов, так и кодировки, используемой для представления последовательностей символов в виде последовательностей байтов.
Hollenbeck, et al. Best Current Practice [Page 19]
RFC 3470 XML within IETF Protocols January 2003
XML выполняет всю обработку символов в терминах Универсального набора символов (UCS, [31] и [33]). XML требует, чтобы все XML-процессоры поддерживали как кодировку UTF-8 [4], так и UTF-16 [20] для UCS, хотя могут быть разрешены и другие совместимые с UCS кодировки (наборы символов). Документы и внешние разобранные сущности, закодированные в UTF-16, должны начинаться с метки порядка байтов (Byte Order Mark) ([8], раздел 4.3.3).
Политика IETF [3] требует, чтобы набор символов UTF-8 был разрешён для всего текста.
Этот документ требует, чтобы протоколы IETF, использующие XML, допускали кодировку данных XML UTF-8. Поскольку соответствующие XML-процессоры также обязаны принимать кодировку UTF-16, рекомендуется также допускать кодировку UTF-16 (с обязательной меткой порядка байтов). Некоторые XML-приложения используют метку порядка байтов с кодировкой UTF-8, но такое использование не следует поощрять, и оно не подходит для XML, встроенного в другие протоколы.
Ограничение данных XML возможностью выражаться только в UTF-8 является дополнительным синтаксическим ограничением (см. раздел 4.3), которое в зависимости от обстоятельств может добавлять дополнительную сложность реализации. Когда используются кодировки, отличные от UTF-8 или UTF-16, кодировка должна быть указана с использованием атрибута «encoding» в XML-декларации (см. раздел 4.4), даже если могут существовать другие механизмы протокола для обозначения кодировки.
5.2 Объявление языка
Текст, заключённый в XML, может быть представлен на множестве различных человеческих языков, и часто полезно явно идентифицировать язык, используемый для представления текста. XML определяет специальный атрибут в пространстве имён «xml», xml:lang, который может использоваться для указания языка, применённого для представления данных в XML-документе. Атрибут xml:lang (который должен быть явно объявлен для использования в DTD или XML Schema) и значения, которые он может принимать, определены в разделе 2.12 документа [8].
Настоятельно рекомендуется, чтобы протоколы, представляющие данные на человеческом языке, предписывали использование атрибута xml:lang, если XML-экземпляр может интерпретироваться в зависимых от языка контекстах.
5.3 Другие вопросы интернационализации
В типографике некоторых человеческих языков существуют стандартные механизмы, которые может быть трудно представить, используя лишь строковые типы данных символов XML. Например, подсказки произношения могут предоставляться с использованием аннотации Ruby [39], а управляющие символы встраивания (такие как описанные в разделе 3.4 документа [34]) или атрибут XHTML [40] «dir» могут использоваться для указания правильного направления отображения двунаправленного текста.
Hollenbeck, et al. Best Current Practice [Page 20]
RFC 3470 XML within IETF Protocols January 2003
Существует ряд сложных вопросов, которые могут возникнуть при использовании расширенных наборов символов с форматами XML-документов. Например:
o Существуют разные способы представления символов, состоящих из комбинируемых символов, и
o Велись некоторые споры о том, должны ли URI представляться с использованием ограниченного подмножества US-ASCII или произвольного Unicode (например, «URI character sequence» в сравнении с «original character sequence» в RFC 2396 [17]).
Некоторые из этих вопросов обсуждаются вместе с рекомендациями в документе W3C «Character Model for the World Wide Web» [44].
Настоятельно рекомендуется, чтобы протоколы, представляющие данные на человеческом языке, повторно использовали существующие механизмы по мере необходимости, чтобы обеспечить правильное отображение читаемого человеком текста.
6. Вопросы IANA
Эта памятка как таковая не оказывает влияния на IANA. В разделе 4.17 отмечены некоторые факторы, которые могут потребовать действий IANA при определении протоколов, использующих XML.
7. Вопросы безопасности
Сетевые протоколы сталкиваются со множеством различных видов угроз, включая непреднамеренное раскрытие, изменение и повторную передачу. Пассивные атаки, такие как перехват пакетов, позволяют атакующему захватывать и просматривать информацию, предназначенную для другого лица. Захваченные данные могут быть изменены и повторно переданы исходному предполагаемому получателю, при этом у получателя нет способа узнать, что информация была скомпрометирована, обнаружить изменения, удостовериться в личности отправителя или подтвердить, какой экземпляр протокола является законным.
Доступны несколько вариантов служб безопасности для XML, помогающих снизить эти риски. Хотя XML не включает встроенных служб безопасности, другие протоколы и уровни протоколов предоставляют службы, которые могут использоваться для защиты XML-протоколов. XML-шифрование [10] предоставляет службы конфиденциальности для предотвращения непреднамеренного раскрытия. Канонический XML [6] и цифровые подписи XML [7] предоставляют службы целостности для обнаружения изменения и службы аутентификации для подтверждения идентичности источника данных. Другие протоколы безопасности IETF (например, протокол Transport Layer Security (TLS) [2]) также доступны для защиты данных и конечных точек служб в зависимости от обстоятельств.
Hollenbeck, et al. Best Current Practice [Page 21]
RFC 3470 XML within IETF Protocols January 2003
Учитывая отсутствие служб безопасности в XML, крайне важно, чтобы спецификации протоколов предписывали дополнительные службы безопасности для противодействия распространённым угрозам и атакам; конкретные требуемые службы будут зависеть от модели угроз протокола.
Опыт показал, что код, разбирающий сетевой трафик, часто является «лёгкой целью» для злоумышленников. Соответственно, реализаторы ДОЛЖНЫ (MUST) проявлять большую осторожность, чтобы гарантировать устойчивость их кода обработки XML к некорректно сформированному XML, переполнениям буфера, неправомерному использованию объявлений сущностей и тому подобному.
Механизмы XML, которые следуют внешним ссылкам (раздел 4.14), также могут подвергать реализацию различным угрозам, заставляя её автоматически обращаться к внешним ресурсам. Важно запретить произвольный доступ к таким внешним ссылкам внутри XML-данных из недоверенных источников. Многие грамматики XML определяют конструкции, использующие URI для внешних ссылок; в таких случаях должны быть приняты те же меры предосторожности.
8. Благодарности
Авторы хотели бы поблагодарить следующих людей, которые внесли значительный вклад в разработку этого документа:
Mark Baker, Tim Berners-Lee, Tim Bray, James Clark, Josh Cohen, John Cowan, Alan Crouch, Martin Duerst, Jun Fujisawa, Christian Geuer-Pollmann, Yaron Goland, Graham Klyne, Dan Kohn, Rick Jeliffe, Chris Lilley, Murata Makoto, Michael Mealling, Jean-Jacques Moreau, Andrew Newton, Julian Reschke, Jonathan Rosenberg, Miles Sabin, Rich Salz, Peter Saint-Andre, Simon St Laurent, Margaret Wasserman и Daniel Veillard.
9. Нормативные ссылки
[1] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
[2] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC 2246, January 1999.
[3] Alvestrand, H., "IETF Policy on Character Sets and Languages", BCP 18, RFC 2277, January 1998.
[4] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 2279, January 1998.
Hollenbeck, et al. Best Current Practice [Page 22]
RFC 3470 XML within IETF Protocols January 2003
[5] Murata, M., St. Laurent, S. and D. Kohn, "XML Media Types", RFC 3023, January 2001.
[6] Boyer, J., "Canonical XML Version 1.0", RFC 3076, March 2001.
[7] Eastlake, D., Reagle, J. and D. Solo, "(Extensible Markup Language) XML-Signature Syntax and Processing", RFC 3275, March 2002.
[8] Bray, T., Paoli, J., Sperberg-McQueen, C. and E. Maler, "Extensible Markup Language (XML) 1.0 (2nd ed)", W3C REC-xml, October 2000, <http://www.w3.org/TR/REC-xml>.
[9] Bray, T., Hollander, D. and A. Layman, "Namespaces in XML", W3C REC-xml-names, January 1999, <http://www.w3.org/TR/REC-xml-names>.
[10] Imamura, T., Dillaway, B., Schaad, J. and E. Simon, "XML Encryption Syntax and Processing", W3C REC-xmlenc-core, October 2001, <http://www.w3.org/TR/xmlenc-core/>.
10. Справочные ссылки
[11] Masinter, L., Mealling, M., Klyne, G. and T. Hardie, "An IETF URN Sub-namespace for Registered Protocol Parameters", Work in Progress.
[12] Mealling, M., "The IETF XML Registry", Work in Progress.
[13] Case, J., Fedor, M., Schoffstall, M. and C. Davin, "Simple Network Management Protocol (SNMP)", STD 15, RFC 1157, May 1990.
[14] Srinivasan, R., "XDR: External Data Representation Standard", RFC 1832, August 1995.[15] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
Extensions (MIME) Part One: Format of Internet Message Bodies",
RFC 2045, November 1996.
[16] Crocker, D. (Ed.) and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", RFC 2234, November 1997.
[17] Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform
Resource Identifiers (URI): Generic Syntax", RFC 2396, August
1998.
Hollenbeck, et al. Лучшая современная практика [Страница 23]
RFC 3470 XML в протоколах IETF Январь 2003
[18] Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA
Considerations Section in RFCs", BCP 26, RFC 2434, October
1998.
[19] Rose, M., "Writing I-Ds and RFCs using XML", RFC 2629, June
1999.
[20] Hoffman, P. and F. Yergeau, "UTF-16, an encoding of ISO 10646",
RFC 2781, February 2000.
[21] Klensin, J. (Ed.), "Simple Mail Transfer Protocol", RFC 2821,
April 2001.
[22] Shepler, S., Callaghan, B., Robinson, D., Thurlow, R., Beame,
C., Eisler, M. and D. Noveck, "NFS version 4 Protocol", RFC
3010, December 2000.
[23] Kennedy, H., "Binary Lexical Octet Ad-hoc Transport", RFC 3252,
April 2002.
[24] Popp, N., Mealling, M. and M. Moseley, "Common Name Resolution
Protocol (CNRP)", RFC 3367, August 2002.
[25] Backus, J., "The syntax and semantics of the proposed
international algebraic language of the Zurich ACM-GAMM
conference", June 1959.
[26] American National Standards Institute, "Code Extension
Techniques for Use with the 7-bit Coded Character Set of
American National Standard Code (ASCII) for Information
Interchange", ANSI X3.41, FIPS PUB 35, 1974.
[27] American National Standards Institute, "Information Retrieval:
Application Service Definition and Protocol Specification",
ANSI Z39.50, ISO Standard 23950, 1995.
[28] International Organization for Standardization, "Information
Processing Systems - Open Systems Interconnection -
Specification of Abstract Syntax Notation One (ASN.1)", ISO
Standard 8824, December 1990.
[29] International Organization for Standardization, "Information
Processing Systems - Open Systems Interconnection -
Specification of Basic Encoding Rules for Abstract Syntax
Notation One (ASN.1)", ISO Standard 8825, December 1990.
Hollenbeck, et al. Лучшая современная практика [Страница 24]
RFC 3470 XML в протоколах IETF Январь 2003
[30] International Organization for Standardization, "Information
processing - Text and office systems - Standard Generalized
Markup Language (SGML)", ISO Standard 8879, 1988.
[31] International Organization for Standardization, "Information
Technology - Universal Multiple-octet coded Character Set (UCS)
- Part 1: Architecture and Basic Multilingual Plane", ISO
Standard 10646-1, May 1993.
[32] International Organization for Standardization, "DSDL Part 0 -
Overview", December 2001, <http://www.jtc1.org/FTP/Public/SC34/
DOCREG/0275.htm>.
[33] Unicode Consortium, "The Unicode Standard, as it may from time
to time be revised or amended", March 2002, <http://
www.unicode.org/unicode/standard/standard.html>.
[34] Duerst, M. and A. Freytag, "Unicode in XML and other Markup
Languages", February 2002, <http://www.w3.org/TR/unicode-xml/>.
[35] Bray, T., Paoli, J. and C. Sperberg-McQueen, "Extensible Markup
Language (XML) 1.0", W3C REC-xml-1998, February 1998, <http://
www.w3.org/TR/1998/REC-xml-19980210/>.
[36] Marsh, J., "XML Base", W3C REC-xmlbase, June 2001, <http://
www.w3.org/TR/xmlbase/>.
[37] Cowan, J. and R. Tobin, "XML Information Set", W3C REC-infoset,
October 2001, <http://www.w3.org/TR/xml-infoset/>.
[38] Lassila, O. and R. Swick, "Resource Description Framework (RDF)
Model and Syntax Specification", W3C REC-rdf-syntax, February
1999, <http://www.w3.org/TR/REC-rdf-syntax>.
[39] Suignard, M., Ishikawa, M., Duerst, M. and T. Texin, "Ruby
Annotation", W3C REC-RUBY, May 2001, <http://www.w3.org/TR/
ruby/>.
[40] Pemberton, S., "XHTML 1.0: The Extensible HyperText Markup
Language", W3C REC-XHTML, January 2000, <http://www.w3.org/TR/
xhtml1/>.
[41] Thompson, H., Beech, D., Maloney, M. and N. Mendelsohn, "XML
Schema Part 1: Structures", W3C REC-xmlschema-1, May 2001,
<http://www.w3.org/TR/xmlschema-1/>.
[42] Biron, P. and A. Malhotra, "XML Schema Part 2: Datatypes", W3C
REC-xmlschema-2, May 2001, <http://www.w3.org/TR/xmlschema-2/>.
Hollenbeck, et al. Лучшая современная практика [Страница 25]
RFC 3470 XML в протоколах IETF Январь 2003
[43] Clark, J., "XSL Transformations (XSLT) Version 1.0", W3C REC-
xslt, November 1999, <http://www.w3.org/TR/xslt>.
[44] Duerst, M., Yergeau, F., Ishida, R., Wolf, M., Freytag, A. and
T. Texin, "Character Model for the World Wide Web 1.0", April
2002, <http://www.w3.org/TR/charmod/>.
[45] Gudgin, M., Hadley, M., Moreau, JJ. and H. Nielsen, "SOAP
Version 1.2 Part 1: Messaging Framework", June 2002,
<http://www.w3.org/TR/soap12-part1/>.
[46] Gudgin, M., Hadley, M., Moreau, JJ. and H. Nielsen, "SOAP
Version 1.2 Part 2: Adjuncts", June 2002,
<http://www.w3.org/TR/soap12-part2/>.
[47] W3C Communications Team, "XML in 10 points", November 2001,
<http://www.w3.org/XML/1999/XML-in-10-points>.
[48] OASIS Technical Committee: RELAX NG, "RELAX NG Specification",
December 2001, <http://www.oasis-open.org/committees/relax-ng/
spec-20011203.html>.
[49] Jelliffe, R., "The Schematron", November 2001, <http://
www.ascc.net/xml/schematron/>.
URI (универсальные идентификаторы ресурсов)
[50] <http://www.imc.org/ietf-xml-use/>
[51] <http://xml.org/>
[52] <http://xmlhack.com/>
[53] <http://oasis-open.org/>
Hollenbeck, et al. Лучшая современная практика [Страница 26]
RFC 3470 XML в протоколах IETF Январь 2003
11. Адреса авторов
Scott Hollenbeck
VeriSign, Inc.
21345 Ridgetop Circle
Dulles, VA 20166-6503
US
Phone: +1 703 948 3257
EMail: shollenbeck@verisign.com
Marshall T. Rose
Dover Beach Consulting, Inc.
POB 255268
Sacramento, CA 95865-5268
US
Phone: +1 916 483 8878
EMail: mrose@dbc.mtview.ca.us
Larry Masinter
Adobe Systems Incorporated
Mail Stop W14
345 Park Ave.
San Jose, CA 95110
US
Phone: +1 408 536 3024
EMail: LMM@acm.org
URI: http://larry.masinter.net
Hollenbeck, et al. Лучшая современная практика [Страница 27]
RFC 3470 XML в протоколах IETF Январь 2003
12. Полное заявление об авторском праве
Copyright (C) The Internet Society (2003). All Rights Reserved.
Этот документ и его переводы могут копироваться и предоставляться другим лицам, а производные работы, которые комментируют или иным образом разъясняют его либо содействуют его реализации, могут подготавливаться, копироваться, публиковаться и распространяться полностью или частично без каких-либо ограничений при условии, что приведённое выше уведомление об авторском праве и этот абзац включены во все такие копии и производные работы. Однако сам этот документ не может быть каким-либо образом изменён, например путём удаления уведомления об авторском праве или ссылок на Internet Society либо другие интернет-организации, кроме случаев, когда это необходимо для разработки интернет-стандартов, при которой должны соблюдаться процедуры, касающиеся авторских прав, определённые в процессе разработки интернет-стандартов, либо когда это необходимо для перевода его на языки, отличные от английского.
Предоставленные выше ограниченные разрешения являются бессрочными и не будут отозваны Internet Society или её правопреемниками либо цессионариями.
Этот документ и содержащаяся в нём информация предоставляются на условиях «КАК ЕСТЬ», И INTERNET SOCIETY И INTERNET ENGINEERING TASK FORCE ОТКАЗЫВАЮТСЯ ОТ ВСЕХ ГАРАНТИЙ, ЯВНЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ, ПОМИМО ПРОЧЕГО, ЛЮБУЮ ГАРАНТИЮ ТОГО, ЧТО ИСПОЛЬЗОВАНИЕ СОДЕРЖАЩЕЙСЯ ЗДЕСЬ ИНФОРМАЦИИ НЕ НАРУШИТ КАКИХ-ЛИБО ПРАВ, А ТАКЖЕ ЛЮБЫЕ ПОДРАЗУМЕВАЕМЫЕ ГАРАНТИИ КОММЕРЧЕСКОЙ ПРИГОДНОСТИ ИЛИ ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЁННОЙ ЦЕЛИ.
Благодарность
Финансирование функции RFC Editor в настоящее время предоставляется Internet Society.
Hollenbeck, et al. Лучшая современная практика [Страница 28]
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,
<?xml version="1.0" encoding="UTF-8"?>
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:
<?rfc toc="yes"?>
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:
<!-- This is a example comment. -->
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:
<ns1:fox a="xxx" ns1:b="qqq"
xmlns="http://example.org"/>
<fox a="xxx" ns1:b="qqq"
xmlns="http://example.org" xmlns:ns1="http://example.org"/>
the attribute "a" is in no namespace, while "ns1:b" is the same
namespace as the containing element. A specific description of the
relationship between default namespaces and attributes can be found
in section 5.2 of [9]. The practical implication of the relationship
between namespaces and attributes is that care must be taken to
ensure that no element contains multiple attributes that have
identical names or have qualified names with the same local part and
with prefixes which have been bound to namespace names that are
identical.
In XML applications, the choice between prefixed and non-prefixed
attributes frequently is based on whether they always appear inside
elements of the same namespace (in which case non-prefixed and
thereby non-namespaced names are used) or whether it's required that
they can be applied to elements in other arbitrary namespaces (in
which case a prefixed name is used). Both situations occur in the
XSLT [43] language: while attributes are unprefixed when they occur
inside elements in the XSLT namespace, such as:
<xsl:value-of select="."/>
Hollenbeck, et al. Best Current Practice [Page 13]
RFC 3470 XML within IETF Protocols January 2003
they are prefixed when they appear in non-XSLT elements, such as the
"xsl:version" attribute when using "literal result element
stylesheets":
<html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>Expense Report Summary</title>
</head>
<body>
<p>Total: <xsl:value-of select="exp-rep/total"/></p>
</body>
</html>
4.10 Element and Attribute Design Considerations
XML provides much flexibility in allowing a designer to use either
elements, attributes, or element content to carry data. This section
gives a flavor of the design considerations; there is much written
about this in the XML literature. Consistent use of elements,
attributes, and values is an important characteristic of a sound
design.
Attributes are generally intended to contain meta-data that describes
the element, and as such they are subject to the following
restrictions:
o Attributes are unordered,
o There can be no more than one instance of a given attribute within
a given element, though an attribute may contain several values
separated by white space ([8], section 2.3 and 3.3.1),
o Attribute values can have no internal XML markup for providing
internal structure, and
o Attribute values are normalized ([8], section 3.3) before
processing
Consider the following example that describes an IP address using an
attribute to describe the address value:
<address addrType="ipv4">10.1.2.3</address>
Hollenbeck, et al. Best Current Practice [Page 14]
RFC 3470 XML within IETF Protocols January 2003
One might encode the same information using an <addrType> element
instead of an "addrType" attribute:
<address>
<addrType>ipv4</addrType>
<value>10.1.2.3</value>
</address>
Another way of encoding the same information would be to use markup
for the "addrType":
<address>
<addrType><ipv4/></addrType>
<value>10.1.2.3</value>
</address>
Choosing between these designs involves tradeoffs concerning, among
other considerations, the likely extensibility patterns and the
ability of the formalism to constrain the values appropriately. In
the first example, the attribute can be thought of as meta-data to
the element which it modifies, and provides for a kind of "element
extensibility". The third example allows for a different kind of
extensibility: the "ipv4" space can be extended using other
namespaces, and the <ipv4> element can include additional markup.
Many protocols include parameters that are selected from an
enumerated set of values. Such enumerated values can be encoded as
elements, attributes, or strings within element values. Any protocol
design should consider how the set of enumerated values is to be
extended: by revising the protocol, by including different values in
different XML namespaces, or by establishing an IANA registry (as per
RFC 2434 [18]). In addition, a common practice in XML is to use a
URI as an XML attribute value or content.
Languages that describe syntactic validity (including XML Schema and
DTDs) often provide a mechanism for specifying "default" values for
an attribute. If an element does not specify a value for the
attribute, then the "default" value is used. The use of default
values for attributes is discouraged by this document. Although the
use of this feature can reduce both the size and clutter of XML
documents, it has a negative impact on software which doesn't know
the document's validity constraints (e.g., for packet tracing or
digital signature).
Hollenbeck, et al. Best Current Practice [Page 15]
RFC 3470 XML within IETF Protocols January 2003
4.11 Binary Data and Text with Control Characters
XML is defined as a character stream rather than a stream of octets.
There is no way to embed raw binary data directly within an XML data
stream; all binary data must be encoded as characters. There are a
number of possible encodings; for example, XML Schema [42] defines
encodings using decimal digits for integers, Base64 [15], or
hexadecimal digits. In addition, binary data might be transmitted
using some other communication channel, and referenced within the XML
data itself using a URI.
Protocols that need a container that can hold both structural data
and large quantities of binary data should consider carefully whether
XML is appropriate, since the Base64 and hex encodings are
inefficient. Otherwise, protocols should use the mechanisms of XML
Schema to represent binary data; the Base64 encoding is best for
larger quantities of data.
XML does not allow "control" characters (0x00-0x1F) except for TAB
(0x09), CR (0x0A), and LF (0x0D). They can not be specified even
using character entity references. There is currently no common way
of encoding them within what is otherwise ordinary text. This means
that strings that might be considered "text" within an ABNF-defined
protocol element may need to be treated as binary data within an XML
representation, or some other encoding mechanism might need to be
invented.
4.12 Incremental Processing
In some situations, it is possible to incrementally process an XML
document as each tag is received; this is analogous to the process by
which browsers incrementally render HTML pages as they are received.
Note that incremental processing is difficult to implement if
interspersed across multiple interactions. In other words, if a
protocol requires incremental processing across both directions of a
bidirectional stream, then it may place an unusual burden on protocol
implementers.
4.13 Entity Declarations and Entity References
In addition to its role as a validity mechanism, an XML DTD provides
a facility for "entity declarations" ([8], section 4.2). An entity
declaration defines, in the DTD, a kind of macro capability where an
"entity reference" may be used to call up and include the content of
the entity declaration.
Hollenbeck, et al. Best Current Practice [Page 16]
RFC 3470 XML within IETF Protocols January 2003
This feature adds complexity to XML processing, and seems more
appropriate for use of XML in document processing than in data
representation. As such, this document recommends avoiding entity
declarations in protocol specifications.
On the other hand, there are five standard entity references built
into XML: "&", "<", ">", "'", and """. XML also
has the ability to write character data using numeric entity
references (using the Unicode [33] value for the character). Entity
references are normally expanded before the XML Information Set is
computed. Restricting the use of these entity references would
introduce an additional syntactic restriction (see Section 4.3)
unnecessarily; these entity references should be allowed.
4.14 External References
When using XML in the context of a stateless protocol, be it the
protocol itself (e.g., SOAP), or simply as content transferred by an
existing protocol (e.g., XML/HTTP), care must be taken to not make
the meaning of a message depend on information outside the message
itself. XML provides external entities (see Section 4.13), which are
an easy way to make the meaning of a message depend on something
external. Using schema languages that can change the Infoset, like
XML Schema, is another way.
4.15 URI Processing
The XML Base specification [36] defines an attribute "xml:base" in
the XML namespace that is intended to affect the "base" to be used
for relative URI processing described in RFC 2396 [17]. The
facilities of xml:base for controlling URI processing may be useful
to protocol designers, but if xml:base is allowed the interaction
with any other protocol facilities for establishing URI context must
be specified clearly. Note that use of relative URIs in namespace
declarations has been deprecated by the W3C; some specific issues
with relative URIs in namespace declarations and canonical XML can be
found in section 1.3 of RFC 3076 [6].
Note also that, in many cases, the term "URI" and the syntactic use
of URIs within XML allows non-ASCII characters within URIs. For
example, the XML Schema "anyURI" datatype ([42] section 3.2.17)
allows for direct encoding of characters outside of the US-ASCII
range. Most current IETF protocols and specifications do not allow
this syntax. Protocol specifications should be clear about the range
of characters specified, e.g., by adding a restriction to the range
of characters allowed in the anyURI schema datatype, or by specifying
that characters outside the US-ASCII range should be escaped when
passed to older protocols or APIs.
Hollenbeck, et al. Best Current Practice [Page 17]
RFC 3470 XML within IETF Protocols January 2003
4.16 White Space
XML's prescribed white space handling behavior can be a source of
confusion between protocol designers and implementers. In XML
instances all white space is considered significant and is by default
visible to processing applications. Consider this example from
Section 4.10:
<address>
<addrType><ipv4/></addrType>
<value>10.1.2.3</value>
</address>
This fragment contains an <address> element and two child elements.
It also contains white space for pretty-printing purposes:
o at least three line separators, which will be converted by the XML
processor to newline (U+000A) characters (see section 2.11 of
[8]), and
o one or more white space characters prefixing the <addrType> and
<value> elements, which an XML processor will make visible to
software reading the instance.
Implementers might safely assume that they can ignore the white space
in the example above, but white space used for pretty-printing can be
a source of confusion in other situations. Consider a minor change
to the <value> element:
<value>
10.1.2.3
</value>
where white space is found on both sides of the IP address. XML
processors treat the white space surrounding "10.1.2.3" as an
integral part of the <value> element. A failure to recognize this
behavior can lead to confusion and errors in both design and
implementation.
All white space is considered significant in XML instances. As a
consequence, it is recommended that protocol designers provide
specific guidelines to address white space handling within protocols
that use XML.
Hollenbeck, et al. Best Current Practice [Page 18]
RFC 3470 XML within IETF Protocols January 2003
4.17 Interaction with the IANA
When XML is used in an IETF protocol there are multiple factors that
might require IANA action, including:
o XML media types. A piece of XML in a protocol element is
sometimes intrinsically bound to the protocol context in which it
appears, and in particular might be directly derived from and/or
input to protocol state-machine implementations. In cases where
the XML content has no relevant meaning outside it's original
protocol context, there is no reason to register a MIME type.
When it is possible that XML content can be interpreted outside of
its original context (such as when that XML content is being
stored in a file system or tunneled over another protocol), then a
MIME type can be registered to specify the specific format for the
data and to provide a hint as to how it might be processed.
If MIME labeling is needed, then the advice of RFC 3023 [5]
applies. In particular, if the XML represents a new language or
document type, a new MIME media type should be registered for the
reasons described in RFC 3023 sections 7 and A.1. In situations
where XML is used to encode generic structured data (e.g., a
document-oriented application that involves combining XML with a
stylesheet), "application/xml" might be appropriate ("MAY be
used"). The "text/xml" media type is not recommended ("SHOULD NOT
be used") because of issues involving display behavior and default
charsets.
o URI registration. There is an ongoing effort ([11], [12]) to
create a URN namespace explicitly for defining URIs for namespace
names and other URI-designated protocol elements for use within
IETF standards track documents; it might also establish IETF
policy for such use.
5. Internationalization Considerations
This section describes internationalization considerations for the
use of XML to represent data in IETF protocols. In addition to the
recommendations here, IETF policy on the use of character sets and
languages described in RFC 2277 [3] also applies.
5.1 Character Sets and Encodings
IETF protocols frequently speak of the "character set" or "charset"
of a string, which is used to denote both the character repertoire
and the encoding used to represent sequences of characters as
sequences of bytes.
Hollenbeck, et al. Best Current Practice [Page 19]
RFC 3470 XML within IETF Protocols January 2003
XML performs all character processing in terms of the Universal
Character Set (UCS, [31] and [33]). XML requires all XML processors
to support both the UTF-8 [4] and UTF-16 [20] encodings of UCS,
although other encodings (charsets) compatible with UCS may be
allowed. Documents and external parsed entities encoded in UTF-16
are required to begin with a Byte Order Mark ([8] section 4.3.3).
IETF policy [3] requires that the UTF-8 charset be allowed for all
text.
This document requires that IETF protocols using XML allow for the
UTF-8 encoding of XML data. Since conforming XML processors are
mandated to also accept UTF-16 encoding, also allowing for UTF-16
encoding (with the mandated Byte Order Mark) is recommended. Some
XML applications are using a Byte Order Mark with UTF-8 encoding, but
this use should not be encouraged and isn't appropriate for XML
embedded in other protocols.
Restricting XML data to only be expressed in UTF-8 is an additional
syntactic restriction (see Section 4.3) which, depending on
circumstances, might add additional implementation complexity. When
encodings other than UTF-8 or UTF-16 are used, the encoding must be
specified using an "encoding" attribute in the XML declaration (see
Section 4.4), even if there might be other protocol mechanisms for
designating the encoding.
5.2 Language Declaration
Text encapsulated in XML can be represented in many different human
languages, and it is often useful to explicitly identify the language
used to present the text. XML defines a special attribute in the
"xml" namespace, xml:lang, that can be used to specify the language
used to represent data in an XML document. The xml:lang attribute
(which has to be explicitly declared for use within a DTD or XML
Schema) and the values it can assume are defined in section 2.12 of
[8].
It is strongly recommended that protocols representing data in a
human language mandate use of an xml:lang attribute if the XML
instance might be interpreted in language-dependent contexts.
5.3 Other Internationalization Considerations
There are standard mechanisms in the typography of some human
languages that can be difficult to represent using merely XML
character string data types. For example, pronunciation clues can be
provided using Ruby annotation [39], and embedding controls (such as
those described in section 3.4 of [34]) or an XHTML [40] "dir"
Hollenbeck, et al. Best Current Practice [Page 20]
RFC 3470 XML within IETF Protocols January 2003
attribute can be used to note the proper display direction for
bidirectional text.
There are a number of tricky issues that can arise when using
extended character sets with XML document formats. For example:
o There are different ways of representing characters consisting of
combining characters, and
o There has been some debate about whether URIs should be
represented using a restricted US-ASCII subset or arbitrary
Unicode (e.g., "URI character sequence" vs "original character
sequence" in RFC 2396 [17]).
Some of these issues are discussed, with recommendations, in the
W3C's "Character Model for the World Wide Web" document [44].
It is strongly recommended that protocols representing data in a
human language reuse existing mechanisms as needed to ensure proper
display of human-legible text.
6. IANA Considerations
This memo, per se, has no impact on the IANA. Section 4.17 notes
some factors that might require IANA action when protocols using XML
are defined.
7. Security Considerations
Network protocols face many different kinds of threats, including
unintended disclosure, modification, and replay. Passive attacks,
such as packet sniffing, allow an attacker to capture and view
information intended for someone else. Captured data can be modified
and replayed to the original intended recipient, with the recipient
having no way to know that the information has been compromised,
detect modifications, be assured of the sender's identity, or to
confirm which protocol instance is legitimate.
Several security service options for XML are available to help
mitigate these risks. Though XML does not include any built-in
security services, other protocols and protocol layers provide
services that can be used to protect XML protocols. XML encryption
[10] provides privacy services to prevent unintended disclosure.
Canonical XML [6] and XML digital signatures [7] provide integrity
services to detect modification and authentication services to
confirm the identity of the data source. Other IETF security
protocols (e.g., the Transport Layer Security (TLS) protocol [2]) are
also available to protect data and service endpoints as appropriate.
Hollenbeck, et al. Best Current Practice [Page 21]
RFC 3470 XML within IETF Protocols January 2003
Given the lack of security services in XML, it is imperative that
protocol specifications mandate additional security services to
counter common threats and attacks; the specific required services
will depend on the protocol's threat model.
Experience has shown that code that parses network traffic is often a
"soft target" for blackhats. Accordingly, implementers MUST take
great care to ensure that their XML handling code is robust with
respect to malformed XML, buffer overruns, misuse of entity
declarations, and so on.
XML mechanisms that follow external references (Section 4.14) may
also expose an implementation to various threats by causing the
implementation to access external resources automatically. It is
important to disallow arbitrary access to such external references
within XML data from untrusted sources. Many XML grammars define
constructs using URIs for external references; in such cases, the
same precautions must be taken.
8. Acknowledgements
The authors would like to thank the following people who have
provided significant contributions to the development of this
document:
Mark Baker, Tim Berners-Lee, Tim Bray, James Clark, Josh Cohen, John
Cowan, Alan Crouch, Martin Duerst, Jun Fujisawa, Christian Geuer-
Pollmann, Yaron Goland, Graham Klyne, Dan Kohn, Rick Jeliffe, Chris
Lilley, Murata Makoto, Michael Mealling, Jean-Jacques Moreau, Andrew
Newton, Julian Reschke, Jonathan Rosenberg, Miles Sabin, Rich Salz,
Peter Saint-Andre, Simon St Laurent, Margaret Wasserman, and Daniel
Veillard.
9. Normative References
[1] Bradner, S., "Key words for use in RFCs to Indicate Requirement
Levels", BCP 14, RFC 2119, March 1997.
[2] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC
2246, January 1999.
[3] Alvestrand, H., "IETF Policy on Character Sets and Languages",
BCP 18, RFC 2277, January 1998.
[4] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC
2279, January 1998.
Hollenbeck, et al. Best Current Practice [Page 22]
RFC 3470 XML within IETF Protocols January 2003
[5] Murata, M., St. Laurent, S. and D. Kohn, "XML Media Types", RFC
3023, January 2001.
[6] Boyer, J., "Canonical XML Version 1.0", RFC 3076, March 2001.
[7] Eastlake, D., Reagle, J. and D. Solo, "(Extensible Markup
Language) XML-Signature Syntax and Processing", RFC 3275, March
2002.
[8] Bray, T., Paoli, J., Sperberg-McQueen, C. and E. Maler,
"Extensible Markup Language (XML) 1.0 (2nd ed)", W3C REC-xml,
October 2000, <http://www.w3.org/TR/REC-xml>.
[9] Bray, T., Hollander, D. and A. Layman, "Namespaces in XML", W3C
REC-xml-names, January 1999, <http://www.w3.org/TR/REC-xml-
names>.
[10] Imamura, T., Dillaway, B., Schaad, J. and E. Simon, "XML
Encryption Syntax and Processing", W3C REC-xmlenc-core, October
2001, <http://www.w3.org/TR/xmlenc-core/>.
10. Informative References
[11] Masinter, L., Mealling, M., Klyne, G. and T. Hardie, "An IETF
URN Sub-namespace for Registered Protocol Parameters", Work in
Progress.
[12] Mealling, M., "The IETF XML Registry", Work in Progress.
[13] Case, J., Fedor, M., Schoffstall, M. and C. Davin, "Simple
Network Management Protocol (SNMP)", STD 15, RFC 1157, May
1990.
[14] Srinivasan, R., "XDR: External Data Representation Standard",
RFC 1832, August 1995.
[15] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
Extensions (MIME) Part One: Format of Internet Message Bodies",
RFC 2045, November 1996.
[16] Crocker, D. (Ed.) and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", RFC 2234, November 1997.
[17] Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform
Resource Identifiers (URI): Generic Syntax", RFC 2396, August
1998.
Hollenbeck, et al. Best Current Practice [Page 23]
RFC 3470 XML within IETF Protocols January 2003
[18] Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA
Considerations Section in RFCs", BCP 26, RFC 2434, October
1998.
[19] Rose, M., "Writing I-Ds and RFCs using XML", RFC 2629, June
1999.
[20] Hoffman, P. and F. Yergeau, "UTF-16, an encoding of ISO 10646",
RFC 2781, February 2000.
[21] Klensin, J. (Ed.), "Simple Mail Transfer Protocol", RFC 2821,
April 2001.
[22] Shepler, S., Callaghan, B., Robinson, D., Thurlow, R., Beame,
C., Eisler, M. and D. Noveck, "NFS version 4 Protocol", RFC
3010, December 2000.
[23] Kennedy, H., "Binary Lexical Octet Ad-hoc Transport", RFC 3252,
April 2002.
[24] Popp, N., Mealling, M. and M. Moseley, "Common Name Resolution
Protocol (CNRP)", RFC 3367, August 2002.
[25] Backus, J., "The syntax and semantics of the proposed
international algebraic language of the Zurich ACM-GAMM
conference", June 1959.
[26] American National Standards Institute, "Code Extension
Techniques for Use with the 7-bit Coded Character Set of
American National Standard Code (ASCII) for Information
Interchange", ANSI X3.41, FIPS PUB 35, 1974.
[27] American National Standards Institute, "Information Retrieval:
Application Service Definition and Protocol Specification",
ANSI Z39.50, ISO Standard 23950, 1995.
[28] International Organization for Standardization, "Information
Processing Systems - Open Systems Interconnection -
Specification of Abstract Syntax Notation One (ASN.1)", ISO
Standard 8824, December 1990.
[29] International Organization for Standardization, "Information
Processing Systems - Open Systems Interconnection -
Specification of Basic Encoding Rules for Abstract Syntax
Notation One (ASN.1)", ISO Standard 8825, December 1990.
Hollenbeck, et al. Best Current Practice [Page 24]
RFC 3470 XML within IETF Protocols January 2003
[30] International Organization for Standardization, "Information
processing - Text and office systems - Standard Generalized
Markup Language (SGML)", ISO Standard 8879, 1988.
[31] International Organization for Standardization, "Information
Technology - Universal Multiple-octet coded Character Set (UCS)
- Part 1: Architecture and Basic Multilingual Plane", ISO
Standard 10646-1, May 1993.
[32] International Organization for Standardization, "DSDL Part 0 -
Overview", December 2001, <http://www.jtc1.org/FTP/Public/SC34/
DOCREG/0275.htm>.
[33] Unicode Consortium, "The Unicode Standard, as it may from time
to time be revised or amended", March 2002, <http://
www.unicode.org/unicode/standard/standard.html>.
[34] Duerst, M. and A. Freytag, "Unicode in XML and other Markup
Languages", February 2002, <http://www.w3.org/TR/unicode-xml/>.
[35] Bray, T., Paoli, J. and C. Sperberg-McQueen, "Extensible Markup
Language (XML) 1.0", W3C REC-xml-1998, February 1998, <http://
www.w3.org/TR/1998/REC-xml-19980210/>.
[36] Marsh, J., "XML Base", W3C REC-xmlbase, June 2001, <http://
www.w3.org/TR/xmlbase/>.
[37] Cowan, J. and R. Tobin, "XML Information Set", W3C REC-infoset,
October 2001, <http://www.w3.org/TR/xml-infoset/>.
[38] Lassila, O. and R. Swick, "Resource Description Framework (RDF)
Model and Syntax Specification", W3C REC-rdf-syntax, February
1999, <http://www.w3.org/TR/REC-rdf-syntax>.
[39] Suignard, M., Ishikawa, M., Duerst, M. and T. Texin, "Ruby
Annotation", W3C REC-RUBY, May 2001, <http://www.w3.org/TR/
ruby/>.
[40] Pemberton, S., "XHTML 1.0: The Extensible HyperText Markup
Language", W3C REC-XHTML, January 2000, <http://www.w3.org/TR/
xhtml1/>.
[41] Thompson, H., Beech, D., Maloney, M. and N. Mendelsohn, "XML
Schema Part 1: Structures", W3C REC-xmlschema-1, May 2001,
<http://www.w3.org/TR/xmlschema-1/>.
[42] Biron, P. and A. Malhotra, "XML Schema Part 2: Datatypes", W3C
REC-xmlschema-2, May 2001, <http://www.w3.org/TR/xmlschema-2/>.
Hollenbeck, et al. Best Current Practice [Page 25]
RFC 3470 XML within IETF Protocols January 2003
[43] Clark, J., "XSL Transformations (XSLT) Version 1.0", W3C REC-
xslt, November 1999, <http://www.w3.org/TR/xslt>.
[44] Duerst, M., Yergeau, F., Ishida, R., Wolf, M., Freytag, A. and
T. Texin, "Character Model for the World Wide Web 1.0", April
2002, <http://www.w3.org/TR/charmod/>.
[45] Gudgin, M., Hadley, M., Moreau, JJ. and H. Nielsen, "SOAP
Version 1.2 Part 1: Messaging Framework", June 2002,
<http://www.w3.org/TR/soap12-part1/>.
[46] Gudgin, M., Hadley, M., Moreau, JJ. and H. Nielsen, "SOAP
Version 1.2 Part 2: Adjuncts", June 2002,
<http://www.w3.org/TR/soap12-part2/>.
[47] W3C Communications Team, "XML in 10 points", November 2001,
<http://www.w3.org/XML/1999/XML-in-10-points>.
[48] OASIS Technical Committee: RELAX NG, "RELAX NG Specification",
December 2001, <http://www.oasis-open.org/committees/relax-ng/
spec-20011203.html>.
[49] Jelliffe, R., "The Schematron", November 2001, <http://
www.ascc.net/xml/schematron/>.
URIs
[50] <http://www.imc.org/ietf-xml-use/>
[51] <http://xml.org/>
[52] <http://xmlhack.com/>
[53] <http://oasis-open.org/>
Hollenbeck, et al. Best Current Practice [Page 26]
RFC 3470 XML within IETF Protocols January 2003
11. Authors' Addresses
Scott Hollenbeck
VeriSign, Inc.
21345 Ridgetop Circle
Dulles, VA 20166-6503
US
Phone: +1 703 948 3257
EMail: shollenbeck@verisign.com
Marshall T. Rose
Dover Beach Consulting, Inc.
POB 255268
Sacramento, CA 95865-5268
US
Phone: +1 916 483 8878
EMail: mrose@dbc.mtview.ca.us
Larry Masinter
Adobe Systems Incorporated
Mail Stop W14
345 Park Ave.
San Jose, CA 95110
US
Phone: +1 408 536 3024
EMail: LMM@acm.org
URI: http://larry.masinter.net
Hollenbeck, et al. Best Current Practice [Page 27]
RFC 3470 XML within IETF Protocols January 2003
12. Full Copyright Statement
Copyright (C) The Internet Society (2003). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement
Funding for the RFC Editor function is currently provided by the
Internet Society.
Hollenbeck, et al. Best Current Practice [Page 28]