int indexOf(const QXmlAttributes & attributes, const QString & name, const QString & type = "CDATA", const bool mandatory = true) { const int idx(attributes.index(name)); if (idx < 0 || idx > attributes.length()) { return -1; } if (attributes.type(idx) != type) { return -1; } if (mandatory && attributes.value(idx).isEmpty()) { return -1; } return idx; }
QString ContentHandler::formatAttributes(const QXmlAttributes &atts) { QString result; for (int i = 0, cnt = atts.count(); i < cnt; ++i) { if (i != 0) result += ", "; result += "{localName=\"" + escapeStr(atts.localName(i)) + "\", qName=\"" + escapeStr(atts.qName(i)) + "\", uri=\"" + escapeStr(atts.uri(i)) + "\", type=\"" + escapeStr(atts.type(i)) + "\", value=\"" + escapeStr(atts.value(i)) + "\"}"; } return result; }