4#include <QtXml/qtxmlglobal.h>
11#include "private/qxmlstream_p.h"
27 QDomDocument::ParseOptions options)
69 if (obra >= 0 && cbra >= 0)
84 const bool nsProcessing =
91 n->
setLocation(
int(reader->lineNumber()),
int(reader->columnNumber()));
97 for (
const auto &attr : atts) {
101 attr.qualifiedName().toString(),
102 attr.value().toString());
104 domElement->setAttribute(attr.qualifiedName().toString(),
105 attr.value().toString());
114 if (!node || node == doc)
127 std::unique_ptr<QDomNodePrivate>
n;
130 }
else if (!entityName.
isEmpty()) {
131 auto e = std::make_unique<QDomEntityPrivate>(
141 n->setLocation(
int(reader->lineNumber()),
int(reader->columnNumber()));
153 n->
setLocation(
int(reader->lineNumber()),
int(reader->columnNumber()));
163 n->
setLocation(
int(reader->lineNumber()),
int(reader->columnNumber()));
171 parseResult.
errorLine = reader->lineNumber();
191 n->
setLocation(
int(reader->lineNumber()),
int(reader->columnNumber()));
230 QDomDocument::ParseOptions options)
231 : reader(
r), domBuilder(
d,
r, options)
237 return parseProlog() && parseBody();
240bool QDomParser::parseProlog()
244 bool foundDtd =
false;
246 while (!reader->atEnd()) {
249 if (reader->hasError()) {
254 switch (reader->tokenType()) {
255 case QXmlStreamReader::StartDocument:
256 if (!reader->documentVersion().isEmpty()) {
258 value += reader->documentVersion();
260 if (!reader->documentEncoding().isEmpty()) {
261 value += u
" encoding='"_s;
262 value += reader->documentEncoding();
265 if (reader->isStandaloneDocument()) {
266 value += u
" standalone='yes'"_s;
269 if (reader->hasStandaloneDeclaration())
270 value += u
" standalone='no'"_s;
275 QDomParser::tr(
"Error occurred while processing XML declaration"));
280 case QXmlStreamReader::DTD:
282 domBuilder.
fatalError(QDomParser::tr(
"Multiple DTD sections are not allowed"));
287 if (!domBuilder.
startDTD(reader->dtdName().toString(),
288 reader->dtdPublicId().toString(),
289 reader->dtdSystemId().toString())) {
291 QDomParser::tr(
"Error occurred while processing document type declaration"));
294 if (!domBuilder.
parseDTD(reader->text().toString()))
296 if (!parseMarkupDecl())
299 case QXmlStreamReader::Comment:
300 if (!domBuilder.
comment(reader->text().toString())) {
301 domBuilder.
fatalError(QDomParser::tr(
"Error occurred while processing comment"));
305 case QXmlStreamReader::ProcessingInstruction:
307 reader->processingInstructionData().toString())) {
309 QDomParser::tr(
"Error occurred while processing a processing instruction"));
322bool QDomParser::parseBody()
326 std::stack<QString> tagStack;
327 while (!reader->atEnd() && !reader->hasError()) {
328 switch (reader->tokenType()) {
329 case QXmlStreamReader::StartElement:
330 tagStack.push(reader->qualifiedName().toString());
331 if (!domBuilder.
startElement(reader->namespaceUri().toString(),
332 reader->qualifiedName().toString(),
333 reader->attributes())) {
335 QDomParser::tr(
"Error occurred while processing a start element"));
339 case QXmlStreamReader::EndElement:
340 if (tagStack.empty() || reader->qualifiedName() != tagStack.top()) {
342 QDomParser::tr(
"Unexpected end element '%1'").
arg(reader->name()));
348 QDomParser::tr(
"Error occurred while processing an end element"));
352 case QXmlStreamReader::Characters:
356 || !(reader->isWhitespace() || reader->text().trimmed().isEmpty())) {
357 if (!domBuilder.
characters(reader->text().toString(), reader->isCDATA())) {
359 QDomParser::tr(
"Error occurred while processing the element content"));
364 case QXmlStreamReader::Comment:
365 if (!domBuilder.
comment(reader->text().toString())) {
366 domBuilder.
fatalError(QDomParser::tr(
"Error occurred while processing comments"));
370 case QXmlStreamReader::ProcessingInstruction:
372 reader->processingInstructionData().toString())) {
374 QDomParser::tr(
"Error occurred while processing a processing instruction"));
378 case QXmlStreamReader::EntityReference:
381 QDomParser::tr(
"Error occurred while processing an entity reference"));
386 domBuilder.
fatalError(QDomParser::tr(
"Unexpected token"));
393 if (reader->hasError()) {
399 if (!tagStack.empty()) {
400 domBuilder.
fatalError(QDomParser::tr(
"Tag mismatch"));
407bool QDomParser::parseMarkupDecl()
411 const auto entities = reader->entityDeclarations();
412 for (
const auto &entityDecl :
entities) {
416 if (!entityDecl.publicId().isEmpty() || !entityDecl.systemId().isEmpty()) {
419 entityDecl.publicId().toString(),
420 entityDecl.systemId().toString(),
421 entityDecl.notationName().toString())) {
423 QDomParser::tr(
"Error occurred while processing entity declaration"));
429 const auto notations = reader->notationDeclarations();
430 for (
const auto ¬ationDecl : notations) {
431 if (!domBuilder.
notationDecl(notationDecl.name().toString(),
432 notationDecl.publicId().toString(),
433 notationDecl.systemId().toString())) {
435 QDomParser::tr(
"Error occurred while processing notation declaration"));
bool characters(const QString &characters, bool cdata=false)
bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts)
QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options)
bool startDTD(const QString &name, const QString &publicId, const QString &systemId)
bool skippedEntity(const QString &name)
bool processingInstruction(const QString &target, const QString &data)
bool startEntity(const QString &name)
void fatalError(const QString &message)
bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)
bool parseDTD(const QString &dtd)
bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString ¬ationName)
bool preserveSpacingOnlyNodes() const
bool comment(const QString &characters)
bool notationDecl(const QString &name, const QString &publicId, const QString &systemId)
QDomElementPrivate * createElement(const QString &tagName)
QDomCDATASectionPrivate * createCDATASection(const QString &data)
QDomProcessingInstructionPrivate * createProcessingInstruction(const QString &target, const QString &data)
QDomTextPrivate * createTextNode(const QString &data)
QDomDocumentTypePrivate * doctype()
QDomEntityReferencePrivate * createEntityReference(const QString &name)
QDomElementPrivate * createElementNS(const QString &nsURI, const QString &qName)
QDomCommentPrivate * createComment(const QString &data)
QDomNodePrivate * appendChild(QDomNodePrivate *newChild) override
void setAttributeNS(const QString &nsURI, const QString &qName, const QString &newValue)
virtual QDomNodePrivate * appendChild(QDomNodePrivate *newChild)
void setLocation(int lineNumber, int columnNumber)
QDomNodePrivate * parent() const
QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options)
constexpr QStringView left(qsizetype n) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QStringView sliced(qsizetype pos) const noexcept
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static const struct QTextHtmlEntity entities[]
QList< QChar > characters