void LLXUIParser::readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename, bool silent) { LLFastTimer timer(FTM_PARSE_XUI); mNameStack.clear(); mCurFileName = filename; mCurReadDepth = 0; setParseSilently(silent); if (node.isNull()) { parserWarning("Invalid node"); } else { readXUIImpl(node, std::string(node->getName()->mString), block); } }
bool QEbuMainWindow::doOpen() { // Close before open! if (!doClose()) return false; QString filename = QFileDialog::getOpenFileName(this, tr("Open Metadata File"), QDir::homePath(), tr("XML Files (*.xml)"), 0); if (filename.isEmpty()) { // User pressed "Cancel" return false; } QFile inputFile(filename); if (!inputFile.open(QFile::ReadOnly)) { QMessageBox openWarning(QMessageBox::Warning, tr("QEbu Parser"), tr("Input file cannot be opened"), QMessageBox::Ok, this); openWarning.setDetailedText(inputFile.errorString()); openWarning.exec(); return false; } // Validation QString schema = qApp->applicationDirPath() + "/data/EBU_CORE_20110915.xsd"; Validator validator; if (!validator.validate(filename, schema)) { Validator::ValidatorError error = validator.error(); switch (error) { case Validator::ValidatorNotFound: QMessageBox::warning(this, tr("Validator"), tr("xmllint was not found in the application's PATH," "thus no validation has been performed.\n" "The parsing can bring to unpredictable results.")); break; case Validator::DocumentNotValid: { QMessageBox validatorWarning(this); validatorWarning.setIcon(QMessageBox::Warning); validatorWarning.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); validatorWarning.setWindowTitle(tr("Validator")); validatorWarning.setText(tr("Invalid input file.\n" "Should you choose to ignore this error, " "the parsing can bring to unpredictable results.")); validatorWarning.setDetailedText(validator.validationErrorMessage()); validatorWarning.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore); validatorWarning.setDefaultButton(QMessageBox::Abort); int i = validatorWarning.exec(); if (i != QMessageBox::Ignore) return false; break; } case Validator::DocumentValid: break; case Validator::Unknown: default: { QMessageBox validatorWarning(this); validatorWarning.setIcon(QMessageBox::Warning); validatorWarning.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); validatorWarning.setWindowTitle(tr("Validator")); validatorWarning.setText(tr("Unexpected error from validator")); validatorWarning.setDetailedText(validator.returnMessage()); validatorWarning.setStandardButtons(QMessageBox::Ignore | QMessageBox::Abort); validatorWarning.setDefaultButton(QMessageBox::Abort); int ret = validatorWarning.exec(); if (ret == QMessageBox::Abort) return false; } } } // Parsing EbuParser parser; if (!parser.parseFromFile(inputFile)) { QMessageBox parserWarning(this); parserWarning.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); parserWarning.setIcon(QMessageBox::Warning); parserWarning.setWindowTitle(tr("QEbu Parser")); parserWarning.setText(tr("Invalid input file.")); parserWarning.setDetailedText(parser.errorMsg()); parserWarning.setStandardButtons(QMessageBox::Ok); parserWarning.setDefaultButton(QMessageBox::Ok); parserWarning.exec(); return false; } // All has gone well (we hope). QMessageBox::information(this, tr("QEbu Parser"), tr("Metadata imported successfully.")); if (m_ebuCoreMain) delete m_ebuCoreMain; m_ebuCoreMain = parser.root(); resetView(); // QFileInfo is used to remove the pathname and extract only the true filename. QFileInfo fi(filename); m_currentDocument->setText(tr("%1 opened at %2").arg(fi.fileName()).arg(QTime::currentTime().toString())); return true; }