summaryrefslogtreecommitdiffstats
path: root/src/xml/dom
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml/dom')
-rw-r--r--src/xml/dom/qdom.cpp750
-rw-r--r--src/xml/dom/qdom.h147
-rw-r--r--src/xml/dom/qdom_p.h11
-rw-r--r--src/xml/dom/qdomhelpers.cpp55
-rw-r--r--src/xml/dom/qdomhelpers_p.h19
5 files changed, 615 insertions, 367 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index b54590a2f8..b25cdf487f 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -23,6 +23,7 @@
#include <qxmlstream.h>
#include <private/qduplicatetracker_p.h>
#include <private/qstringiterator_p.h>
+#include <qvarlengtharray.h>
#include <stdio.h>
#include <limits>
@@ -46,7 +47,7 @@ using namespace Qt::StringLiterals;
/* ##### new TODOs:
- Remove empty emthods in the *Private classes
+ Remove empty methods in the *Private classes
Make a lot of the (mostly empty) methods in the public classes inline.
Specially constructors assignment operators and comparison operators are candidates.
@@ -373,52 +374,52 @@ QDomImplementation::QDomImplementation()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a implementation.
*/
-QDomImplementation::QDomImplementation(const QDomImplementation &x)
+QDomImplementation::QDomImplementation(const QDomImplementation &implementation)
+ : impl(implementation.impl)
{
- impl = x.impl;
if (impl)
impl->ref.ref();
}
-QDomImplementation::QDomImplementation(QDomImplementationPrivate *p)
+QDomImplementation::QDomImplementation(QDomImplementationPrivate *pimpl)
+ : impl(pimpl)
{
// We want to be co-owners, so increase the reference count
- impl = p;
if (impl)
impl->ref.ref();
}
/*!
- Assigns \a x to this DOM implementation.
+ Assigns \a other to this DOM implementation.
*/
-QDomImplementation& QDomImplementation::operator=(const QDomImplementation &x)
+QDomImplementation& QDomImplementation::operator=(const QDomImplementation &other)
{
- if (x.impl)
- x.impl->ref.ref();
+ if (other.impl)
+ other.impl->ref.ref();
if (impl && !impl->ref.deref())
delete impl;
- impl = x.impl;
+ impl = other.impl;
return *this;
}
/*!
- Returns \c true if \a x and this DOM implementation object were
+ Returns \c true if \a other and this DOM implementation object were
created from the same QDomDocument; otherwise returns \c false.
*/
-bool QDomImplementation::operator==(const QDomImplementation &x) const
+bool QDomImplementation::operator==(const QDomImplementation &other) const
{
- return (impl == x.impl);
+ return impl == other.impl;
}
/*!
- Returns \c true if \a x and this DOM implementation object were
+ Returns \c true if \a other and this DOM implementation object were
created from different QDomDocuments; otherwise returns \c false.
*/
-bool QDomImplementation::operator!=(const QDomImplementation &x) const
+bool QDomImplementation::operator!=(const QDomImplementation &other) const
{
- return (impl != x.impl);
+ return !operator==(other);
}
/*!
@@ -645,10 +646,10 @@ bool QDomNodeListPrivate::operator==(const QDomNodeListPrivate &other) const
bool QDomNodeListPrivate::operator!=(const QDomNodeListPrivate &other) const
{
- return (node_impl != other.node_impl) || (tagname != other.tagname);
+ return !operator==(other);
}
-void QDomNodeListPrivate::createList()
+void QDomNodeListPrivate::createList() const
{
if (!node_impl)
return;
@@ -702,16 +703,21 @@ void QDomNodeListPrivate::createList()
}
}
-QDomNodePrivate* QDomNodeListPrivate::item(int index)
+bool QDomNodeListPrivate::maybeCreateList() const
{
if (!node_impl)
- return nullptr;
+ return false;
const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
if (!doc || timestamp != doc->nodeListTime)
createList();
- if (index >= list.size())
+ return true;
+}
+
+QDomNodePrivate *QDomNodeListPrivate::item(int index)
+{
+ if (!maybeCreateList() || index >= list.size() || index < 0)
return nullptr;
return list.at(index);
@@ -719,16 +725,10 @@ QDomNodePrivate* QDomNodeListPrivate::item(int index)
int QDomNodeListPrivate::length() const
{
- if (!node_impl)
+ if (!maybeCreateList())
return 0;
- const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
- if (!doc || timestamp != doc->nodeListTime) {
- QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);
- that->createList();
- }
-
- return list.count();
+ return list.size();
}
/**************************************************************
@@ -770,54 +770,54 @@ QDomNodeList::QDomNodeList()
{
}
-QDomNodeList::QDomNodeList(QDomNodeListPrivate* p)
- : impl(p)
+QDomNodeList::QDomNodeList(QDomNodeListPrivate *pimpl)
+ : impl(pimpl)
{
}
/*!
- Constructs a copy of \a n.
+ Constructs a copy of \a nodeList.
*/
-QDomNodeList::QDomNodeList(const QDomNodeList& n)
+QDomNodeList::QDomNodeList(const QDomNodeList &nodeList)
+ : impl(nodeList.impl)
{
- impl = n.impl;
if (impl)
impl->ref.ref();
}
/*!
- Assigns \a n to this node list.
+ Assigns \a other to this node list.
*/
-QDomNodeList& QDomNodeList::operator=(const QDomNodeList &n)
+QDomNodeList& QDomNodeList::operator=(const QDomNodeList &other)
{
- if (n.impl)
- n.impl->ref.ref();
+ if (other.impl)
+ other.impl->ref.ref();
if (impl && !impl->ref.deref())
delete impl;
- impl = n.impl;
+ impl = other.impl;
return *this;
}
/*!
- Returns \c true if the node list \a n and this node list are equal;
+ Returns \c true if the node list \a other and this node list are equal;
otherwise returns \c false.
*/
-bool QDomNodeList::operator==(const QDomNodeList &n) const
+bool QDomNodeList::operator==(const QDomNodeList &other) const
{
- if (impl == n.impl)
+ if (impl == other.impl)
return true;
- if (!impl || !n.impl)
+ if (!impl || !other.impl)
return false;
- return (*impl == *n.impl);
+ return (*impl == *other.impl);
}
/*!
- Returns \c true the node list \a n and this node list are not equal;
+ Returns \c true the node list \a other and this node list are not equal;
otherwise returns \c false.
*/
-bool QDomNodeList::operator!=(const QDomNodeList &n) const
+bool QDomNodeList::operator!=(const QDomNodeList &other) const
{
- return !operator==(n);
+ return !operator==(other);
}
/*!
@@ -1473,48 +1473,48 @@ QDomNode::QDomNode()
}
/*!
- Constructs a copy of \a n.
+ Constructs a copy of \a node.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomNode::QDomNode(const QDomNode &n)
+QDomNode::QDomNode(const QDomNode &node)
+ : impl(node.impl)
{
- impl = n.impl;
if (impl)
impl->ref.ref();
}
/*! \internal
- Constructs a new node for the data \a n.
+ Constructs a new node for the data \a pimpl.
*/
-QDomNode::QDomNode(QDomNodePrivate *n)
+QDomNode::QDomNode(QDomNodePrivate *pimpl)
+ : impl(pimpl)
{
- impl = n;
if (impl)
impl->ref.ref();
}
/*!
- Assigns a copy of \a n to this DOM node.
+ Assigns a copy of \a other to this DOM node.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomNode& QDomNode::operator=(const QDomNode &n)
+QDomNode& QDomNode::operator=(const QDomNode &other)
{
- if (n.impl)
- n.impl->ref.ref();
+ if (other.impl)
+ other.impl->ref.ref();
if (impl && !impl->ref.deref())
delete impl;
- impl = n.impl;
+ impl = other.impl;
return *this;
}
/*!
- Returns \c true if \a n and this DOM node are equal; otherwise
+ Returns \c true if \a other and this DOM node are equal; otherwise
returns \c false.
Any instance of QDomNode acts as a reference to an underlying data
@@ -1533,18 +1533,18 @@ QDomNode& QDomNode::operator=(const QDomNode &n)
\c {element3 == element4} will return false because they refer to
two different nodes in the underlying data structure.
*/
-bool QDomNode::operator== (const QDomNode& n) const
+bool QDomNode::operator==(const QDomNode &other) const
{
- return (impl == n.impl);
+ return impl == other.impl;
}
/*!
- Returns \c true if \a n and this DOM node are not equal; otherwise
+ Returns \c true if \a other and this DOM node are not equal; otherwise
returns \c false.
*/
-bool QDomNode::operator!= (const QDomNode& n) const
+bool QDomNode::operator!=(const QDomNode &other) const
{
- return (impl != n.impl);
+ return !operator==(other);
}
/*!
@@ -1621,15 +1621,14 @@ QString QDomNode::nodeValue() const
}
/*!
- Sets the node's value to \a v.
+ Sets the node's value to \a value.
\sa nodeValue()
*/
-void QDomNode::setNodeValue(const QString& v)
+void QDomNode::setNodeValue(const QString& value)
{
- if (!impl)
- return;
- IMPL->setNodeValue(v);
+ if (impl)
+ IMPL->setNodeValue(value);
}
/*!
@@ -2503,11 +2502,12 @@ int QDomNode::columnNumber() const
*
**************************************************************/
-QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate* n) : ref(1)
+QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate *pimpl)
+ : ref(1)
+ , parent(pimpl)
+ , readonly(false)
+ , appendToParent(false)
{
- readonly = false;
- parent = n;
- appendToParent = false;
}
QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
@@ -2515,16 +2515,16 @@ QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
clearMap();
}
-QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
+QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate *pimpl)
{
- std::unique_ptr<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));
+ std::unique_ptr<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(pimpl));
m->readonly = readonly;
m->appendToParent = appendToParent;
auto it = map.constBegin();
for (; it != map.constEnd(); ++it) {
- QDomNodePrivate *new_node = (*it)->cloneNode();
- new_node->setParent(p);
+ QDomNodePrivate *new_node = it.value()->cloneNode();
+ new_node->setParent(pimpl);
m->setNamedItem(new_node);
}
@@ -2539,16 +2539,16 @@ void QDomNamedNodeMapPrivate::clearMap()
if (!appendToParent) {
auto it = map.constBegin();
for (; it != map.constEnd(); ++it)
- if (!(*it)->ref.deref())
- delete *it;
+ if (!it.value()->ref.deref())
+ delete it.value();
}
map.clear();
}
QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(const QString& name) const
{
- auto it = map.constFind(name);
- return it == map.cend() ? nullptr : *it;
+ auto it = map.find(name);
+ return it == map.end() ? nullptr : it.value();
}
QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, const QString& localName) const
@@ -2556,7 +2556,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, cons
auto it = map.constBegin();
QDomNodePrivate *n;
for (; it != map.constEnd(); ++it) {
- n = *it;
+ n = it.value();
if (!n->prefix.isNull()) {
// node has a namespace
if (n->namespaceURI == nsURI && n->name == localName)
@@ -2623,12 +2623,12 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const
{
if (index >= length() || index < 0)
return nullptr;
- return *std::next(map.cbegin(), index);
+ return std::next(map.begin(), index).value();
}
int QDomNamedNodeMapPrivate::length() const
{
- return map.count();
+ return map.size();
}
bool QDomNamedNodeMapPrivate::contains(const QString& name) const
@@ -2696,51 +2696,51 @@ QDomNamedNodeMap::QDomNamedNodeMap()
}
/*!
- Constructs a copy of \a n.
+ Constructs a copy of \a namedNodeMap.
*/
-QDomNamedNodeMap::QDomNamedNodeMap(const QDomNamedNodeMap &n)
+QDomNamedNodeMap::QDomNamedNodeMap(const QDomNamedNodeMap &namedNodeMap)
+ : impl(namedNodeMap.impl)
{
- impl = n.impl;
if (impl)
impl->ref.ref();
}
-QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *n)
+QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *pimpl)
+ : impl(pimpl)
{
- impl = n;
if (impl)
impl->ref.ref();
}
/*!
- Assigns \a n to this named node map.
+ Assigns \a other to this named node map.
*/
-QDomNamedNodeMap& QDomNamedNodeMap::operator=(const QDomNamedNodeMap &n)
+QDomNamedNodeMap& QDomNamedNodeMap::operator=(const QDomNamedNodeMap &other)
{
- if (n.impl)
- n.impl->ref.ref();
+ if (other.impl)
+ other.impl->ref.ref();
if (impl && !impl->ref.deref())
delete impl;
- impl = n.impl;
+ impl = other.impl;
return *this;
}
/*!
- Returns \c true if \a n and this named node map are equal; otherwise
+ Returns \c true if \a other and this named node map are equal; otherwise
returns \c false.
*/
-bool QDomNamedNodeMap::operator== (const QDomNamedNodeMap& n) const
+bool QDomNamedNodeMap::operator==(const QDomNamedNodeMap &other) const
{
- return (impl == n.impl);
+ return impl == other.impl;
}
/*!
- Returns \c true if \a n and this named node map are not equal;
+ Returns \c true if \a other and this named node map are not equal;
otherwise returns \c false.
*/
-bool QDomNamedNodeMap::operator!= (const QDomNamedNodeMap& n) const
+bool QDomNamedNodeMap::operator!=(const QDomNamedNodeMap &other) const
{
- return (impl != n.impl);
+ return !operator==(other);
}
/*!
@@ -3069,11 +3069,11 @@ void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const
auto it2 = notations->map.constBegin();
for (; it2 != notations->map.constEnd(); ++it2)
- (*it2)->save(s, 0, indent);
+ it2.value()->save(s, 0, indent);
auto it = entities->map.constBegin();
for (; it != entities->map.constEnd(); ++it)
- (*it)->save(s, 0, indent);
+ it.value()->save(s, 0, indent);
s << ']';
}
@@ -3116,30 +3116,30 @@ QDomDocumentType::QDomDocumentType() : QDomNode()
}
/*!
- Constructs a copy of \a n.
+ Constructs a copy of \a documentType.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocumentType::QDomDocumentType(const QDomDocumentType& n)
- : QDomNode(n)
+QDomDocumentType::QDomDocumentType(const QDomDocumentType &documentType)
+ : QDomNode(documentType)
{
}
-QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate* n)
- : QDomNode(n)
+QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate *pimpl)
+ : QDomNode(pimpl)
{
}
/*!
- Assigns \a n to this document type.
+ Assigns \a other to this document type.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocumentType &QDomDocumentType::operator=(const QDomDocumentType &n) = default;
+QDomDocumentType &QDomDocumentType::operator=(const QDomDocumentType &other) = default;
/*!
Returns the name of the document type as specified in the
&lt;!DOCTYPE name&gt; tag.
@@ -3297,25 +3297,25 @@ QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n)
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a documentFragment.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocumentFragment::QDomDocumentFragment(const QDomDocumentFragment& x)
- : QDomNode(x)
+QDomDocumentFragment::QDomDocumentFragment(const QDomDocumentFragment &documentFragment)
+ : QDomNode(documentFragment)
{
}
/*!
- Assigns \a x to this DOM document fragment.
+ Assigns \a other to this DOM document fragment.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocumentFragment &QDomDocumentFragment::operator=(const QDomDocumentFragment &x) = default;
+QDomDocumentFragment &QDomDocumentFragment::operator=(const QDomDocumentFragment &other) = default;
/*!
\fn QDomNode::NodeType QDomDocumentFragment::nodeType() const
@@ -3354,7 +3354,7 @@ QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(bool deep)
int QDomCharacterDataPrivate::dataLength() const
{
- return value.length();
+ return value.size();
}
QString QDomCharacterDataPrivate::substringData(unsigned long offset, unsigned long n) const
@@ -3423,14 +3423,14 @@ QDomCharacterData::QDomCharacterData()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a characterData.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomCharacterData::QDomCharacterData(const QDomCharacterData& x)
- : QDomNode(x)
+QDomCharacterData::QDomCharacterData(const QDomCharacterData &characterData)
+ : QDomNode(characterData)
{
}
@@ -3440,13 +3440,13 @@ QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n)
}
/*!
- Assigns \a x to this character data.
+ Assigns \a other to this character data.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomCharacterData &QDomCharacterData::operator=(const QDomCharacterData &x) = default;
+QDomCharacterData &QDomCharacterData::operator=(const QDomCharacterData &other) = default;
/*!
Returns the string stored in this object.
@@ -3462,12 +3462,12 @@ QString QDomCharacterData::data() const
}
/*!
- Sets this object's string to \a v.
+ Sets this object's string to \a data.
*/
-void QDomCharacterData::setData(const QString& v)
+void QDomCharacterData::setData(const QString &data)
{
if (impl)
- impl->setNodeValue(v);
+ impl->setNodeValue(data);
}
/*!
@@ -3612,7 +3612,7 @@ static QString encodeText(const QString &str,
const bool encodeEOLs = false)
{
QString retval(str);
- int len = retval.length();
+ int len = retval.size();
int i = 0;
while (i < len) {
@@ -3640,8 +3640,8 @@ static QString encodeText(const QString &str,
ati == QChar(0x9))) {
const QString replacement(u"&#x"_s + QString::number(ati.unicode(), 16) + u';');
retval.replace(i, 1, replacement);
- i += replacement.length();
- len += replacement.length() - 1;
+ i += replacement.size();
+ len += replacement.size() - 1;
} else if (encodeEOLs && ati == QChar(0xD)) {
retval.replace(i, 1, "&#xd;"_L1); // Replace a single 0xD with a ref for 0xD
len += 4;
@@ -3729,14 +3729,14 @@ QDomAttr::QDomAttr()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a attr.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomAttr::QDomAttr(const QDomAttr& x)
- : QDomNode(x)
+QDomAttr::QDomAttr(const QDomAttr &attr)
+ : QDomNode(attr)
{
}
@@ -3746,13 +3746,13 @@ QDomAttr::QDomAttr(QDomAttrPrivate* n)
}
/*!
- Assigns \a x to this DOM attribute.
+ Assigns \a other to this DOM attribute.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomAttr &QDomAttr::operator=(const QDomAttr &x) = default;
+QDomAttr &QDomAttr::operator=(const QDomAttr &other) = default;
/*!
Returns the attribute's name.
@@ -3804,15 +3804,15 @@ QString QDomAttr::value() const
}
/*!
- Sets the attribute's value to \a v.
+ Sets the attribute's value to \a value.
\sa value()
*/
-void QDomAttr::setValue(const QString& v)
+void QDomAttr::setValue(const QString &value)
{
if (!impl)
return;
- impl->setNodeValue(v);
+ impl->setNodeValue(value);
IMPL->m_specified = true;
}
@@ -4026,32 +4026,83 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const
/* Write out attributes. */
if (!m_attr->map.isEmpty()) {
+ /*
+ * To ensure that we always output attributes in a consistent
+ * order, sort the attributes before writing them into the
+ * stream. (Note that the order may be different than the one
+ * that e.g. we've read from a file, or the program order in
+ * which these attributes have been populated. We just want to
+ * guarantee reproducibile outputs.)
+ */
+ struct SavedAttribute {
+ QString prefix;
+ QString name;
+ QString encodedValue;
+ };
+
+ /* Gather all the attributes to save. */
+ QVarLengthArray<SavedAttribute, 8> attributesToSave;
+ attributesToSave.reserve(m_attr->map.size());
+
QDuplicateTracker<QString> outputtedPrefixes;
- auto it = m_attr->map.constBegin();
- for (; it != m_attr->map.constEnd(); ++it) {
- s << ' ';
- if (it.value()->namespaceURI.isNull()) {
- s << it.value()->name << "=\"" << encodeText(it.value()->value, true, true) << '\"';
- } else {
- s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, true, true) << '\"';
- /* This is a fix for 138243, as good as it gets.
- *
- * QDomElementPrivate::save() output a namespace declaration if
- * the element is in a namespace, no matter what. This function do as well, meaning
- * that we get two identical namespace declaration if we don't have the if-
- * statement below.
- *
- * This doesn't work when the parent element has the same prefix as us but
- * a different namespace. However, this can only occur by the user modifying the element,
- * and we don't do fixups by that anyway, and hence it's the user responsibility to not
- * arrive in those situations. */
- if ((!it.value()->ownerNode ||
- it.value()->ownerNode->prefix != it.value()->prefix) &&
- !outputtedPrefixes.hasSeen(it.value()->prefix)) {
- s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, true, true) << '\"';
- }
+ for (const auto &[key, value] : std::as_const(m_attr->map).asKeyValueRange()) {
+ Q_UNUSED(key); /* We extract the attribute name from the value. */
+ bool mayNeedXmlNS = false;
+
+ SavedAttribute attr;
+ attr.name = value->name;
+ attr.encodedValue = encodeText(value->value, true, true);
+ if (!value->namespaceURI.isNull()) {
+ attr.prefix = value->prefix;
+ mayNeedXmlNS = true;
+ }
+
+ attributesToSave.push_back(std::move(attr));
+
+ /*
+ * This is a fix for 138243, as good as it gets.
+ *
+ * QDomElementPrivate::save() output a namespace
+ * declaration if the element is in a namespace, no matter
+ * what. This function do as well, meaning that we get two
+ * identical namespace declaration if we don't have the if-
+ * statement below.
+ *
+ * This doesn't work when the parent element has the same
+ * prefix as us but a different namespace. However, this
+ * can only occur by the user modifying the element, and we
+ * don't do fixups by that anyway, and hence it's the user
+ * responsibility to avoid those situations.
+ */
+
+ if (mayNeedXmlNS
+ && ((!value->ownerNode || value->ownerNode->prefix != value->prefix)
+ && !outputtedPrefixes.hasSeen(value->prefix)))
+ {
+ SavedAttribute nsAttr;
+ nsAttr.prefix = QStringLiteral("xmlns");
+ nsAttr.name = value->prefix;
+ nsAttr.encodedValue = encodeText(value->namespaceURI, true, true);
+ attributesToSave.push_back(std::move(nsAttr));
}
}
+
+ /* Sort the attributes by prefix and name. */
+ const auto savedAttributeComparator = [](const SavedAttribute &lhs, const SavedAttribute &rhs)
+ {
+ const int cmp = QString::compare(lhs.prefix, rhs.prefix);
+ return (cmp < 0) || ((cmp == 0) && (lhs.name < rhs.name));
+ };
+
+ std::sort(attributesToSave.begin(), attributesToSave.end(), savedAttributeComparator);
+
+ /* Actually stream the sorted attributes. */
+ for (const auto &attr : attributesToSave) {
+ s << ' ';
+ if (!attr.prefix.isEmpty())
+ s << attr.prefix << ':';
+ s << attr.name << "=\"" << attr.encodedValue << '\"';
+ }
}
if (last) {
@@ -4149,14 +4200,14 @@ QDomElement::QDomElement()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a element.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomElement::QDomElement(const QDomElement& x)
- : QDomNode(x)
+QDomElement::QDomElement(const QDomElement &element)
+ : QDomNode(element)
{
}
@@ -4166,13 +4217,13 @@ QDomElement::QDomElement(QDomElementPrivate* n)
}
/*!
- Assigns \a x to this DOM element.
+ Assigns \a other to this DOM element.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomElement &QDomElement::operator=(const QDomElement &x) = default;
+QDomElement &QDomElement::operator=(const QDomElement &other) = default;
/*!
\fn QDomNode::NodeType QDomElement::nodeType() const
@@ -4619,6 +4670,10 @@ QDomTextPrivate* QDomTextPrivate::splitText(int offset)
value.truncate(offset);
parent()->insertAfter(t, this);
+ Q_ASSERT(t->ref.loadRelaxed() == 2);
+
+ // We are not interested in this node
+ t->ref.deref();
return t;
}
@@ -4666,14 +4721,14 @@ QDomText::QDomText()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a text.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomText::QDomText(const QDomText& x)
- : QDomCharacterData(x)
+QDomText::QDomText(const QDomText &text)
+ : QDomCharacterData(text)
{
}
@@ -4683,13 +4738,13 @@ QDomText::QDomText(QDomTextPrivate* n)
}
/*!
- Assigns \a x to this DOM text.
+ Assigns \a other to this DOM text.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomText &QDomText::operator=(const QDomText &x) = default;
+QDomText &QDomText::operator=(const QDomText &other) = default;
/*!
\fn QDomNode::NodeType QDomText::nodeType() const
@@ -4794,14 +4849,14 @@ QDomComment::QDomComment()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a comment.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomComment::QDomComment(const QDomComment& x)
- : QDomCharacterData(x)
+QDomComment::QDomComment(const QDomComment &comment)
+ : QDomCharacterData(comment)
{
}
@@ -4811,13 +4866,13 @@ QDomComment::QDomComment(QDomCommentPrivate* n)
}
/*!
- Assigns \a x to this DOM comment.
+ Assigns \a other to this DOM comment.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomComment &QDomComment::operator=(const QDomComment &x) = default;
+QDomComment &QDomComment::operator=(const QDomComment &other) = default;
/*!
\fn QDomNode::NodeType QDomComment::nodeType() const
@@ -4899,14 +4954,14 @@ QDomCDATASection::QDomCDATASection()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a cdataSection.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomCDATASection::QDomCDATASection(const QDomCDATASection& x)
- : QDomText(x)
+QDomCDATASection::QDomCDATASection(const QDomCDATASection &cdataSection)
+ : QDomText(cdataSection)
{
}
@@ -4916,13 +4971,13 @@ QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n)
}
/*!
- Assigns \a x to this CDATA section.
+ Assigns \a other to this CDATA section.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomCDATASection &QDomCDATASection::operator=(const QDomCDATASection &x) = default;
+QDomCDATASection &QDomCDATASection::operator=(const QDomCDATASection &other) = default;
/*!
\fn QDomNode::NodeType QDomCDATASection::nodeType() const
@@ -5020,14 +5075,14 @@ QDomNotation::QDomNotation()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a notation.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomNotation::QDomNotation(const QDomNotation& x)
- : QDomNode(x)
+QDomNotation::QDomNotation(const QDomNotation &notation)
+ : QDomNode(notation)
{
}
@@ -5037,13 +5092,13 @@ QDomNotation::QDomNotation(QDomNotationPrivate* n)
}
/*!
- Assigns \a x to this DOM notation.
+ Assigns \a other to this DOM notation.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomNotation &QDomNotation::operator=(const QDomNotation &x) = default;
+QDomNotation &QDomNotation::operator=(const QDomNotation &other) = default;
/*!
\fn QDomNode::NodeType QDomNotation::nodeType() const
@@ -5214,14 +5269,14 @@ QDomEntity::QDomEntity()
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a entity.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomEntity::QDomEntity(const QDomEntity& x)
- : QDomNode(x)
+QDomEntity::QDomEntity(const QDomEntity &entity)
+ : QDomNode(entity)
{
}
@@ -5231,13 +5286,13 @@ QDomEntity::QDomEntity(QDomEntityPrivate* n)
}
/*!
- Assigns \a x to this DOM entity.
+ Assigns \a other to this DOM entity.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomEntity &QDomEntity::operator=(const QDomEntity &x) = default;
+QDomEntity &QDomEntity::operator=(const QDomEntity &other) = default;
/*!
\fn QDomNode::NodeType QDomEntity::nodeType() const
@@ -5363,14 +5418,14 @@ QDomEntityReference::QDomEntityReference()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a entityReference.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomEntityReference::QDomEntityReference(const QDomEntityReference& x)
- : QDomNode(x)
+QDomEntityReference::QDomEntityReference(const QDomEntityReference &entityReference)
+ : QDomNode(entityReference)
{
}
@@ -5380,13 +5435,13 @@ QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)
}
/*!
- Assigns \a x to this entity reference.
+ Assigns \a other to this entity reference.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomEntityReference &QDomEntityReference::operator=(const QDomEntityReference &x) = default;
+QDomEntityReference &QDomEntityReference::operator=(const QDomEntityReference &other) = default;
/*!
\fn QDomNode::NodeType QDomEntityReference::nodeType() const
@@ -5477,14 +5532,14 @@ QDomProcessingInstruction::QDomProcessingInstruction()
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a processingInstruction.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction& x)
- : QDomNode(x)
+QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction &processingInstruction)
+ : QDomNode(processingInstruction)
{
}
@@ -5494,14 +5549,14 @@ QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPr
}
/*!
- Assigns \a x to this processing instruction.
+ Assigns \a other to this processing instruction.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
QDomProcessingInstruction &
-QDomProcessingInstruction::operator=(const QDomProcessingInstruction &x) = default;
+QDomProcessingInstruction::operator=(const QDomProcessingInstruction &other) = default;
/*!
\fn QDomNode::NodeType QDomProcessingInstruction::nodeType() const
@@ -5534,15 +5589,14 @@ QString QDomProcessingInstruction::data() const
}
/*!
- Sets the data contained in the processing instruction to \a d.
+ Sets the data contained in the processing instruction to \a data.
\sa data()
*/
-void QDomProcessingInstruction::setData(const QString& d)
+void QDomProcessingInstruction::setData(const QString &data)
{
- if (!impl)
- return;
- impl->setNodeValue(d);
+ if (impl)
+ impl->setNodeValue(data);
}
/**************************************************************
@@ -5609,8 +5663,8 @@ void QDomDocumentPrivate::clear()
QDomNodePrivate::clear();
}
-bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespaceProcessing,
- QString *errorMsg, int *errorLine, int *errorColumn)
+QDomDocument::ParseResult QDomDocumentPrivate::setContent(QXmlStreamReader *reader,
+ QDomDocument::ParseOptions options)
{
clear();
impl = new QDomImplementationPrivate;
@@ -5618,23 +5672,16 @@ bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespacePro
type->ref.deref();
if (!reader) {
- qWarning("Failed to set content, XML reader is not initialized");
- return false;
+ const auto error = u"Failed to set content, XML reader is not initialized"_s;
+ qWarning("%s", qPrintable(error));
+ return { error };
}
- QDomParser domParser(this, reader, namespaceProcessing);
+ QDomParser domParser(this, reader, options);
- if (!domParser.parse()) {
- if (errorMsg)
- *errorMsg = std::get<0>(domParser.errorInfo());
- if (errorLine)
- *errorLine = std::get<1>(domParser.errorInfo());
- if (errorColumn)
- *errorColumn = std::get<2>(domParser.errorInfo());
- return false;
- }
-
- return true;
+ if (!domParser.parse())
+ return domParser.result();
+ return {};
}
QDomNodePrivate* QDomDocumentPrivate::cloneNode(bool deep)
@@ -5947,8 +5994,8 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod
representation of the document can be obtained using toString().
\note The DOM tree might end up reserving a lot of memory if the XML
- document is big. For such documents, the QXmlStreamReader or the
- QXmlQuery classes might be better solutions.
+ document is big. For such documents, the QXmlStreamReader class
+ might be a better solution.
It is possible to insert a node from another document into the
document using importNode().
@@ -5973,10 +6020,9 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod
\l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}
Specifications.
- \sa {DOM Bookmarks Example}, {Simple DOM Model Example}
+ \sa {DOM Bookmarks Application}
*/
-
/*!
Constructs an empty document.
*/
@@ -6006,30 +6052,30 @@ QDomDocument::QDomDocument(const QDomDocumentType& doctype)
}
/*!
- Constructs a copy of \a x.
+ Constructs a copy of \a document.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocument::QDomDocument(const QDomDocument& x)
- : QDomNode(x)
+QDomDocument::QDomDocument(const QDomDocument &document)
+ : QDomNode(document)
{
}
-QDomDocument::QDomDocument(QDomDocumentPrivate* x)
- : QDomNode(x)
+QDomDocument::QDomDocument(QDomDocumentPrivate *pimpl)
+ : QDomNode(pimpl)
{
}
/*!
- Assigns \a x to this DOM document.
+ Assigns \a other to this DOM document.
The data of the copy is shared (shallow copy): modifying one node
will also change the other. If you want to make a deep copy, use
cloneNode().
*/
-QDomDocument &QDomDocument::operator=(const QDomDocument &x) = default;
+QDomDocument &QDomDocument::operator=(const QDomDocument &other) = default;
/*!
Destroys the object and frees its resources.
@@ -6038,25 +6084,30 @@ QDomDocument::~QDomDocument()
{
}
+#if QT_DEPRECATED_SINCE(6, 8)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
/*!
\overload
+ \deprecated [6.8] Use the overloads taking ParseOptions instead.
This function reads the XML document from the string \a text, returning
true if the content was successfully parsed; otherwise returns \c false.
Since \a text is already a Unicode string, no encoding detection
is done.
*/
-bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
+bool QDomDocument::setContent(const QString& text, bool namespaceProcessing,
+ QString *errorMsg, int *errorLine, int *errorColumn)
{
- if (!impl)
- impl = new QDomDocumentPrivate();
-
- QXmlStreamReader streamReader(text);
- streamReader.setNamespaceProcessing(namespaceProcessing);
- return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn);
+ QXmlStreamReader reader(text);
+ reader.setNamespaceProcessing(namespaceProcessing);
+ return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
}
/*!
+ \deprecated [6.8] Use the overload taking ParseOptions instead.
+ \overload
+
This function parses the XML document from the byte array \a
data and sets it as the content of the document. It tries to
detect the encoding of the document as required by the XML
@@ -6085,6 +6136,7 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt
QDomNode::prefix(), QDomNode::localName() and
QDomNode::namespaceURI() return an empty string.
+//! [entity-refs]
Entity references are handled as follows:
\list
\li References to internal general entities and character entities occurring in the
@@ -6099,22 +6151,41 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt
occurs outside of the content is replaced with an empty string.
\li Any unparsed entity reference is replaced with an empty string.
\endlist
+//! [entity-refs]
\sa QDomNode::namespaceURI(), QDomNode::localName(),
QDomNode::prefix(), QString::isNull(), QString::isEmpty()
*/
-bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
+bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing,
+ QString *errorMsg, int *errorLine, int *errorColumn)
{
- if (!impl)
- impl = new QDomDocumentPrivate();
+ QXmlStreamReader reader(data);
+ reader.setNamespaceProcessing(namespaceProcessing);
+ return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
+}
- QXmlStreamReader streamReader(data);
- streamReader.setNamespaceProcessing(namespaceProcessing);
- return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn);
+static inline QDomDocument::ParseOptions toParseOptions(bool namespaceProcessing)
+{
+ return namespaceProcessing ? QDomDocument::ParseOption::UseNamespaceProcessing
+ : QDomDocument::ParseOption::Default;
+}
+
+static inline void unpackParseResult(const QDomDocument::ParseResult &parseResult,
+ QString *errorMsg, int *errorLine, int *errorColumn)
+{
+ if (!parseResult) {
+ if (errorMsg)
+ *errorMsg = parseResult.errorMessage;
+ if (errorLine)
+ *errorLine = static_cast<int>(parseResult.errorLine);
+ if (errorColumn)
+ *errorColumn = static_cast<int>(parseResult.errorColumn);
+ }
}
/*!
\overload
+ \deprecated [6.8] Use the overload taking ParseOptions instead.
This function reads the XML document from the IO device \a dev, returning
true if the content was successfully parsed; otherwise returns \c false.
@@ -6124,29 +6195,17 @@ bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing,
This will change in Qt 7, which will no longer open \a dev. Applications
should therefore open the device themselves before calling setContent.
*/
-bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
+bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing,
+ QString *errorMsg, int *errorLine, int *errorColumn)
{
- if (!impl)
- impl = new QDomDocumentPrivate();
-
-#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
- if (!dev->isOpen()) {
- qWarning("QDomDocument called with unopened QIODevice. "
- "This will not be supported in future Qt versions");
- if (!dev->open(QIODevice::ReadOnly)) {
- qWarning("QDomDocument::setContent: Failed to open device");
- return false;
- }
- }
-#endif
-
- QXmlStreamReader streamReader(dev);
- streamReader.setNamespaceProcessing(namespaceProcessing);
- return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn);
+ ParseResult result = setContent(dev, toParseOptions(namespaceProcessing));
+ unpackParseResult(result, errorMsg, errorLine, errorColumn);
+ return bool(result);
}
/*!
\overload
+ \deprecated [6.8] Use the overload returning ParseResult instead.
This function reads the XML document from the string \a text, returning
true if the content was successfully parsed; otherwise returns \c false.
@@ -6162,6 +6221,7 @@ bool QDomDocument::setContent(const QString& text, QString *errorMsg, int *error
/*!
\overload
+ \deprecated [6.8] Use the overload returning ParseResult instead.
This function reads the XML document from the byte array \a buffer,
returning true if the content was successfully parsed; otherwise returns
@@ -6176,7 +6236,7 @@ bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int *
/*!
\overload
- \deprecated
+ \deprecated [6.8] Use the overload returning ParseResult instead.
This function reads the XML document from the IO device \a dev, returning
true if the content was successfully parsed; otherwise returns \c false.
@@ -6191,6 +6251,7 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine,
/*!
\overload
\since 5.15
+ \deprecated [6.8] Use the overload taking ParseOptions instead.
This function reads the XML document from the QXmlStreamReader \a reader
and parses it. Returns \c true if the content was successfully parsed;
@@ -6207,12 +6268,165 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine,
\sa QXmlStreamReader
*/
-bool QDomDocument::setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg,
- int *errorLine, int *errorColumn)
+bool QDomDocument::setContent(QXmlStreamReader *reader, bool namespaceProcessing,
+ QString *errorMsg, int *errorLine, int *errorColumn)
+{
+ ParseResult result = setContent(reader, toParseOptions(namespaceProcessing));
+ unpackParseResult(result, errorMsg, errorLine, errorColumn);
+ return bool(result);
+}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 8)
+
+/*!
+ \enum QDomDocument::ParseOption
+ \since 6.5
+
+ This enum describes the possible options that can be used when
+ parsing an XML document using the setContent() method.
+
+ \value Default No parse options are set.
+ \value UseNamespaceProcessing Namespace processing is enabled.
+ \value PreserveSpacingOnlyNodes Text nodes containing only spacing
+ characters are preserved.
+
+ \sa setContent()
+*/
+
+/*!
+ \struct QDomDocument::ParseResult
+ \since 6.5
+ \inmodule QtXml
+ \ingroup xml-tools
+ \brief The struct is used to store the result of QDomDocument::setContent().
+
+ The QDomDocument::ParseResult struct is used for storing the result of
+ QDomDocument::setContent(). If an error is found while parsing an XML
+ document, the message, line and column number of an error are stored in
+ \c ParseResult.
+
+ \sa QDomDocument::setContent()
+*/
+
+/*!
+ \variable QDomDocument::ParseResult::errorMessage
+
+ The field contains the text message of an error found by
+ QDomDocument::setContent() while parsing an XML document.
+
+ \sa QDomDocument::setContent()
+*/
+
+/*!
+ \variable QDomDocument::ParseResult::errorLine
+
+ The field contains the line number of an error found by
+ QDomDocument::setContent() while parsing an XML document.
+
+ \sa QDomDocument::setContent()
+*/
+
+/*!
+ \variable QDomDocument::ParseResult::errorColumn
+
+ The field contains the column number of an error found by
+ QDomDocument::setContent() while parsing an XML document.
+
+ \sa QDomDocument::setContent()
+*/
+
+/*!
+ \fn QDomDocument::ParseResult::operator bool() const
+
+ Returns \c false if any error is found by QDomDocument::setContent();
+ otherwise returns \c true.
+
+ \sa QDomDocument::setContent()
+*/
+
+/*!
+ \fn ParseResult QDomDocument::setContent(const QByteArray &data, ParseOptions options)
+ \fn ParseResult QDomDocument::setContent(QAnyStringView text, ParseOptions options)
+ \fn ParseResult QDomDocument::setContent(QIODevice *device, ParseOptions options)
+ \fn ParseResult QDomDocument::setContent(QXmlStreamReader *reader, ParseOptions options)
+
+ \since 6.5
+
+ This function parses the XML document from the byte array \a
+ data, string view \a text, IO \a device, or stream \a reader
+ and sets it as the content of the document. It tries to
+ detect the encoding of the document, in accordance with the
+ XML specification. Returns the result of parsing in ParseResult,
+ which explicitly converts to \c bool.
+
+ You can use the \a options parameter to specify different parsing
+ options, for example, to enable namespace processing, etc.
+
+ By default, namespace processing is disabled. If it's disabled, the
+ parser does no namespace processing when it reads the XML file. The
+ functions QDomNode::prefix(), QDomNode::localName() and
+ QDomNode::namespaceURI() return an empty string.
+
+ If namespace processing is enabled via the parse \a options, the parser
+ recognizes namespaces in the XML file and sets the prefix name, local
+ name and namespace URI to appropriate values. The functions
+ QDomNode::prefix(), QDomNode::localName() and QDomNode::namespaceURI()
+ return a string for all elements and attributes and return an empty
+ string if the element or attribute has no prefix.
+
+ Text nodes consisting only of whitespace are stripped and won't
+ appear in the QDomDocument. Since Qt 6.5, one can pass
+ QDomDocument::ParseOption::PreserveSpacingOnlyNodes as a parse
+ option, to specify that spacing-only text nodes must be preserved.
+
+ \include qdom.cpp entity-refs
+
+ \note The overload taking IO \a device will try to open it in read-only
+ mode if it is not already open. In that case, the caller is responsible
+ for calling close. This will change in Qt 7, which will no longer open
+ the IO \a device. Applications should therefore open the device themselves
+ before calling setContent().
+
+ \sa ParseResult, ParseOptions
+*/
+QDomDocument::ParseResult QDomDocument::setContentImpl(const QByteArray &data, ParseOptions options)
+{
+ QXmlStreamReader reader(data);
+ reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
+ return setContent(&reader, options);
+}
+
+QDomDocument::ParseResult QDomDocument::setContent(QAnyStringView data, ParseOptions options)
+{
+ QXmlStreamReader reader(data);
+ reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
+ return setContent(&reader, options);
+}
+
+QDomDocument::ParseResult QDomDocument::setContent(QIODevice *device, ParseOptions options)
+{
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ if (!device->isOpen()) {
+ qWarning("QDomDocument called with unopened QIODevice. "
+ "This will not be supported in future Qt versions.");
+ if (!device->open(QIODevice::ReadOnly)) {
+ const auto error = u"QDomDocument::setContent: Failed to open device."_s;
+ qWarning("%s", qPrintable(error));
+ return { error };
+ }
+ }
+#endif
+
+ QXmlStreamReader reader(device);
+ reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
+ return setContent(&reader, options);
+}
+
+QDomDocument::ParseResult QDomDocument::setContent(QXmlStreamReader *reader, ParseOptions options)
{
if (!impl)
impl = new QDomDocumentPrivate();
- return IMPL->setContent(reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
+ return IMPL->setContent(reader, options);
}
/*!
@@ -6751,6 +6965,12 @@ QDomComment QDomNode::toComment() const
return QDomComment();
}
+/*!
+ \variable QDomNode::impl
+ \internal
+ Pointer to private data structure.
+*/
+
QT_END_NAMESPACE
#endif // QT_NO_DOM
diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h
index eabcc34c9e..a3900609c4 100644
--- a/src/xml/dom/qdom.h
+++ b/src/xml/dom/qdom.h
@@ -7,6 +7,8 @@
#include <QtXml/qtxmlglobal.h>
#include <QtCore/qstring.h>
+class tst_QDom;
+
QT_BEGIN_NAMESPACE
@@ -58,11 +60,11 @@ class Q_XML_EXPORT QDomImplementation
{
public:
QDomImplementation();
- QDomImplementation(const QDomImplementation&);
+ QDomImplementation(const QDomImplementation &implementation);
~QDomImplementation();
- QDomImplementation& operator= (const QDomImplementation&);
- bool operator== (const QDomImplementation&) const;
- bool operator!= (const QDomImplementation&) const;
+ QDomImplementation& operator=(const QDomImplementation &other);
+ bool operator==(const QDomImplementation &other) const;
+ bool operator!=(const QDomImplementation &other) const;
// functions
bool hasFeature(const QString& feature, const QString& version) const;
@@ -110,10 +112,10 @@ public:
};
QDomNode();
- QDomNode(const QDomNode&);
- QDomNode& operator= (const QDomNode&);
- bool operator== (const QDomNode&) const;
- bool operator!= (const QDomNode&) const;
+ QDomNode(const QDomNode &node);
+ QDomNode& operator=(const QDomNode &other);
+ bool operator==(const QDomNode &other) const;
+ bool operator!=(const QDomNode &other) const;
~QDomNode();
// DOM functions
@@ -144,7 +146,7 @@ public:
// DOM attributes
QString nodeValue() const;
- void setNodeValue(const QString&);
+ void setNodeValue(const QString &value);
QString prefix() const;
void setPrefix(const QString& pre);
@@ -201,6 +203,7 @@ protected:
QDomNode(QDomNodePrivate*);
private:
+ friend class ::tst_QDom;
friend class QDomDocument;
friend class QDomDocumentType;
friend class QDomNodeList;
@@ -211,10 +214,10 @@ class Q_XML_EXPORT QDomNodeList
{
public:
QDomNodeList();
- QDomNodeList(const QDomNodeList&);
- QDomNodeList& operator= (const QDomNodeList&);
- bool operator== (const QDomNodeList&) const;
- bool operator!= (const QDomNodeList&) const;
+ QDomNodeList(const QDomNodeList &nodeList);
+ QDomNodeList& operator=(const QDomNodeList &other);
+ bool operator==(const QDomNodeList &other) const;
+ bool operator!=(const QDomNodeList &other) const;
~QDomNodeList();
// DOM functions
@@ -240,8 +243,8 @@ class Q_XML_EXPORT QDomDocumentType : public QDomNode
{
public:
QDomDocumentType();
- QDomDocumentType(const QDomDocumentType& x);
- QDomDocumentType& operator= (const QDomDocumentType&);
+ QDomDocumentType(const QDomDocumentType &documentType);
+ QDomDocumentType& operator=(const QDomDocumentType &other);
// DOM read only attributes
QString name() const;
@@ -265,11 +268,27 @@ private:
class Q_XML_EXPORT QDomDocument : public QDomNode
{
public:
+ enum class ParseOption {
+ Default = 0x00,
+ UseNamespaceProcessing = 0x01,
+ PreserveSpacingOnlyNodes = 0x02,
+ };
+ Q_DECLARE_FLAGS(ParseOptions, ParseOption)
+
+ struct ParseResult
+ {
+ QString errorMessage;
+ qsizetype errorLine = 0;
+ qsizetype errorColumn = 0;
+
+ explicit operator bool() const noexcept { return errorMessage.isEmpty(); }
+ };
+
QDomDocument();
explicit QDomDocument(const QString& name);
explicit QDomDocument(const QDomDocumentType& doctype);
- QDomDocument(const QDomDocument& x);
- QDomDocument& operator= (const QDomDocument&);
+ QDomDocument(const QDomDocument &document);
+ QDomDocument& operator=(const QDomDocument &other);
~QDomDocument();
// DOM functions
@@ -297,20 +316,38 @@ public:
inline QDomNode::NodeType nodeType() const { return DocumentNode; }
// Qt extensions
- bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
- bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
- bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
- bool setContent(const QByteArray& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
- bool setContent(const QString& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
- bool setContent(QIODevice* dev, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr );
+#if QT_DEPRECATED_SINCE(6, 8)
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload taking ParseOptions instead.")
+ bool setContent(const QByteArray &text, bool namespaceProcessing, QString *errorMsg = nullptr, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload taking ParseOptions instead.")
+ bool setContent(const QString &text, bool namespaceProcessing, QString *errorMsg = nullptr, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload taking ParseOptions instead.")
+ bool setContent(QIODevice *dev, bool namespaceProcessing, QString *errorMsg = nullptr, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload returning ParseResult instead.")
+ bool setContent(const QByteArray &text, QString *errorMsg, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload returning ParseResult instead.")
+ bool setContent(const QString &text, QString *errorMsg, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload returning ParseResult instead.")
+ bool setContent(QIODevice *dev, QString *errorMsg, int *errorLine = nullptr, int *errorColumn = nullptr);
+ QT_DEPRECATED_VERSION_X_6_8("Use the overload taking ParseOptions instead.")
bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg = nullptr,
int *errorLine = nullptr, int *errorColumn = nullptr);
+#endif // QT_DEPRECATED_SINCE(6, 8)
+
+ Q_WEAK_OVERLOAD
+ ParseResult setContent(const QByteArray &data, ParseOptions options = ParseOption::Default)
+ { return setContentImpl(data, options); }
+ ParseResult setContent(QAnyStringView data, ParseOptions options = ParseOption::Default);
+ ParseResult setContent(QIODevice *device, ParseOptions options = ParseOption::Default);
+ ParseResult setContent(QXmlStreamReader *reader, ParseOptions options = ParseOption::Default);
// Qt extensions
- QString toString(int = 1) const;
- QByteArray toByteArray(int = 1) const;
+ QString toString(int indent = 1) const;
+ QByteArray toByteArray(int indent = 1) const;
private:
+ ParseResult setContentImpl(const QByteArray &data, ParseOptions options);
+
QDomDocument(QDomDocumentPrivate*);
friend class QDomNode;
@@ -320,10 +357,10 @@ class Q_XML_EXPORT QDomNamedNodeMap
{
public:
QDomNamedNodeMap();
- QDomNamedNodeMap(const QDomNamedNodeMap&);
- QDomNamedNodeMap& operator= (const QDomNamedNodeMap&);
- bool operator== (const QDomNamedNodeMap&) const;
- bool operator!= (const QDomNamedNodeMap&) const;
+ QDomNamedNodeMap(const QDomNamedNodeMap &namedNodeMap);
+ QDomNamedNodeMap& operator=(const QDomNamedNodeMap &other);
+ bool operator==(const QDomNamedNodeMap &other) const;
+ bool operator!=(const QDomNamedNodeMap &other) const;
~QDomNamedNodeMap();
// DOM functions
@@ -357,8 +394,8 @@ class Q_XML_EXPORT QDomDocumentFragment : public QDomNode
{
public:
QDomDocumentFragment();
- QDomDocumentFragment(const QDomDocumentFragment& x);
- QDomDocumentFragment& operator= (const QDomDocumentFragment&);
+ QDomDocumentFragment(const QDomDocumentFragment &documentFragment);
+ QDomDocumentFragment& operator=(const QDomDocumentFragment &other);
// Overridden from QDomNode
inline QDomNode::NodeType nodeType() const { return DocumentFragmentNode; }
@@ -374,8 +411,8 @@ class Q_XML_EXPORT QDomCharacterData : public QDomNode
{
public:
QDomCharacterData();
- QDomCharacterData(const QDomCharacterData& x);
- QDomCharacterData& operator= (const QDomCharacterData&);
+ QDomCharacterData(const QDomCharacterData &characterData);
+ QDomCharacterData& operator=(const QDomCharacterData &other);
// DOM functions
QString substringData(unsigned long offset, unsigned long count);
@@ -389,7 +426,7 @@ public:
// DOM attributes
QString data() const;
- void setData(const QString&);
+ void setData(const QString &data);
// Overridden from QDomNode
QDomNode::NodeType nodeType() const;
@@ -407,8 +444,8 @@ class Q_XML_EXPORT QDomAttr : public QDomNode
{
public:
QDomAttr();
- QDomAttr(const QDomAttr& x);
- QDomAttr& operator= (const QDomAttr&);
+ QDomAttr(const QDomAttr &attr);
+ QDomAttr& operator=(const QDomAttr &other);
// DOM read only attributes
QString name() const;
@@ -417,7 +454,7 @@ public:
// DOM attributes
QString value() const;
- void setValue(const QString&);
+ void setValue(const QString &value);
// Overridden from QDomNode
inline QDomNode::NodeType nodeType() const { return AttributeNode; }
@@ -434,8 +471,8 @@ class Q_XML_EXPORT QDomElement : public QDomNode
{
public:
QDomElement();
- QDomElement(const QDomElement& x);
- QDomElement& operator= (const QDomElement&);
+ QDomElement(const QDomElement &element);
+ QDomElement& operator=(const QDomElement &other);
// DOM functions
QString attribute(const QString& name, const QString& defValue = QString() ) const;
@@ -492,8 +529,8 @@ class Q_XML_EXPORT QDomText : public QDomCharacterData
{
public:
QDomText();
- QDomText(const QDomText& x);
- QDomText& operator= (const QDomText&);
+ QDomText(const QDomText &text);
+ QDomText& operator=(const QDomText &other);
// DOM functions
QDomText splitText(int offset);
@@ -513,8 +550,8 @@ class Q_XML_EXPORT QDomComment : public QDomCharacterData
{
public:
QDomComment();
- QDomComment(const QDomComment& x);
- QDomComment& operator= (const QDomComment&);
+ QDomComment(const QDomComment &comment);
+ QDomComment& operator=(const QDomComment &other);
// Overridden from QDomCharacterData
inline QDomNode::NodeType nodeType() const { return CommentNode; }
@@ -530,8 +567,8 @@ class Q_XML_EXPORT QDomCDATASection : public QDomText
{
public:
QDomCDATASection();
- QDomCDATASection(const QDomCDATASection& x);
- QDomCDATASection& operator= (const QDomCDATASection&);
+ QDomCDATASection(const QDomCDATASection &cdataSection);
+ QDomCDATASection& operator=(const QDomCDATASection &other);
// Overridden from QDomText
inline QDomNode::NodeType nodeType() const { return CDATASectionNode; }
@@ -547,8 +584,8 @@ class Q_XML_EXPORT QDomNotation : public QDomNode
{
public:
QDomNotation();
- QDomNotation(const QDomNotation& x);
- QDomNotation& operator= (const QDomNotation&);
+ QDomNotation(const QDomNotation &notation);
+ QDomNotation& operator=(const QDomNotation &other);
// DOM read only attributes
QString publicId() const;
@@ -568,8 +605,8 @@ class Q_XML_EXPORT QDomEntity : public QDomNode
{
public:
QDomEntity();
- QDomEntity(const QDomEntity& x);
- QDomEntity& operator= (const QDomEntity&);
+ QDomEntity(const QDomEntity &entity);
+ QDomEntity& operator=(const QDomEntity &other);
// DOM read only attributes
QString publicId() const;
@@ -589,8 +626,8 @@ class Q_XML_EXPORT QDomEntityReference : public QDomNode
{
public:
QDomEntityReference();
- QDomEntityReference(const QDomEntityReference& x);
- QDomEntityReference& operator= (const QDomEntityReference&);
+ QDomEntityReference(const QDomEntityReference &entityReference);
+ QDomEntityReference& operator=(const QDomEntityReference &other);
// Overridden from QDomNode
inline QDomNode::NodeType nodeType() const { return EntityReferenceNode; }
@@ -606,15 +643,15 @@ class Q_XML_EXPORT QDomProcessingInstruction : public QDomNode
{
public:
QDomProcessingInstruction();
- QDomProcessingInstruction(const QDomProcessingInstruction& x);
- QDomProcessingInstruction& operator= (const QDomProcessingInstruction&);
+ QDomProcessingInstruction(const QDomProcessingInstruction &processingInstruction);
+ QDomProcessingInstruction& operator=(const QDomProcessingInstruction &other);
// DOM read only attributes
QString target() const;
// DOM attributes
QString data() const;
- void setData(const QString& d);
+ void setData(const QString &data);
// Overridden from QDomNode
inline QDomNode::NodeType nodeType() const { return ProcessingInstructionNode; }
@@ -627,7 +664,7 @@ private:
};
-Q_XML_EXPORT QTextStream& operator<<(QTextStream&, const QDomNode&);
+Q_XML_EXPORT QTextStream& operator<<(QTextStream& stream, const QDomNode& node);
#endif // QT_NO_DOM
diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h
index 83d472aa8e..b2ecd534c8 100644
--- a/src/xml/dom/qdom_p.h
+++ b/src/xml/dom/qdom_p.h
@@ -142,7 +142,8 @@ public:
bool operator==(const QDomNodeListPrivate &) const;
bool operator!=(const QDomNodeListPrivate &) const;
- void createList();
+ void createList() const;
+ bool maybeCreateList() const;
QDomNodePrivate *item(int index);
int length() const;
@@ -153,8 +154,8 @@ public:
QDomNodePrivate *node_impl;
QString tagname;
QString nsURI;
- QList<QDomNodePrivate *> list;
- long timestamp;
+ mutable QList<QDomNodePrivate *> list;
+ mutable long timestamp;
};
class QDomNamedNodeMapPrivate
@@ -425,8 +426,8 @@ public:
QDomDocumentPrivate(QDomDocumentPrivate *n, bool deep);
~QDomDocumentPrivate();
- bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg,
- int *errorLine, int *errorColumn);
+ QDomDocument::ParseResult setContent(QXmlStreamReader *reader,
+ QDomDocument::ParseOptions options);
// Attributes
QDomDocumentTypePrivate *doctype() { return type.data(); }
diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp
index b58d2f7ae9..0649e0c75d 100644
--- a/src/xml/dom/qdomhelpers.cpp
+++ b/src/xml/dom/qdomhelpers.cpp
@@ -8,6 +8,7 @@
#include "qdomhelpers_p.h"
#include "qdom_p.h"
#include "qxmlstream.h"
+#include "private/qxmlstream_p.h"
#include <memory>
#include <stack>
@@ -22,13 +23,9 @@ using namespace Qt::StringLiterals;
*
**************************************************************/
-QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing)
- : errorLine(0),
- errorColumn(0),
- doc(d),
- node(d),
- reader(r),
- nsProcessing(namespaceProcessing)
+QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r,
+ QDomDocument::ParseOptions options)
+ : doc(d), node(d), reader(r), parseOptions(options)
{
Q_ASSERT(doc);
Q_ASSERT(reader);
@@ -84,6 +81,8 @@ bool QDomBuilder::parseDTD(const QString &dtd)
bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
const QXmlStreamAttributes &atts)
{
+ const bool nsProcessing =
+ parseOptions.testFlag(QDomDocument::ParseOption::UseNamespaceProcessing);
QDomNodePrivate *n =
nsProcessing ? doc->createElementNS(nsURI, qName) : doc->createElement(qName);
if (!n)
@@ -168,14 +167,9 @@ bool QDomBuilder::skippedEntity(const QString &name)
void QDomBuilder::fatalError(const QString &message)
{
- errorMsg = message;
- errorLine = static_cast<int>(reader->lineNumber());
- errorColumn = static_cast<int>(reader->columnNumber());
-}
-
-QDomBuilder::ErrorInfo QDomBuilder::error() const
-{
- return ErrorInfo(errorMsg, errorLine, errorColumn);
+ parseResult.errorMessage = message;
+ parseResult.errorLine = reader->lineNumber();
+ parseResult.errorColumn = reader->columnNumber();
}
bool QDomBuilder::startEntity(const QString &name)
@@ -232,8 +226,9 @@ bool QDomBuilder::notationDecl(const QString &name, const QString &publicId,
*
**************************************************************/
-QDomParser::QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing)
- : reader(r), domBuilder(d, r, namespaceProcessing)
+QDomParser::QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r,
+ QDomDocument::ParseOptions options)
+ : reader(r), domBuilder(d, r, options)
{
}
@@ -242,11 +237,6 @@ bool QDomParser::parse()
return parseProlog() && parseBody();
}
-QDomBuilder::ErrorInfo QDomParser::errorInfo() const
-{
- return domBuilder.error();
-}
-
bool QDomParser::parseProlog()
{
Q_ASSERT(reader);
@@ -275,9 +265,9 @@ bool QDomParser::parseProlog()
if (reader->isStandaloneDocument()) {
value += u" standalone='yes'"_s;
} else {
- // TODO: Add standalone='no', if 'standalone' is specified. With the current
- // QXmlStreamReader there is no way to figure out if it was specified or not.
- // QXmlStreamReader needs to be modified for handling that case correctly.
+ // Add the standalone attribute only if it was specified
+ if (reader->hasStandaloneDeclaration())
+ value += u" standalone='no'"_s;
}
if (!domBuilder.processingInstruction(u"xml"_s, value)) {
@@ -360,13 +350,14 @@ bool QDomParser::parseBody()
}
break;
case QXmlStreamReader::Characters:
- if (!reader->isWhitespace()) { // Skip the content consisting of only whitespaces
- if (reader->isCDATA() || !reader->text().trimmed().isEmpty()) {
- if (!domBuilder.characters(reader->text().toString(), reader->isCDATA())) {
- domBuilder.fatalError(QDomParser::tr(
- "Error occurred while processing the element content"));
- return false;
- }
+ // Skip the content if it contains only spacing characters,
+ // unless it's CDATA or PreserveSpacingOnlyNodes was specified.
+ if (reader->isCDATA() || domBuilder.preserveSpacingOnlyNodes()
+ || !(reader->isWhitespace() || reader->text().trimmed().isEmpty())) {
+ if (!domBuilder.characters(reader->text().toString(), reader->isCDATA())) {
+ domBuilder.fatalError(
+ QDomParser::tr("Error occurred while processing the element content"));
+ return false;
}
}
break;
diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h
index 81de6e2e80..5a4b2207f9 100644
--- a/src/xml/dom/qdomhelpers_p.h
+++ b/src/xml/dom/qdomhelpers_p.h
@@ -4,6 +4,7 @@
#define QDOMHELPERS_P_H
#include <qcoreapplication.h>
+#include <qdom.h>
#include <private/qglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -33,7 +34,7 @@ class QXmlStreamAttributes;
class QDomBuilder
{
public:
- QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing);
+ QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options);
~QDomBuilder();
bool endDocument();
@@ -53,22 +54,20 @@ public:
const QString &notationName);
void fatalError(const QString &message);
+ QDomDocument::ParseResult result() const { return parseResult; }
- using ErrorInfo = std::tuple<QString, int, int>;
- ErrorInfo error() const;
-
- QString errorMsg;
- int errorLine;
- int errorColumn;
+ bool preserveSpacingOnlyNodes() const
+ { return parseOptions & QDomDocument::ParseOption::PreserveSpacingOnlyNodes; }
private:
QString dtdInternalSubset(const QString &dtd);
+ QDomDocument::ParseResult parseResult;
QDomDocumentPrivate *doc;
QDomNodePrivate *node;
QXmlStreamReader *reader;
QString entityName;
- bool nsProcessing;
+ QDomDocument::ParseOptions parseOptions;
};
/**************************************************************
@@ -81,10 +80,10 @@ class QDomParser
{
Q_DECLARE_TR_FUNCTIONS(QDomParser)
public:
- QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing);
+ QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options);
bool parse();
- QDomBuilder::ErrorInfo errorInfo() const;
+ QDomDocument::ParseResult result() const { return domBuilder.result(); }
private:
bool parseProlog();