示例#1
0
void QWbXmlReader::parseAttributes( QXmlAttributes& attrs )
{
    QString name;
    QString value;
    int index;

    d->currentAttr = QString();

    for (;;) {
        switch ( d->tokenType ) {

            case QWbXmlToken_EOF:
            case QWbXmlToken_EndTag:
            case QWbXmlToken_EndAttrs:
            {
                if ( !name.isEmpty() ) {
                    attrs.append( name, QString(), name, value );
                }
                nextToken();
                return;
            }
            // Not reached.

            case QWbXmlToken_AttrStart:
            {
                if ( !name.isEmpty() ) {
                    attrs.append( name, QString(), name, value );
                }
                d->currentAttr = name;
                name = d->tokenValue;
                index = name.indexOf(QChar('='));
                if ( index != -1 ) {
                    // Attribute value prefix of the form "name=prefix".
                    value = name.mid( index + 1);
                    name = name.left( index );
                } else {
                    // Just the attribute name, with no prefix.
                    value = "";
                }
                nextToken();
            }
            break;

            case QWbXmlToken_String:
            {
                value += d->tokenValue;
                nextToken();
            }
            break;

            default:
            {
                nextToken();
            }
            break;
        }
    }

    d->currentAttr = QString();
}
示例#2
0
void TestResult::toXML(XMLWriter &receiver) const
{
    QXmlAttributes atts;
    atts.append(QLatin1String("name"), QString(), QLatin1String("name"), m_testName);
    atts.append(QLatin1String("result"), QString(), QLatin1String("result"), displayName(m_status));

    if(!m_comment.isEmpty())
        atts.append(QLatin1String("comment"), QString(), QLatin1String("comment"), m_comment);

    receiver.startElement(QLatin1String("test-case"), atts);
    receiver.endElement(QLatin1String("test-case"));
}
示例#3
0
void TestBaseLine::toXML(XMLWriter &receiver) const
{
    switch(m_type)
    {
        case XML: /* Fallthrough. */
        case Fragment: /* Fallthrough. */
        case SchemaIsValid: /* Fallthrough. */
        case Text:
        {
            QXmlAttributes inspectAtts;
            inspectAtts.append(QLatin1String("role"), QString(),
                               QLatin1String("role"), QLatin1String("principal"));
            inspectAtts.append(QLatin1String("compare"), QString(),
                               QLatin1String("compare"), displayName(m_type));
            receiver.startElement(QLatin1String("output-file"), inspectAtts);
            receiver.characters(m_details);
            receiver.endElement(QLatin1String("output-file"));
            return;
        }
        case Ignore:
        {
            Q_ASSERT_X(false, Q_FUNC_INFO, "Serializing 'Ignore' is not implemented.");
            return;
        }
        case Inspect:
        {
            QXmlAttributes inspectAtts;
            inspectAtts.append(QLatin1String("role"), QString(),
                               QLatin1String("role"), QLatin1String("principal"));
            inspectAtts.append(QLatin1String("compare"), QString(),
                               QLatin1String("compare"), QLatin1String("Inspect"));
            receiver.startElement(QLatin1String("output-file"), inspectAtts);
            receiver.characters(m_details);
            receiver.endElement(QLatin1String("output-file"));
            return;
        }
        case ExpectedError:
        {
            receiver.startElement(QLatin1String("expected-error"));
            receiver.characters(m_details);
            receiver.endElement(QLatin1String("expected-error"));
            return;
        }
    }
}
示例#4
0
void ContentReader::startElement(void*, const xmlChar *fullname, const xmlChar ** atts)
{
	QString name(QString((const char*) fullname).toLower());
	QXmlAttributes attrs;
	if (atts)
	{
		for(const xmlChar** cur = atts; cur && *cur; cur += 2)
			attrs.append(QString((char*)*cur), NULL, QString((char*)*cur), QString((char*)*(cur + 1)));
	}
	creader->startElement(NULL, NULL, name, attrs);
}
示例#5
0
void StyleReader::startElement(void*, const xmlChar * fullname, const xmlChar ** atts)
{
	QString* name = new QString((const char*) fullname);
	name = new QString(name->toLower());
	QXmlAttributes* attrs = new QXmlAttributes();
	if (atts)
	{
		for(const xmlChar** cur = atts; cur && *cur; cur += 2)
			attrs->append(QString((char*)*cur), NULL, QString((char*)*cur), QString((char*)*(cur + 1)));
	}
	sreader->startElement(NULL, NULL, *name, *attrs);
}
		bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
		{
			if(depth == 0) {
				Parser::Event *e = new Parser::Event;
				QXmlAttributes a;
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					if(a.index(uri, ln) == -1)
						a.append(atts.qName(n), uri, ln, atts.value(n));
				}
				e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues);
				nsnames.clear();
				nsvalues.clear();
				e->setActualString(in->lastString());

				in->resetLastData();
				eventList.append(e);
				in->pause(true);
			}
			else {
				QDomElement e = doc->createElementNS(namespaceURI, qName);
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					bool have;
					if(!uri.isEmpty()) {
						have = e.hasAttributeNS(uri, ln);
						if(qt_bug_have)
							have = !have;
					}
					else
						have = e.hasAttribute(ln);
					if(!have)
						e.setAttributeNS(uri, atts.qName(n), atts.value(n));
				}

				if(depth == 1) {
					elem = e;
					current = e;
				}
				else {
					current.appendChild(e);
					current = e;
				}
			}
			++depth;
			return true;
		}
示例#7
0
void TestCase::toXML(XMLWriter &receiver) const
{
    /* <test-case> */
    QXmlAttributes test_caseAtts;
    test_caseAtts.append(QLatin1String("is-XPath2"), QString(),
                         QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true")
                                                               : QLatin1String("false"));
    test_caseAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), name());
    test_caseAtts.append(QLatin1String("creator"), QString(), QLatin1String("creator"), creator());
    QString scen;
    switch(scenario())
    {
        case Standard:
        {
            scen = QLatin1String("standard");
            break;
        }
        case ParseError:
        {
            scen = QLatin1String("parse-error");
            break;
        }
        case RuntimeError:
        {
            scen = QLatin1String("runtime-error");
            break;
        }
        case Trivial:
        {
            scen = QLatin1String("trivial");
            break;
        }
        default: /* includes 'AnyError' */
            Q_ASSERT(false);
    }
    test_caseAtts.append(QLatin1String("scenario"), QString(), QLatin1String("scenario"), scen);
    test_caseAtts.append(QLatin1String(QLatin1String("FilePath")), QString(),
                         QLatin1String("FilePath"), QString());
    receiver.startElement(QLatin1String("test-case"), test_caseAtts);

    /* <description> */
    receiver.startElement(QLatin1String("description"), test_caseAtts);
    receiver.characters(description());

    /* </description> */
    receiver.endElement(QLatin1String("description"));

    /* <query> */
    QXmlAttributes queryAtts;
    queryAtts.append(QLatin1String("date"), QString(), QLatin1String("date"), /* This date is a dummy. */
                     QDate::currentDate().toString(Qt::ISODate));
    queryAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), testCasePath().toString());
    receiver.startElement(QLatin1String("query"), queryAtts);

    /* </query> */
    receiver.endElement(QLatin1String("query"));

    /* Note: this is invalid, we don't add spec-citation. */
    TestBaseLine::List bls(baseLines());
    const TestBaseLine::List::const_iterator end(bls.constEnd());
    TestBaseLine::List::const_iterator it(bls.constBegin());

    for(; it != end; ++it)
        (*it)->toXML(receiver);

    /* </test-case> */
    receiver.endElement(QLatin1String("test-case"));
}
void TestSuiteResult::toXML(XMLWriter &receiver) const
{
    /* If this data needs to be configurable in someway(say, another
     * XML format is supported), then break out the info into getters(alternatively, combined
     * with setters, or that the class is subclassed), and access the getters instead.
     */
    const QString organizationName          (QLatin1String("K Desktop Environment(KDE)"));
    const QString organizationWebsite       (QLatin1String("http://www.kde.org/"));
    const QString submittorName             (QLatin1String("Frans Englich"));
    const QString submittorEmail            (QLatin1String("*****@*****.**"));
    const QString implementationVersion     (QLatin1String("0.1"));
    const QString implementationName        (QLatin1String("Patternist"));
    const QString implementationDescription (QLatin1String(
                                             "Patternist is an implementation written in C++ "
                                             "and with the Qt/KDE libraries. "
                                             "It is licensed under GNU LGPL and part of KDE, "
                                             "the K Desktop Environment."));

    /* Not currently serialized:
     * - <implementation-defined-items>
     * - <features>
     * - <context-properties>
     */

    receiver.startDocument();
    /* <test-suite-result> */
    receiver.startPrefixMapping(QString(), Global::xqtsResultNS);
    receiver.startElement(QLatin1String("test-suite-result"));
    receiver.endPrefixMapping(QString());

    /* <implementation> */
    QXmlAttributes implementationAtts;
    implementationAtts.append(QLatin1String("name"), QString(),
                              QLatin1String("name"), implementationName);
    implementationAtts.append(QLatin1String("version"), QString(),
                              QLatin1String("version"), implementationVersion);
    receiver.startElement(QLatin1String("implementation"), implementationAtts);

    /* <organization> */
    QXmlAttributes organizationAtts;
    organizationAtts.append(QLatin1String("name"), QString(),
                            QLatin1String("name"), organizationName);
    organizationAtts.append(QLatin1String("website"), QString(),
                            QLatin1String("website"), organizationWebsite);
    receiver.startElement(QLatin1String("organization"), organizationAtts);

    /* </organization> */
    receiver.endElement(QLatin1String("organization"));

    /* <submittor> */
    QXmlAttributes submittorAtts;
    submittorAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), submittorName);
    submittorAtts.append(QLatin1String("email"), QString(), QLatin1String("email"), submittorEmail);
    receiver.startElement(QLatin1String("submittor"), submittorAtts);

    /* </submittor> */
    receiver.endElement(QLatin1String("submittor"));

    /* <description> */
    receiver.startElement(QLatin1String("description"));

    /* <p> */
    receiver.startElement(QLatin1String("p"));
    receiver.characters(implementationDescription);

    /* </p> */
    receiver.endElement(QLatin1String("p"));
    /* </description> */
    receiver.endElement(QLatin1String("description"));

    /* </implementation> */
    receiver.endElement(QLatin1String("implementation"));

    /* <syntax> */
    receiver.startElement(QLatin1String("syntax"));
    receiver.characters(QLatin1String(QLatin1String("XQuery")));

    /* </syntax> */
    receiver.endElement(QLatin1String("syntax"));

    /* <test-run> */
    QXmlAttributes test_runAtts;
    test_runAtts.append(QLatin1String("dateRun"), QString(), QLatin1String("dateRun"), m_runDate.toString(QLatin1String("yyyy-MM-dd")));
    receiver.startElement(QLatin1String("test-run"), test_runAtts);

    /* <test-suite> */
    QXmlAttributes test_suiteAtts;
    test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion);
    receiver.startElement(QLatin1String("test-suite"), test_suiteAtts);

    /* </test-suite> */
    receiver.endElement(QLatin1String("test-suite"));

    /* </test-run> */
    receiver.endElement(QLatin1String("test-run"));

    /* Serialize the TestResults: tons of test-case elements. */
    const TestResult::List::const_iterator end(m_results.constEnd());
    TestResult::List::const_iterator it(m_results.constBegin());

    for(; it != end; ++it)
        (*it)->toXML(receiver);

    /* </test-suite-result> */
    receiver.endElement(QLatin1String("test-suite-result"));
    receiver.endDocument();
}
示例#9
0
	virtual bool startElement(const QString &namespaceURI, const QString &, const QString &qName, const QXmlAttributes &attrs)
	{
		kdDebug(26001) << "SVGFragmentSearcher::startElement, namespaceURI " << namespaceURI << ", qName " << qName << endl;
		bool parse = m_result;
		if(!parse)
		{
			int pos = attrs.index("id");
			if(pos > -1 && attrs.value(pos) == m_id)
				parse = true;
		}

		if(parse)
		{
			DOM::Element impl = static_cast<DOM::Document *>(m_doc)->createElementNS(namespaceURI, qName);
			SVGElementImpl *newElement = SVGDocumentImpl::createElement(qName, impl, m_doc);
			newElement->setViewportElement(m_doc->rootElement());

			if(m_currentNode)
				m_currentNode->appendChild(*newElement);
			else
				m_result = newElement;

			QXmlAttributes newAttrs;

			for(int i = 0; i < attrs.count(); i++)
			{
				QString name = attrs.localName(i);
				QString value = attrs.value(i);

				if(name == "id")
				{
					value = "@fragment@" + m_url.prettyURL() + "@" + value;
					m_idMap[value] = newElement;
				}
				else
				if(name == "href")
				{
					value.stripWhiteSpace();

					if(value.startsWith("#"))
					{
						value.remove(0, 1);

						// Convert the id to its mangled version.
						QString id = "@fragment@" + m_url.prettyURL() + "@" + value;

						if(m_idMap.contains(id))
						{
							// This is a local reference to an element within the fragment.
							// Just convert the href.
							value = id;
						}
						else
						{
							// This is a local reference to an id outside of the fragment.
							// Change it into an absolute href.
							value = m_url.prettyURL() + "#" + value;
						}
					}
				}

				newAttrs.append(attrs.qName(i), attrs.uri(i), attrs.localName(i), value);
			}

			newElement->setAttributes(newAttrs);
			m_currentNode = newElement;
		}

		return true;
	}