void TinyXMLDocument::processElement(const TiXmlElement* element) { // build attributes block for the element CImagesetXMLAttributes attrs; const TiXmlAttribute *currAttr = element->FirstAttribute(); while (currAttr) { attrs.add(currAttr->Name(), currAttr->Value()); currAttr = currAttr->Next(); } // start element d_handler->elementStart(element->Value(), attrs); // do children const TiXmlElement* childElement = element->FirstChildElement(); while (childElement) { processElement(childElement); childElement = childElement->NextSiblingElement(); } // end element d_handler->elementEnd(element->Value()); }
void ToolImage::processElement(Element *element) { if (element->GetTagName() == "img") { RocketHelper::drawBoxAroundElement(element, Color4b(10, 200, 128, 255)); } for (int child_index=0; child_index < element->GetNumChildren(); ++child_index) { processElement(element->GetChild(child_index)); } }
TinyXMLDocument::TinyXMLDocument(XMLHandler& handler, const String& filename, const String& schemaName, const String& resourceGroup) { d_handler = &handler; // use resource provider to load file data // Fixed using patch from tracker item #000057 // cegui_mk2-0.4.1-fixtinyxml.patch RawDataContainer rawXMLData; System::getSingleton().getResourceProvider()->loadRawDataContainer(filename, rawXMLData, resourceGroup); // Create a buffer with extra bytes for a newline and a terminating null size_t size = rawXMLData.getSize(); char* buf = new char[size + 2]; memcpy(buf, rawXMLData.getDataPtr(), size); // PDT: The addition of the newline is a kludge to resolve an issue // whereby parse returns 0 if the xml file has no newline at the end but // is otherwise well formed. buf[size] = '\n'; buf[size+1] = 0; // Parse the document CEGUI_TINYXML_NAMESPACE::TiXmlDocument doc; if (!doc.Parse((const char*)buf)) { // error detected, cleanup out buffers delete[] buf; System::getSingleton().getResourceProvider()-> unloadRawDataContainer(rawXMLData); // throw exception throw FileIOException("TinyXMLParser: an error occurred while " "parsing the XML document '" + filename + "' - check it for potential errors!."); } const CEGUI_TINYXML_NAMESPACE::TiXmlElement* currElement = doc.RootElement(); if (currElement) { try { // function called recursively to parse xml data processElement(currElement); } catch(...) { delete [] buf; System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData); throw; } } // if (currElement) // Free memory delete [] buf; System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData); }
bool HtmlBookmarksImporter::import(const QString &path) { #ifdef OTTER_ENABLE_QTWEBKIT QFile file(getSuggestedPath(path)); if (!file.open(QIODevice::ReadOnly)) { emit importFinished(BookmarksImport, FailedImport, 0); return false; } if (m_optionsWidget) { if (m_optionsWidget->hasToRemoveExisting()) { removeAllBookmarks(); if (m_optionsWidget->isImportingIntoSubfolder()) { setImportFolder(BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, {{BookmarksModel::TitleRole, m_optionsWidget->getSubfolderName()}})); } } else { setAllowDuplicates(m_optionsWidget->areDuplicatesAllowed()); setImportFolder(m_optionsWidget->getTargetFolder()); } } QWebPage page; page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false); page.mainFrame()->setHtml(file.readAll()); m_totalAmount = page.mainFrame()->findAllElements(QLatin1String("dt, hr")).count(); emit importStarted(BookmarksImport, m_totalAmount); BookmarksManager::getModel()->beginImport(getImportFolder(), page.mainFrame()->findAllElements(QLatin1String("a[href]")).count(), page.mainFrame()->findAllElements(QLatin1String("a[shortcuturl]")).count()); processElement(page.mainFrame()->documentElement().findFirst(QLatin1String("dl"))); BookmarksManager::getModel()->endImport(); emit importFinished(BookmarksImport, SuccessfullImport, m_totalAmount); file.close(); return true; #else return false; #endif }
void XMLProtocolParser::handle(tinyxml2::XMLElement *element) { processElement(element); tinyxml2::XMLElement *curChild = nullptr; tinyxml2::XMLElement *nextSibling = nullptr; curChild = element->FirstChildElement(); nextSibling = element->NextSiblingElement(); if (curChild != nullptr) handle(curChild); if (nextSibling != nullptr) handle(nextSibling); }
void SAXParser::processElement() { Element element; // C.3.3 If the optional component attributes is present, then the bit '1' (presence) is appended to the bit stream; // otherwise, the bit '0' (absence) is appended. bool hasAttributes = checkBit(_b, 2) != 0; // C.3.4 If the optional component namespace-attributes is present, it is encoded as described in the three // following subclauses. // C.3.4.1 The four bits '1110' (presence) and the two bits '00' (padding) are appended to the bit stream. // check for namespace attributes if((_b & Constants::ELEMENT_NAMESPACE_ATTRIBUTES_MASK) == Constants::ELEMENT_NAMESPACE_ATTRIBUTES_FLAG) { throw std::runtime_error("No namespace support yet"); } // C.3.5 The value of the component qualified-name is encoded as described in C.18. getQualifiedNameOrIndex3(element._qualifiedName); if(hasAttributes) processAttributes(); _contentHandler->startElement(_vocab, element, _attributes); _attributes.clear(); while(!_terminated) { _b = static_cast<unsigned char>(_stream->get()); if(!checkBit(_b, 1)) { // 0 padding announcing element processElement(); } else if((_b & Constants::TWO_BITS) == Constants::ELEMENT_CHARACTER_CHUNK) { processCharacterChunk(); } else if (_b == Constants::TERMINATOR_SINGLE || _b == Constants::TERMINATOR_DOUBLE) { _terminated = true; _doubleTerminated = _b == Constants::TERMINATOR_DOUBLE; } else throw std::runtime_error("message.decodingEIIs"); } _contentHandler->endElement(_vocab, element); _terminated = _doubleTerminated; _doubleTerminated = false; }
void SAXParser::processDocument() { _contentHandler->startDocument(); processDocumentProperties(); // Process children while(!_terminated) { _b = static_cast<unsigned char>(_stream->get()); if(!checkBit(_b, 1)) { // 0 padding announcing element processElement(); } } _contentHandler->endDocument(); }
TinyXMLDocument::TinyXMLDocument(CImagesetXMLHandler& handler, const std::string& filename, const std::string& schemaName) { d_handler = &handler; char* pDataBuf = 0; try { // open file FILE* fp = fopen(filename.c_str(), "rb"); if(!fp) { char szException[MAX_PATH] = {0}; _snprintf(szException, MAX_PATH, "TinyXMLDocument:Load file %s error", filename.c_str()); throw std::exception(szException); } fseek(fp, 0, SEEK_END); int nFileSize = ftell(fp); fseek(fp, 0, SEEK_SET); // load file data pDataBuf = new char[nFileSize+1]; memset(pDataBuf, 0, nFileSize+1); fread(pDataBuf, 1, nFileSize, fp); pDataBuf[nFileSize] = 0; fclose(fp); TiXmlDocument doc; doc.Parse((const char*)pDataBuf); const TiXmlElement* currElement = doc.RootElement(); if (currElement) { // function called recursively to parse xml data processElement(currElement); } }catch(...) { delete[] pDataBuf; pDataBuf = 0; throw; } delete[] pDataBuf; pDataBuf = 0; }
TinyXMLDocument::TinyXMLDocument(XMLHandler& handler, const RawDataContainer& source, const String& /*schemaName*/) { d_handler = &handler; // Create a buffer with extra bytes for a newline and a terminating null size_t size = source.getSize(); char* buf = new char[size + 2]; memcpy(buf, source.getDataPtr(), size); // PDT: The addition of the newline is a kludge to resolve an issue // whereby parse returns 0 if the xml file has no newline at the end but // is otherwise well formed. buf[size] = '\n'; buf[size+1] = 0; // Parse the document TiXmlDocument doc; if (!doc.Parse((const char*)buf)) { // error detected, cleanup out buffers delete[] buf; // throw exception throw FileIOException("an error occurred while " "parsing the XML document - check it for potential errors!."); } const TiXmlElement* currElement = doc.RootElement(); if (currElement) { try { // function called recursively to parse xml data processElement(currElement); } catch (...) { delete [] buf; throw; } } // if (currElement) // Free memory delete [] buf; }
QString SourceCodeGenerator::processElement(const QDomNode &element, int level) { QString sp = QString(" ").repeated(level); QJsonObject obj = rule.object().value(element.nodeName()).toObject(); QString tpl = sp+obj.value("template").toString(); for(int i = 0; i < element.attributes().size(); ++i) { if(obj.contains("list")) { QJsonArray list = obj["list"].toArray(); if (list.contains(QJsonValue(element.attributes().item(i).nodeName()))) { QStringList sl = element.attributes().item(i).nodeValue().split(obj["separator"].toString(), QString::SkipEmptyParts); QString prefix = obj["prefix"].toString(); QString suffix = obj["suffix"].toString(); for(int k=0; k < sl.size(); ++k) { QString s = sl[k]; s = prefix + s + suffix; s.replace("%$%", sl[k]); sl[k] = s; } tpl.replace("%"+element.attributes().item(i).nodeName() + "%", sl.join(obj["glue"].toString())); } tpl.replace("%"+element.attributes().item(i).nodeName() + "%", element.attributes().item(i).nodeValue()); } else tpl.replace("%"+element.attributes().item(i).nodeName() + "%", element.attributes().item(i).nodeValue()); } tpl.replace("\n","\n" + sp); tpl.replace("\t", sp); for(int i = 0; i < element.childNodes().size(); ++i) { if (element.childNodes().item(i).nodeName() == "branch") { QDomNode branch = element.childNodes().item(i); QString bt = QString("%branch%1%").arg(i + 1); QStringList body; for(int j = 0; j < branch.childNodes().size(); ++j) { body << processElement(branch.childNodes().item(j), level + 1); } tpl.replace(bt, "\n" + body.join("\n")); } } return tpl; }
//----------------------------------------------------------------------------// void RapidXMLDocument::processElement(const rapidxml::xml_node<>* element) { // build attributes block for the element XMLAttributes attrs; rapidxml::xml_attribute<>* currAttr = element->first_attribute(0); while (currAttr) { attrs.add((utf8*)currAttr->name(), (utf8*)currAttr->value()); currAttr = currAttr->next_attribute(); } // start element d_handler->elementStart((utf8*)element->name(), attrs); // do children rapidxml::xml_node<>* childNode = element->first_node(); while (childNode) { switch (childNode->type()) { case rapidxml::node_element: processElement(childNode); break; case rapidxml::node_data: if (childNode->value() != '\0') d_handler->text((utf8*)childNode->value()); break; // Silently ignore unhandled node type }; childNode = childNode->next_sibling(); } // end element d_handler->elementEnd((utf8*)element->name()); }
bool HtmlBookmarksImporter::import(const QString &path) { #ifdef OTTER_ENABLE_QTWEBKIT QFile file(getSuggestedPath(path)); if (!file.open(QIODevice::ReadOnly)) { return false; } if (m_optionsWidget) { if (m_optionsWidget->hasToRemoveExisting()) { removeAllBookmarks(); if (m_optionsWidget->isImportingIntoSubfolder()) { setImportFolder(BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), m_optionsWidget->getSubfolderName())); } } else { setAllowDuplicates(m_optionsWidget->allowDuplicates()); setImportFolder(m_optionsWidget->getTargetFolder()); } } QWebPage page; page.mainFrame()->setHtml(file.readAll()); processElement(page.mainFrame()->documentElement()); file.close(); return true; #else return false; #endif }
TinyXMLDocument::TinyXMLDocument(XMLHandler& handler, const String& filename, const String& schemaName, const String& resourceGroup) { d_handler = &handler; // use resource provider to load file data // Fixed using patch from tracker item #000057 // cegui_mk2-0.4.1-fixtinyxml.patch RawDataContainer rawXMLData; System::getSingleton().getResourceProvider()->loadRawDataContainer(filename, rawXMLData, resourceGroup); // Create a buffer with the missing extra byte size_t size = rawXMLData.getSize(); char* buf = new char[size + 1]; memcpy(buf, rawXMLData.getDataPtr(), size); buf[size] = 0; try { // Parse the document CEGUITinyXML::TiXmlDocument doc; doc.Parse((const char*)buf); const CEGUITinyXML::TiXmlElement* currElement = doc.RootElement(); if (currElement) { // function called recursively to parse xml data processElement(currElement); } // if (currElement) } catch(...) { delete [] buf; System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData); throw; } // Free memory delete [] buf; System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData); }
void TinyXMLDocument::processElement(const TiXmlElement* element) { // build attributes block for the element XMLAttributes attrs; const TiXmlAttribute *currAttr = element->FirstAttribute(); while (currAttr) { attrs.add((encoded_char*)currAttr->Name(), (encoded_char*)currAttr->Value()); currAttr = currAttr->Next(); } // start element d_handler->elementStart((encoded_char*)element->Value(), attrs); // do children const TiXmlNode* childNode = element->FirstChild(); while (childNode) { switch(childNode->Type()) { case TiXmlNode::CEGUI_TINYXML_ELEMENT: processElement(childNode->ToElement()); break; case TiXmlNode::CEGUI_TINYXML_TEXT: if (childNode->ToText()->Value() != '\0') d_handler->text((encoded_char*)childNode->ToText()->Value()); break; // Silently ignore unhandled node type }; childNode = childNode->NextSibling(); } // end element d_handler->elementEnd((encoded_char*)element->Value()); }
void ToolImage::onRender() { OpenedDocument *document; document = Rockete::getInstance().getCurrentDocument(); if (document) { glLineWidth(2.0f); processElement(document->rocketDocument); if(document->selectedElement) { RocketHelper::drawBoxAroundElement(document->selectedElement, Color4b(10, 200, 240, 255)); } glLineWidth(1.0f); } if (itMustPlaceNewImage) { Vector2f size; size.x = 100; size.y = 100; GraphicSystem::drawBox(futureImagePosition - size * 0.5f, size, Color4b(128, 128, 128, 128)); } }
int SchemaValidatorImpl::processChildren( store::PUL* pul, namespace_context& nsCtx, TypeManager* typeManager, EventSchemaValidator& schemaValidator, store::Iterator_t children, std::vector<store::Item_t>& typedValues, const QueryLoc& loc) { store::Item_t child; store::Item_t typeName; int noOfChildren = 0; while ( children->next(child) ) { noOfChildren++; if ( child->isNode() ) { //cout << " vup - processChildren: " << child->getType()->getLocalName() // ->c_str() << "\n"; cout.flush(); switch ( child->getNodeKind() ) { case store::StoreConsts::elementNode: processElement(pul, typeManager, schemaValidator, child, loc); break; case store::StoreConsts::attributeNode: ZORBA_ASSERT(false); break; case store::StoreConsts::documentNode: ZORBA_ASSERT(false); break; case store::StoreConsts::textNode: { //cout << " vup - pC text: '" << child->getStringValue()-> // normalizeSpace()->str() << "'\n"; cout.flush(); zstring childStringValue; child->getStringValue2(childStringValue); schemaValidator.text(childStringValue); store::Item_t typeQName = schemaValidator.getTypeQName(); processTextValue(pul, typeManager, nsCtx, typeQName, childStringValue, child, typedValues, loc); } break; case store::StoreConsts::piNode: //cout << " vup - pi: " << child->getStringValue() << "\n"; cout.flush(); // do nothing break; case store::StoreConsts::commentNode: //cout << " vup - comment: " << child->getStringValue() << "\n"; cout.flush(); // do nothing break; case store::StoreConsts::anyNode: //cout << " vup - any: " << child->getStringValue() << "\n"; cout.flush(); ZORBA_ASSERT(false); break; default: ZORBA_ASSERT(false); } } } return noOfChildren; }
//----------------------------------------------------------------------------// RapidXMLDocument::RapidXMLDocument(XMLHandler& handler, const String& filename, const String& /*schemaName*/, const String& resourceGroup) { d_handler = &handler; // use resource provider to load file data RawDataContainer rawXMLData; System::getSingleton().getResourceProvider()-> loadRawDataContainer(filename, rawXMLData, resourceGroup); // Create a buffer with extra bytes for a newline and a terminating null size_t size = rawXMLData.getSize(); char* buf = new char[size + 2]; memcpy(buf, rawXMLData.getDataPtr(), size); // PDT: The addition of the newline is a kludge to resolve an issue // whereby parse returns 0 if the xml file has no newline at the end but // is otherwise well formed. buf[size] = '\n'; buf[size + 1] = 0; // Parse the document rapidxml::xml_document<> doc; // character type defaults to char try { doc.parse<0>(buf); // 0 means default parse flags } catch (...) { // error detected, cleanup out buffers delete[] buf; System::getSingleton().getResourceProvider()-> unloadRawDataContainer(rawXMLData); // throw exception throw FileIOException("RapidXMLParser: an error occurred while " "parsing the XML document '" + filename + "' - check it for potential errors!."); } rapidxml::xml_node<>* currElement = doc.first_node(); if (currElement) { try { // function called recursively to parse xml data processElement(currElement); } catch (...) { delete[] buf; System::getSingleton().getResourceProvider()-> unloadRawDataContainer(rawXMLData); throw; } } // Free memory delete[] buf; System::getSingleton().getResourceProvider()-> unloadRawDataContainer(rawXMLData); }
void HtmlBookmarksImporter::processElement(const QWebElement &element) { QWebElement entryElement(element.findFirst(QLatin1String("dt, hr"))); while (!entryElement.isNull()) { if (entryElement.tagName().toLower() == QLatin1String("hr")) { BookmarksManager::addBookmark(BookmarksModel::SeparatorBookmark, {}, getCurrentFolder()); ++m_currentAmount; emit importProgress(BookmarksImport, m_totalAmount, m_currentAmount); } else { BookmarksModel::BookmarkType type(BookmarksModel::UnknownBookmark); QWebElement matchedElement(entryElement.findFirst(QLatin1String("dt > h3"))); if (matchedElement.isNull()) { matchedElement = entryElement.findFirst(QLatin1String("dt > a")); if (!matchedElement.isNull()) { type = (matchedElement.hasAttribute(QLatin1String("FEEDURL")) ? BookmarksModel::FeedBookmark : BookmarksModel::UrlBookmark); } } else { type = BookmarksModel::FolderBookmark; } if (type != BookmarksModel::UnknownBookmark && !matchedElement.isNull()) { QMap<int, QVariant> metaData({{BookmarksModel::TitleRole, matchedElement.toPlainText()}}); const bool isUrlBookmark(type == BookmarksModel::UrlBookmark || BookmarksModel::FeedBookmark); if (isUrlBookmark) { const QUrl url(matchedElement.attribute(QLatin1String("HREF"))); if (!areDuplicatesAllowed() && BookmarksManager::hasBookmark(url)) { entryElement = entryElement.nextSibling(); continue; } metaData[BookmarksModel::UrlRole] = url; } if (matchedElement.hasAttribute(QLatin1String("SHORTCUTURL"))) { const QString keyword(matchedElement.attribute(QLatin1String("SHORTCUTURL"))); if (!keyword.isEmpty() && !BookmarksManager::hasKeyword(keyword)) { metaData[BookmarksModel::KeywordRole] = keyword; } } if (matchedElement.hasAttribute(QLatin1String("ADD_DATE"))) { const QDateTime dateTime(getDateTime(matchedElement, QLatin1String("ADD_DATE"))); if (dateTime.isValid()) { metaData[BookmarksModel::TimeAddedRole] = dateTime; metaData[BookmarksModel::TimeModifiedRole] = dateTime; } } if (matchedElement.hasAttribute(QLatin1String("LAST_MODIFIED"))) { const QDateTime dateTime(getDateTime(matchedElement, QLatin1String("LAST_MODIFIED"))); if (dateTime.isValid()) { metaData[BookmarksModel::TimeModifiedRole] = dateTime; } } if (isUrlBookmark && matchedElement.hasAttribute(QLatin1String("LAST_VISITED"))) { const QDateTime dateTime(getDateTime(matchedElement, QLatin1String("LAST_VISITED"))); if (dateTime.isValid()) { metaData[BookmarksModel::TimeVisitedRole] = dateTime; } } BookmarksModel::Bookmark *bookmark(BookmarksManager::addBookmark(type, metaData, getCurrentFolder())); ++m_currentAmount; emit importProgress(BookmarksImport, m_totalAmount, m_currentAmount); if (type == BookmarksModel::FolderBookmark) { setCurrentFolder(bookmark); processElement(entryElement); } if (entryElement.nextSibling().tagName().toLower() == QLatin1String("dd")) { bookmark->setItemData(entryElement.nextSibling().toPlainText(), BookmarksModel::DescriptionRole); entryElement = entryElement.nextSibling(); } } } entryElement = entryElement.nextSibling(); } goToParent(); }
QString SourceCodeGenerator::applyRule(const QDomDocument &xml) { QDomElement alg = xml.firstChildElement("algorithm"); QString code = processElement(alg, 0); return code; }
void SchemaValidatorImpl::validateAfterUpdate( store::Item* item, zorba::store::PUL* pul, const QueryLoc& loc) { ZORBA_ASSERT(item->isNode()); TypeManager* typeManager = theSctx->get_typemanager(); StaticContextConsts::validation_mode_t mode = theSctx->validation_mode(); if (mode == StaticContextConsts::skip_validation) return; bool isLax = (mode == StaticContextConsts::lax_validation); Schema* schema = typeManager->getSchema(); if ( !schema ) { // no schema available no change to pul return; } EventSchemaValidator schemaValidator = EventSchemaValidator(typeManager, schema->getGrammarPool(), isLax, theLoc); switch ( item->getNodeKind() ) { case store::StoreConsts::documentNode: { //cout << "Validate after update document" << "\n"; cout.flush(); schemaValidator.startDoc(); store::NsBindings bindings; namespace_context nsCtx = namespace_context(theSctx, bindings); std::vector<store::Item_t> typedValues; processChildren(pul, nsCtx, typeManager, schemaValidator, item->getChildren(), typedValues, loc); schemaValidator.endDoc(); //cout << "End Validate after update doc" << "\n"; cout.flush(); return; } case store::StoreConsts::elementNode: { //cout << "Validate after update element" << "\n"; cout.flush(); schemaValidator.startDoc(); processElement(pul, typeManager, schemaValidator, item, loc); schemaValidator.endDoc(); //cout << "End Validate after update elem" << "\n"; cout.flush(); return; } default: throw XQUERY_EXCEPTION( err::XQDY0061, ERROR_PARAMS( ZED( NotDocOrElementNode ) ), ERROR_LOC( theLoc ) ); } }
int XMIResource::processNode(xmlTextReaderPtr reader) { // manage only xcos related XML nodes const xmlChar* nsURI = xmlTextReaderConstNamespaceUri(reader); if (nsURI == xcosNamespaceUri || nsURI == nullptr) { xmlReaderTypes nodeType = (xmlReaderTypes) xmlTextReaderNodeType(reader); switch (nodeType) { case XML_READER_TYPE_NONE: return 1; case XML_READER_TYPE_ELEMENT: return processElement(reader); case XML_READER_TYPE_ATTRIBUTE: sciprint("xmlReader attributes node not supported\n"); return -1; case XML_READER_TYPE_TEXT: return processText(reader); case XML_READER_TYPE_CDATA: return processText(reader); case XML_READER_TYPE_ENTITY_REFERENCE: sciprint("xmlReader entity reference not supported\n"); return -1; case XML_READER_TYPE_ENTITY: sciprint("xmlReader entity not supported\n"); return -1; case XML_READER_TYPE_PROCESSING_INSTRUCTION: sciprint("xmlReader processing instruction not supported\n"); return -1; case XML_READER_TYPE_COMMENT: return 1; case XML_READER_TYPE_DOCUMENT: return 1; case XML_READER_TYPE_DOCUMENT_TYPE: sciprint("xmlReader document type not supported\n"); return -1; case XML_READER_TYPE_DOCUMENT_FRAGMENT: sciprint("xmlReader document fragment not supported\n"); return -1; case XML_READER_TYPE_NOTATION: sciprint("xmlReader notation not supported\n"); return -1; case XML_READER_TYPE_WHITESPACE: sciprint("xmlReader whitespace not supported\n"); return -1; case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: return 1; // ignore indent or end-of-line case XML_READER_TYPE_END_ELEMENT: return processEndElement(reader); case XML_READER_TYPE_END_ENTITY: sciprint("xmlReader end entity not supported\n"); return -1; case XML_READER_TYPE_XML_DECLARATION: sciprint("xmlReader XML declaration not supported\n"); return -1; } } else { // TODO mixed model should be preserved in some way and restored back on XMIResource_save.cpp . } sciprint("unable to process node\n"); return -1; }
void HtmlBookmarksImporter::processElement(const QWebElement &element) { if (element.tagName().toLower() == QLatin1String("h3")) { BookmarksItem *bookmark = BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), element.toPlainText(), getCurrentFolder()); const QString keyword = element.attribute(QLatin1String("SHORTCUTURL")); if (!BookmarksManager::hasKeyword(keyword)) { bookmark->setData(keyword, BookmarksModel::KeywordRole); } if (!element.attribute(QLatin1String("ADD_DATE")).isEmpty()) { const QDateTime time = QDateTime::fromTime_t(element.attribute(QLatin1String("ADD_DATE")).toUInt()); bookmark->setData(time, BookmarksModel::TimeAddedRole); bookmark->setData(time, BookmarksModel::TimeModifiedRole); } setCurrentFolder(bookmark); } else if (element.tagName().toLower() == QLatin1String("a")) { const QUrl url(element.attribute(QLatin1String("href"))); if (!allowDuplicates() && BookmarksManager::hasBookmark(url)) { return; } BookmarksItem *bookmark = BookmarksManager::addBookmark(BookmarksModel::UrlBookmark, url, element.toPlainText(), getCurrentFolder()); const QString keyword = element.attribute(QLatin1String("SHORTCUTURL")); if (!BookmarksManager::hasKeyword(keyword)) { bookmark->setData(keyword, BookmarksModel::KeywordRole); } if (element.parent().nextSibling().tagName().toLower() == QLatin1String("dd")) { bookmark->setData(element.parent().nextSibling().toPlainText(), BookmarksModel::DescriptionRole); } if (!element.attribute(QLatin1String("ADD_DATE")).isEmpty()) { bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("ADD_DATE")).toUInt()), BookmarksModel::TimeAddedRole); } if (!element.attribute(QLatin1String("LAST_MODIFIED")).isEmpty()) { bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("LAST_MODIFIED")).toUInt()), BookmarksModel::TimeModifiedRole); } if (!element.attribute(QLatin1String("LAST_VISITED")).isEmpty()) { bookmark->setData(QDateTime::fromTime_t(element.attribute(QLatin1String("LAST_VISITED")).toUInt()), BookmarksModel::TimeVisitedRole); } } else if (element.tagName().toLower() == QLatin1String("hr")) { BookmarksManager::addBookmark(BookmarksModel::SeparatorBookmark, QUrl(), QString(), getCurrentFolder()); } const QWebElementCollection descendants = element.findAll(QLatin1String("*")); for (int i = 0; i < descendants.count(); ++i) { if (descendants.at(i).parent() == element) { processElement(descendants.at(i)); } } if (element.tagName().toLower() == QLatin1String("dl")) { goToParent(); } }