📄 qxmlstream.g
字号:
if (!QXmlUtils::isPublicID(symString(1).toString())) { raiseWellFormedError(QXmlStream::tr("%1 is an invalid PUBLIC identifier.").arg(symString(1).toString())); resume($rule_number); return false; } } break; ./ entity_value ::= QUOTE QUOTE;/. case $rule_number:./entity_value ::= DBLQUOTE DBLQUOTE;/. case $rule_number: clearSym(); break;./entity_value ::= QUOTE entity_value_content_with_dblquote QUOTE;/. case $rule_number:./entity_value ::= DBLQUOTE entity_value_content_with_quote DBLQUOTE;/. case $rule_number: sym(1) = sym(2); break;./entity_value_content_with_dblquote ::= entity_value_content_with_dblquote entity_value_content;/. case $rule_number:./entity_value_content_with_quote ::= entity_value_content_with_quote entity_value_content;/. case $rule_number:./entity_value_content_with_dblquote ::= entity_value_content_with_dblquote DBLQUOTE;/. case $rule_number:./entity_value_content_with_quote ::= entity_value_content_with_quote QUOTE;/. case $rule_number: sym(1).len += sym(2).len; break;./entity_value_content_with_dblquote ::= entity_value_content;entity_value_content_with_quote ::= entity_value_content;entity_value_content_with_dblquote ::= DBLQUOTE;entity_value_content_with_quote ::= QUOTE;entity_value_content ::= LETTER | DIGIT | LANGLE | RANGLE | HASH | LBRACK | RBRACK | LPAREN | RPAREN | PIPE | EQ | SLASH | COLON | SEMICOLON | COMMA | SPACE | DASH | PLUS | STAR | DOT | QUESTIONMARK | BANG;entity_value_content ::= char_ref | entity_ref_in_entity_value | entity_done;attribute_value ::= QUOTE QUOTE;/. case $rule_number:./attribute_value ::= DBLQUOTE DBLQUOTE;/. case $rule_number: clearSym(); break;./attribute_value ::= QUOTE attribute_value_content_with_dblquote QUOTE;/. case $rule_number:./attribute_value ::= DBLQUOTE attribute_value_content_with_quote DBLQUOTE;/. case $rule_number: sym(1) = sym(2); lastAttributeValue = symString(1); break;./attribute_value_content_with_dblquote ::= attribute_value_content_with_dblquote attribute_value_content;/. case $rule_number:./attribute_value_content_with_quote ::= attribute_value_content_with_quote attribute_value_content;/. case $rule_number:./attribute_value_content_with_dblquote ::= attribute_value_content_with_dblquote DBLQUOTE;/. case $rule_number:./attribute_value_content_with_quote ::= attribute_value_content_with_quote QUOTE;/. case $rule_number: sym(1).len += sym(2).len; break;./attribute_value_content_with_dblquote ::= attribute_value_content | DBLQUOTE;attribute_value_content_with_quote ::= attribute_value_content | QUOTE;attribute_value_content ::= literal_content | char_ref | entity_ref_in_attribute_value | entity_done;attribute ::= qname space_opt EQ space_opt attribute_value;/. case $rule_number: { QStringRef prefix = symPrefix(1); if (prefix.isEmpty() && symString(1) == QLatin1String("xmlns") && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); namespaceDeclaration.prefix.clear(); const QStringRef ns(symString(5)); if(ns == QLatin1String("http://www.w3.org/2000/xmlns/") || ns == QLatin1String("http://www.w3.org/XML/1998/namespace")) raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); else namespaceDeclaration.namespaceUri = addToStringStorage(ns); } else { Attribute &attribute = attributeStack.push(); attribute.key = sym(1); attribute.value = sym(5); QStringRef attributeQualifiedName = symName(1); bool normalize = false; for (int a = 0; a < dtdAttributes.size(); ++a) { DtdAttribute &dtdAttribute = dtdAttributes[a]; if (!dtdAttribute.isCDATA && dtdAttribute.tagName == qualifiedName && dtdAttribute.attributeQualifiedName == attributeQualifiedName ) { normalize = true; break; } } if (normalize) { // normalize attribute value (simplify and trim) int pos = textBuffer.size(); int n = 0; bool wasSpace = true; for (int i = 0; i < attribute.value.len; ++i) { QChar c = textBuffer.at(attribute.value.pos + i); if (c.unicode() == ' ') { if (wasSpace) continue; wasSpace = true; } else { wasSpace = false; } textBuffer.inline_append(textBuffer.at(attribute.value.pos + i)); ++n; } if (wasSpace) while (n && textBuffer.at(pos + n - 1).unicode() == ' ') --n; attribute.value.pos = pos; attribute.value.len = n; } if (prefix == QLatin1String("xmlns") && namespaceProcessing) { NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); QStringRef namespacePrefix = symString(attribute.key); QStringRef namespaceUri = symString(attribute.value); attributeStack.pop(); if ((namespacePrefix == QLatin1String("xml") ^ namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")) || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/") || namespaceUri.isEmpty() || namespacePrefix == QLatin1String("xmlns")) raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration.")); namespaceDeclaration.prefix = addToStringStorage(namespacePrefix); namespaceDeclaration.namespaceUri = addToStringStorage(namespaceUri); } } } break;./attribute_list_opt ::= | space | space attribute_list space_opt;attribute_list ::= attribute | attribute_list space attribute;stag_start ::= LANGLE qname;/. case $rule_number: { normalizeLiterals = true; Tag &tag = tagStack_push(); prefix = tag.namespaceDeclaration.prefix = addToStringStorage(symPrefix(2)); name = tag.name = addToStringStorage(symString(2)); qualifiedName = tag.qualifiedName = addToStringStorage(symName(2)); if (!validateName(qualifiedName)) raiseWellFormedError(QXmlStream::tr("Invalid XML name.")); } break;./empty_element_tag ::= stag_start attribute_list_opt SLASH RANGLE;/. case $rule_number: isEmptyElement = true; // fall through./stag ::= stag_start attribute_list_opt RANGLE;/. case $rule_number: setType(QXmlStreamReader::StartElement); resolveTag(); if (tagStack.size() == 1 && hasSeenTag && !inParseEntity) raiseWellFormedError(QXmlStream::tr("Extra content at end of document.")); hasSeenTag = true; break;./etag ::= LANGLE SLASH qname space_opt RANGLE;/. case $rule_number: { setType(QXmlStreamReader::EndElement); Tag &tag = tagStack_pop(); namespaceUri = tag.namespaceDeclaration.namespaceUri; name = tag.name; qualifiedName = tag.qualifiedName; if (qualifiedName != symName(3)) raiseWellFormedError(QXmlStream::tr("Opening and ending tag mismatch.")); } break;./entity_ref ::= AMPERSAND name SEMICOLON;/. case $rule_number: { sym(1).len += sym(2).len + 1; QString reference = symString(2).toString(); if (entityHash.contains(reference)) { Entity &entity = entityHash[reference]; if (entity.unparsed) { raiseWellFormedError(QXmlStream::tr("Reference to unparsed entity '%1'.").arg(reference)); } else { if (!entity.hasBeenParsed) { parseEntity(entity.value); entity.hasBeenParsed = true; } if (entity.literal) putStringLiteral(entity.value); else if (referenceEntity(entity)) putReplacement(entity.value); textBuffer.chop(2 + sym(2).len); clearSym(); } break; } else if (entitiesMustBeDeclared()) { raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(reference)); break; } setType(QXmlStreamReader::EntityReference); name = symString(2); } break;./pereference ::= PERCENT name SEMICOLON;/. case $rule_number: { sym(1).len += sym(2).len + 1; QString reference = symString(2).toString(); if (parameterEntityHash.contains(reference)) { referenceToParameterEntityDetected = true; Entity &entity = parameterEntityHash[reference]; if (entity.unparsed || entity.external) { referenceToUnparsedEntityDetected = true; } else { if (referenceEntity(entity)) putString(entity.value); textBuffer.chop(2 + sym(2).len); clearSym(); } } else if (entitiesMustBeDeclared()) { raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(symString(2).toString())); } } break;./entity_ref_in_entity_value ::= AMPERSAND name SEMICOLON;/. case $rule_number: sym(1).len += sym(2).len + 1; break;./entity_ref_in_attribute_value ::= AMPERSAND name SEMICOLON;/. case $rule_number: { sym(1).len += sym(2).len + 1; QString reference = symString(2).toString(); if (entityHash.contains(reference)) { Entity &entity = entityHash[reference]; if (entity.unparsed || entity.value.isNull()) { raiseWellFormedError(QXmlStream::tr("Reference to external entity '%1' in attribute value.").arg(reference)); break; } if (!entity.hasBeenParsed) { parseEntity(entity.value); entity.hasBeenParsed = true; } if (entity.literal) putStringLiteral(entity.value); else if (referenceEntity(entity)) putReplacementInAttributeValue(entity.value); textBuffer.chop(2 + sym(2).len); clearSym(); } else if (entitiesMustBeDeclared()) { raiseWellFormedError(QXmlStream::tr("Entity '%1' not declared.").arg(reference)); } } break;./char_ref ::= AMPERSAND HASH char_ref_value SEMICOLON;/. case $rule_number: { if (uint s = resolveCharRef(3)) { if (s >= 0xffff) putStringLiteral(QString::fromUcs4(&s, 1)); else putChar((LETTER << 16) | s); textBuffer.chop(3 + sym(3).len); clearSym(); } else { raiseWellFormedError(QXmlStream::tr("Invalid character reference.")); } } break;./char_ref_value ::= LETTER | DIGIT;char_ref_value ::= char_ref_value LETTER;/. case $rule_number:./char_ref_value ::= char_ref_value DIGIT;/. case $rule_number: sym(1).len += sym(2).len; break;./content ::= content content_char_list;content ::= content stag content etag;content ::= content empty_element_tag;content ::= content comment;content ::= content cdata;content ::= content xml_decl;content ::= content processing_instruction;content ::= content doctype_decl;content ::= content char_ref;content ::= content entity_ref;content ::= content entity_done;content ::= ;space ::= SPACE;/. case $rule_number: sym(1).len += fastScanSpace(); if (atEnd) { resume($rule_number); return false; } break;./space_opt ::=;space_opt ::= space;--qname ::= COLON;--/.-- case $rule_number:--./qname ::= LETTER;/. case $rule_number: { sym(1).len += fastScanName(&sym(1).prefix); if (atEnd) { resume($rule_number); return false; } } break;./--name ::= COLON;--/.-- case $rule_number:--./name ::= LETTER;/. case $rule_number: sym(1).len += fastScanName(); if (atEnd) { resume($rule_number); return false; } break;./nmtoken ::= LETTER;/. case $rule_number:./nmtoken ::= DIGIT;/. case $rule_number:./nmtoken ::= DOT;/. case $rule_number:./nmtoken ::= DASH;/. case $rule_number:./nmtoken ::= COLON;/. case $rule_number: sym(1).len += fastScanNMTOKEN(); if (atEnd) { resume($rule_number); return false; } break;.//. default: ; } // switch act = state_stack[tos] = nt_action (act, lhs[r] - TERMINAL_COUNT); if (type != QXmlStreamReader::NoToken) return true; } else { parseError(); break; } } return false;}./
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -