The xmlpatterns module gets removed in Qt6 and how can I rewrite the code below:
We use QXmlQuery and SchemaMessageHandler, m_queryContent is an xquery file use variable defined in nuiBuffer and metadataBuffer:
QXmlQuery query;
SchemaMessageHandler messageHandler;
query.setMessageHandler(&messageHandler);
//Bind the content of the NUI to an XQuery var.This way we can reference
//the nui from within our query
QBuffer nuiBuffer;
nuiBuffer.setData(m_nuiContent.toUtf8());
nuiBuffer.open(QIODevice::ReadOnly | QIODevice::Text);
query.bindVariable(XVAR_NUI, &nuiBuffer );
//Bind the content of DevtoolsMetadata to an XQuery var.
QBuffer metadataBuffer;
metadataBuffer.setData(metadataContent.toUtf8());
metadataBuffer.open(QIODevice::ReadOnly | QIODevice::Text);
query.bindVariable(XVAR_METADATA, &metadataBuffer);
//Set the query
query.setQuery(m_queryContent);
QBuffer resultBuffer;
//metadataBuffer.setData(metadataContent.toUtf8());
resultBuffer.open(QIODevice::WriteOnly | QIODevice::Text);
Then we use QXmlFormatter format the xml string:
//We need to maintain the same format with uiDesigner
QXmlFormatter formatter(query, &resultBuffer);
formatter.setIndentationDepth(FORMAT_INDENTATION_DEPTH);
//qDebug() << "XQuery Expression: " << m_queryContent ;
if (!query.isValid()){
qCritical() << QString("Invalid query. Error at line %1, column %2").arg(
messageHandler.line()).arg(messageHandler.column());
qCritical() << messageHandler.statusMessage();
return false;
}
if (!query.evaluateTo(&formatter)){
qWarning() << QString("Runtime query error at line %1, column %2").arg(
messageHandler.line()).arg(messageHandler.column());
qWarning() << messageHandler.statusMessage();
return false;
}
m_queryResult = QString::fromLocal8Bit(resultBuffer.data());
Need to find a way to replace QXmlQuery and QXmlFormatter