Skip to content

Commit

Permalink
Fixed xerces not being able to read QT temp files on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hr-98 committed Aug 7, 2023
1 parent 4e98b56 commit 53d4095
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libs/ifc/xml/vdomdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,22 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
domParser->setExitOnFirstFatalError(true);
domParser->setErrorHandler(handler);

#ifdef Q_OS_WIN32
QFile patternFile(fileName);
if (patternFile.open(QIODevice::ReadOnly) == false)
{
const QString errorMsg(tr("Can't open schema file %1:\n%2.").arg(schema).arg(fileSchema.errorString()));
throw VException(errorMsg);
}

QTextStream patternIn(&patternFile);
std::string xmlString = patternIn.readAll().toStdString();
xercesc::MemBufInputSource inputBuffer((XMLByte*)xmlString.c_str(), xmlString.size(), "/input.xml");

domParser->parse(inputBuffer);
#else
domParser->parse(xercesc::XMLString::transcode(fileName.toStdString().c_str()));
#endif
if (domParser->getErrorCount() != 0) {
const QString errorMsg(tr("Validation error file %1").arg(fileName));
throw VException(errorMsg);
Expand Down

0 comments on commit 53d4095

Please sign in to comment.