Редактирование: Qt:Документация 4.3.2/qtxml
Материал из Wiki.crossplatform.ru
Внимание: Вы не представились системе. Ваш IP-адрес будет записан в историю изменений этой страницы.
ПРЕДУПРЕЖДЕНИЕ: Длина этой страницы составляет 51 килобайт. Страницы, размер которых приближается к 32 КБ или превышает это значение, могут неверно отображаться в некоторых браузерах. Пожалуйста, рассмотрите вариант разбиения страницы на меньшие части.
Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия | Ваш текст | ||
Строка 314: | Строка 314: | ||
<div id="namespace-support-via-features"></div> | <div id="namespace-support-via-features"></div> | ||
- | ==== | + | ====Namespace Support via Features==== |
- | + | As we have seen in the previous section, we can configure the behavior of the reader when it comes to namespace processing. This is done by setting and unsetting the ''http://xml.org/sax/features/namespaces'' and ''http://xml.org/sax/features/namespace-prefixes'' features. | |
- | + | They influence the reporting behavior in the following way: | |
- | # | + | #Namespace prefixes and local parts of elements and attributes can be reported. |
- | # | + | #The qualified names of elements and attributes are reported. |
- | # | + | #[[Qt:Документация 4.3.2/qxmlcontenthandler#startPrefixMapping | QXmlContentHandler::startPrefixMapping]]() and [[Qt:Документация 4.3.2/qxmlcontenthandler#endPrefixMapping | QXmlContentHandler::endPrefixMapping]]() are called by the reader. |
- | # | + | #Attributes that declare namespaces (i.e. the attribute ''xmlns'' and attributes starting with ''xmlns:'') are reported. |
- | + | Consider the following element: | |
<source lang="cpp-qt"> <author xmlns:fnord = 'http://trolltech.com/fnord/' | <source lang="cpp-qt"> <author xmlns:fnord = 'http://trolltech.com/fnord/' | ||
title="Ms" | title="Ms" | ||
fnord:title="Goddess" | fnord:title="Goddess" | ||
name="Eris Kallisti"/></source> | name="Eris Kallisti"/></source> | ||
- | + | With ''http://xml.org/sax/features/namespace-prefixes'' set to true the reader will report four attributes; but with the ''namespace-prefixes'' feature set to false only three, with the ''xmlns:fnord'' attribute defining a namespace being "invisible" to the reader. | |
- | + | The ''http://xml.org/sax/features/namespaces'' feature is responsible for reporting local names, namespace prefixes and URIs. With ''http://xml.org/sax/features/namespaces'' set to true the parser will report ''title'' as the local name of the ''fnord:title'' attribute, ''fnord'' being the namespace prefix and ''http://trolltech.com/fnord/'' as the namespace URI. When ''http://xml.org/sax/features/namespaces'' is false none of them are reported. | |
- | + | In the current implementation the Qt XML classes follow the definition that the prefix ''xmlns'' itself isn't associated with any namespace at all (see [http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-using http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-using]). Therefore even with ''http://xml.org/sax/features/namespaces'' and ''http://xml.org/sax/features/namespace-prefixes'' both set to true the reader won't return either a local name, a namespace prefix or a namespace URI for ''xmlns:fnord''. | |
- | + | This might be changed in the future following the W3C suggestion [http://www.w3.org/2000/xmlns/ http://www.w3.org/2000/xmlns/] to associate ''xmlns'' with the namespace ''http://www.w3.org/2000/xmlns''. | |
- | + | As the SAX2 standard suggests, [[Qt:Документация 4.3.2/qxmlsimplereader | QXmlSimpleReader]] defaults to having ''http://xml.org/sax/features/namespaces'' set to true and ''http://xml.org/sax/features/namespace-prefixes'' set to false. When changing this behavior using [[Qt:Документация 4.3.2/qxmlsimplereader#setFeature | QXmlSimpleReader::setFeature]]() note that the combination of both features set to false is illegal. | |
<div id="summary"></div> | <div id="summary"></div> | ||
- | ===== | + | =====Summary===== |
- | [[Qt:Документация 4.3.2/qxmlsimplereader | QXmlSimpleReader]] | + | [[Qt:Документация 4.3.2/qxmlsimplereader | QXmlSimpleReader]] implements the following behavior: |
Строка 348: | Строка 348: | ||
|- valign="top" class="qt-style" | | |- valign="top" class="qt-style" | | ||
!(namespaces, namespace-prefixes) | !(namespaces, namespace-prefixes) | ||
- | ! | + | !Namespace prefix and local part |
- | ! | + | !Qualified names |
- | ! | + | !Prefix mapping |
- | ! | + | !xmlns attributes |
|- valign="top" class="odd" | | |- valign="top" class="odd" | | ||
|(true, false) | |(true, false) | ||
Строка 375: | Строка 375: | ||
|} | |} | ||
- | + | The behavior of the entries marked with an asterisk (*) is not specified by SAX. | |
<div id="properties"></div> | <div id="properties"></div> | ||
- | |||
====Свойства==== | ====Свойства==== | ||