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; }
bool nftrcreader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs) { if (name == "name") inName = true; else if (name == "file") inFile = true; else if (name == "tnail") inTNail = true; else if (name == "img") inImg = true; else if (name == "psize") inPSize = true; else if (name == "color") inColor = true; else if (name == "descr") inDescr = true; else if (name == "usage") inUsage = true; else if (name == "scribus_version") inScribusVersion = true; else if (name == "date") inDate = true; else if (name == "author") inAuthor = true; else if (name == "email") inEmail = true; if (name == "template") { // new template starts here inTemplate = true; QString category; QString enCat; for (int i = 0; i < attrs.count(); i++) { if (attrs.localName(i) == "category") { category = getCategory(attrs.value(i)); enCat = attrs.value(i); } } tmpTemplate = new nfttemplate(new QFile(currentFile), category); // create a new template tmpTemplate->enCategory = enCat; } if (name == "settings") inSettings = true; return true; }
void LinkedTextHandler::startRef(const QXmlAttributes& attrib) { if (!m_curString.isEmpty()) { m_children.append(new LT_Text(m_curString)); debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data()); m_curString=""; } ASSERT(m_ref==0); m_ref = new LT_Ref; m_ref->setRefId(attrib.value("refid")); m_ref->setExtId(attrib.value("external")); ASSERT(attrib.value("kindref")=="compound" || attrib.value("kindref")=="member"); m_ref->setTargetKind(attrib.value("kindref")=="compound" ? ILT_Ref::Compound : ILT_Ref::Member); }
bool CGrammtabHandler::startElement(const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& qName, const QXmlAttributes& atts) { if (qName == "PoS") { currentItem = gramTab->AddPart(atts.value("id").toInt(), atts.value("short")); } else if (qName == "grammem") { currentItem = gramTab->AddGrammem(atts.value("id").toInt(), atts.value("short")); } return true; }
bool UiHandler::startElement( const QString& /* namespaceURI */, const QString& /* localName */, const QString& qName, const QXmlAttributes& atts ) { if ( qName == QString("item") ) { flush(); if ( !atts.value(QString("text")).isEmpty() ) source = atts.value( QString("text") ); } else if ( qName == QString("string") ) { flush(); } accum.truncate( 0 ); return TRUE; }
bool ListParser::startTag(const QString &tag, const QXmlAttributes &atts) { if (root() == "list") { if (tag == "options") { k->pattern = atts.value("pattern"); k->type = atts.value("type").toInt(); } else if (tag == "caseSensitive") { k->caseSensitive = bool(atts.value("enabled").toInt()); } else if (tag == "regexp") { k->regexp = bool(atts.value("enabled").toInt()); } } return true; }
void IncludeHandler::startInclude(const QXmlAttributes &attrib) { m_curString = ""; m_refId = attrib.value("refid"); m_isLocal = attrib.value("local")=="yes"; m_parent->setDelegate(this); }
bool startElement( const QString&, const QString &, const QString &name, const QXmlAttributes &a ) { if (fresh) { if (name=="playlist") { fresh=false; return true; } else { return false; } } if (name != "item") return true; QMap<QString,QString> propMap; for (int i=0; i<a.count(); i++) { propMap[a.qName(i)] = a.value(i); } saver->readItem(propMap); return true; }
bool Button::xml_start(const QString & qName, const QXmlAttributes & atts) { //printf("Procesando botón %s\n",qName.toLocal8Bit().data() ); //mButton *w=(mButton *)widget; if(qName=="button" && check_id(atts) ) { //QString icon=atts.value("icon"); //if(!title.isEmpty()) widget->setWindowTitle ( atts.value("title") ); widget_properties(atts,this); return true; } else if(qName=="text") { return true; } else if(qName=="icon") { return true; } else if(qName=="signal") { QString signal=atts.value("name"); if(signal=="clicked") QObject::connect((mButton*)widget, SIGNAL(clicked()), (mButton*)widget, SLOT(clicked_cb()) ); return true; } return false; }
bool SimpleXMLHandler::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes) { // maybe check for double opening lines? //qDebug("lol"); if (qName == "LINES") { bool ok1 = true, ok2 = true; row = 0; readingCards = true; properties.resize(attributes.value("ColCount").toInt(&ok1)); // cards.resize(attributes.value("RowCount").toInt(&ok2) - 1); if (!ok1 || !ok2 ) { errorStr = "Can't convert string to double."; return false; } } else if (!readingCards) { return true; } else if (qName == "LINE") { column = 0; currentCard = Card(); } else if (qName == "CELL") { currentText.clear(); } return true; }
bool startElement( const QString& /*namespaceURI*/, const QString& localName, const QString& qName, const QXmlAttributes& atts ) { // Some Parent Elements have special meanings if ( stack.isEmpty() ) { if ( qName == "definitions" ) return true; // Include another file if ( qName == "include" ) { QString value = atts.value( "file" ); impl->imports.push_back( value ); return true; } } cElement* element = new cElement; element->setName( localName.latin1() ); element->copyAttributes( atts ); // Child Element ? if ( stack.count() > 0 ) { cElement* parent = stack.current(); // Pop the potential parent parent->addChild( element ); // Add the child to it's parent element->setParent( parent ); } stack.push( element ); // Push our element (there may be children) return true; }
bool KWord13Parser::startElementLayout(const QString&, const QXmlAttributes& attributes, KWord13StackItem *stackItem) { // ### TODO: check parent? if (stackItem->elementType == KWord13TypeIgnore) { return true; } stackItem->elementType = KWord13TypeLayout; if (m_currentFormat) { kWarning(30520) << "Current format defined! (Layout)"; delete m_currentFormat; m_currentFormat = 0; } if (m_currentLayout) { // Delete an eventually already existing paragraph (should not happen) kWarning(30520) << "Current layout already defined!"; delete m_currentLayout; } m_currentLayout = new KWord13Layout; m_currentLayout->m_outline = (attributes.value("outline") == "true"); return true; }
bool QphHandler::startElement(const QString & /* namespaceURI */, const QString & /* localName */, const QString &qName, const QXmlAttributes &atts) { if (qName == QLatin1String("QPH")) { m_language = atts.value(QLatin1String("language")); m_sourceLanguage = atts.value(QLatin1String("sourcelanguage")); } else if (qName == QLatin1String("phrase")) { source.truncate(0); target.truncate(0); definition.truncate(0); } accum.truncate(0); return true; }
bool Handler::startElement(const QString &, const QString &, const QString & qName, const QXmlAttributes &attr) { if (qName == "item") { if (inItem) return false; else { inItem = true; linkString = attr.value("rdf:about"); } } else if (qName == "title") { if (inTitle) return false; else if (!titleString.isEmpty()) return false; else if (inItem) inTitle = true; } else if (qName == "link") { if (inLink) return false; else if (inItem) inLink = true; } return true; }
static bool encodingIsUtf8( const QXmlAttributes& atts ) { for ( int i = 0; i < atts.length(); i++ ) { // utf8="true" is a pre-3.0 syntax if ( atts.qName( i ) == QString( "utf8" ) ) { return ( atts.value( i ) == QString( "true" ) ); } else if ( atts.qName( i ) == QString( "encoding" ) ) { return ( atts.value( i ) == QString( "UTF-8" ) ); } } return FALSE; }
bool TemplateQueryHandler::startElement ( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & qName, const QXmlAttributes & atts ) { //qDebug() << "startElement: " << qName; if(!m_inTripleList && (qName.compare("triple_list")==0 )) { m_inTripleList = true; return true; } if(m_currentTriple) { if(qName.compare("subject") == 0 ) { // no need to check for element type, since subject are always URIs (when received) m_component = ESubject; } else if(qName.compare("predicate") == 0 ) { // no need to check for element type, since predicates are always URIs m_component = EPredicate; } else if(qName.compare("object") == 0 && (atts.length() == 1) && (atts.qName(0).compare("type") == 0)) { //check elementtype for object, bNode is illegal when received. QString attrvalue = atts.value(0); m_component = EObject; if( attrvalue.compare("literal", Qt::CaseInsensitive) == 0) m_elementType = TripleElement::ElementTypeLiteral; else if (attrvalue.compare("URI", Qt::CaseInsensitive) == 0) m_elementType = TripleElement::ElementTypeURI; else { m_errorString = "Invalid object type: "; m_errorString.append(attrvalue); return false; } m_component = EObject; } else { m_errorString = "Invalid element name for a triple: "; m_errorString.append(qName); return false; } } else { if(qName.compare("triple") == 0 ) { m_currentTriple = new Triple(); } else { m_errorString = "starting something other than triple element"; return false; } } return true; }
bool xml_sax_handler_read_devices::startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &attributes) { if (qName == "symbol") { QString devices = attributes.value("devices"); QString fn; if (devices.length() > 0) { QStringList sl_devices = devices.split(";", QString::SkipEmptyParts); for (int i = 0; i < sl_devices.count(); i +=2) { QTreeWidgetItem *child = new QTreeWidgetItem(item); child->setText(0, sl_devices.at(i)); //Nella colonna 1 metto solo il filename senza il percorso fn = sl_devices.at(i+1).section('/',-1); fn = fn.left(fn.length()-4); child->setText(1, fn); //Nella colonna 2 metto tutto, anche il percorso child->setText(2, sl_devices.at(i+1)); all_row->append(child); } } } return TRUE; }
bool HelperXmlHandler_EpubTOC::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts) { // qDebug() << "startElement " << " " << localName; // for ( int i = 0; i < atts.count(); i++ ) // qDebug() << " " << atts.localName(i) << " " << atts.value(i); if ( localName == "navMap" ) { m_inNavMap = true; return true; } if ( !m_inNavMap ) return true; if ( localName == "navPoint" ) m_indent++; if ( localName == "text" ) m_inText = true; if ( localName == "content" ) { int idx = atts.index( "src" ); if ( idx == -1 ) return false; m_lastId = atts.value( idx ); checkNewTocEntry(); } return true; }
bool XMLHandler::startElement(const QString &namespaceURI, const QString & /*localName*/, const QString &qName, const QXmlAttributes &atts) { if(currentNode()->nodeType() == Node::TEXT_NODE) exitText(); DOMString nsURI; if(!namespaceURI.isNull()) nsURI = DOMString(namespaceURI); else // No namespace declared, default to the no namespace nsURI = DOMString(""); ElementImpl *newElement = m_doc->createElementNS(nsURI, qName); if(!newElement) return false; int i; for(i = 0; i < atts.length(); i++) { int exceptioncode = 0; QString uriString = atts.uri(i); QString qnString = atts.qName(i); fixUpNSURI(uriString, qnString); DOMString uri(uriString); DOMString qn(qnString); DOMString val(atts.value(i)); newElement->setAttributeNS(uri, qn, val, exceptioncode); if(exceptioncode) // exception setting attributes return false; } if(newElement->id() == ID_SCRIPT || newElement->id() == makeId(xhtmlNamespace, ID_SCRIPT)) static_cast< HTMLScriptElementImpl * >(newElement)->setCreatedByParser(true); // this is tricky. in general the node doesn't have to attach to the one it's in. as far // as standards go this is wrong, but there's literally thousands of documents where // we see <p><ul>...</ul></p>. the following code is there for those cases. // when we can't attach to the currently holding us node we try to attach to its parent bool attached = false; for(NodeImpl *current = currentNode(); current; current = current->parent()) { attached = current->addChild(newElement); if(attached) break; } if(attached) { if(m_view && !newElement->attached() && !m_doc->hasPendingSheets()) newElement->attach(); pushNode(newElement); return true; } else { delete newElement; return false; } // ### DOM spec states: "if there is no markup inside an element's content, the text is contained in a // single object implementing the Text interface that is the only child of the element."... do we // need to ensure that empty elements always have an empty text child? }
void MemberHandler::startReimplementedBy(const QXmlAttributes& attrib) { MemberReference *mr = new MemberReference; mr->m_memId = attrib.value("refid"); m_reimplementedBy.append(mr); m_curString=""; }
bool XmlParser::getAtt( const QString &name, bool *value, bool required, const QString &elementName, const QXmlAttributes& attribute ) { // Find the attribute name int id; if ( ( id = attribute.index( name ) ) < 0 ) { if ( required ) { m_error = QString( "<%1> element is missing the required " "\"%2=\" attribute." ).arg( elementName ).arg( name ) ; } return( false ); } // Get and return its boolean value QString perm = attribute.value( id ); if ( perm.lower() == "true" ) { *value = true; } else if ( perm.lower() == "false" ) { *value = false; } else { m_error = QString( "<%1 %2=\"%3\" > element must be \"true\" or \"false\"." ) .arg( elementName ).arg( name ).arg( perm ); return( false ); } return( true ); }
bool SAXConfigurationHandler::startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ) { int idx = qName.find ( ':' ); QString prefix = ""; if ( idx > 0 ) { prefix = qName.left ( idx ); } ConfigurationPtr c(new DefaultConfiguration( localName, getLocationString(), namespaceURI, prefix )); // if processing the toplevel item simply push it, otherwise link it // with the parent if( d->configuration.isNull() ) { d->configuration = c; } else { ConfigurationPtr parent = d->elements.top(); parent->addChild( c ); } // process attributes for( int i = 0; i < atts.length(); i ++ ) { c->setAttribute( atts.localName( i ), atts.value( i ) ); } // push currently built configuration to the stack d->elements.push( c ); return true; }
bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*localName*/, const QString& qName, const QXmlAttributes& atts ) { if (m_currentNode->nodeType() == Node::TEXT_NODE) exitText(); ElementImpl *newElement; if (namespaceURI.isNull()) newElement = m_doc->createElement(qName); else newElement = m_doc->createElementNS(namespaceURI,qName); // ### handle exceptions int i; for (i = 0; i < atts.length(); i++) newElement->setAttribute(atts.localName(i),atts.value(i)); if (m_currentNode->addChild(newElement)) { if (m_view) newElement->attach(m_view); m_currentNode = newElement; return TRUE; } else { delete newElement; return FALSE; } }
bool RulesXmlHandler::createConditionNode( const QXmlAttributes & atts ) { if( _rootNode == NULL || _currentNode == NULL ) { return false; } QString typeCondition = atts.value( "type" ); if( QString::compare( typeCondition, "perception", Qt::CaseInsensitive ) == 0 ) { return createConditionPerceptionNode( atts ); } else if( QString::compare( typeCondition, "datamining", Qt::CaseInsensitive ) == 0 ) { return createConditionDataMiningNode( atts ); } else if( QString::compare( typeCondition, "emotion", Qt::CaseInsensitive ) == 0 ) { return createConditionEmotionNode( atts ); } else if( QString::compare( typeCondition, "variable", Qt::CaseInsensitive ) == 0 ) { return createConditionVariableNode( atts ); } else if( QString::compare( typeCondition, "property", Qt::CaseInsensitive ) == 0 ) { return createConditionPropertyNode( atts ); } qDebug() << "[RulesXmlHandler::createConditionNode] Invalid condition node type" << typeCondition; return false; }
void MainHandler::startCompound(const QXmlAttributes& attrib) { m_curCompound = new CompoundEntry(257); m_curCompound->id = attrib.value("refid"); m_compounds.append(m_curCompound); m_compoundDict.insert(m_curCompound->id,m_curCompound); }
bool ClusteringResultOutputHandler::parseClusteringElement(const QXmlAttributes &attributes) { mImpactClusteringElementOpen = true; mImpactClusterElementOpen = false; mParsedInputImageFilenames.clear(); QString segmentationInputTypeStr = attributes.value("segmentationInputType"); if (segmentationInputTypeStr.isEmpty()) { errorStr = QObject::tr("No segmentationInputType specified in clustering element!"); return false; } if (segmentationInputTypeStr.compare("abbyyXML")==0) { mParsedParsingMethod = FINEREADER_XML; } else if (segmentationInputTypeStr.compare("im2CharRectsXML")==0) { mParsedParsingMethod = IM2CHARRECTS_XML; } else if (segmentationInputTypeStr.compare("datFiles")==0) { mParsedParsingMethod = DAT_FILES; // errorStr = QObject::tr("reading clustering element: dat files not supported yet!"); // return false; } else { errorStr = QObject::tr("Unknown segmentationInputType specified in clustering element!"); return false; } return true; }
void GraphHandler::startNode(const QXmlAttributes &attrib) { NodeHandler *n = new NodeHandler(this); n->startNode(attrib); m_nodes.append(n); m_nodeDict->insert(attrib.value("id"),n); }
void SectionHandler::startSection(const QXmlAttributes& attrib) { m_parent->setDelegate(this); m_kindString = attrib.value("kind"); m_kind = s_typeMap->map(m_kindString); debug(2,"section kind=`%s'\n",m_kindString.data()); }
bool TupCommunicationParser::startTag(const QString &tag, const QXmlAttributes &atts) { if (root() == "communication_chat" || root() == "communication_wall") { if (tag == "message") { k->message = atts.value("text"); k->login = atts.value("from"); } } else if (root() == "communication_notice") { if (tag == "notice") { k->login = atts.value("login"); k->state = atts.value("state").toInt(); } } return true; }
QString getType(const QXmlAttributes & attributes) { const int type_idx(indexOf(attributes, "type")); const int named_type_idx(indexOf(attributes, "named-type")); QCString type; if (named_type_idx >= 0) { type = attributes.value(named_type_idx).utf8(); if (type.left(2)!="::") { type = getCurrentScope(attributes.value(named_type_idx).utf8()); } else { type = type.mid(2); } if (m_namedTypeMap.contains(type)) { if (type_idx >= 0) { const QCString dbus_type(attributes.value(type_idx).utf8()); if (dbus_type != m_namedTypeMap[type]) { DOC_ERROR(QString("Type \"%1\" does not match up with " "previous definition of named type \"%2\" (which was \"%3\"."). arg(dbus_type). arg(type). arg(m_namedTypeMap[type])); } } return type; } DOC_ERROR(QString("Undefined named type \"%1\" used.").arg(type)); } if (type_idx >= 0) { type = attributes.value(type_idx).utf8(); QRegExp reg_exp(QCString("(a?[ybnqiuxdtsogv]|a[{]sv[}])")); if (reg_exp.match(type.data())) { return type; } DOC_ERROR(QString("Unnamed complex D-Bus type \"%1\" found.").arg(type)); } return QString(); }