项目里要用到
XML模板,在网上找XSLT资料的时候,nokia官网上的例子里有XQ文件 myquery.xq 这是什么
格式的
文件啊? 在网上没找到呢
QFile xq("");
QString fileName("the filename");
QString publisherName("the publisher");
qlonglong year = 1234;
QXmlQuery query;
query.bindVariable("file",
QVariant(fileName));
query.bindVariable("publisher",
QVariant(publisherName));
query.bindVariable("year",
QVariant(year));
query.setQuery(&xq,
QUrl::fromLocalFile(xq.fileName()));
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem item(result.next());
while (!item.isNull()) {
if (item.isAtomicValue()) {
QVariant v = item.toAtomicValue();
switch (v.type()) {
case
QVariant::LongLong:
// xs:integer
break;
case
QVariant::String:
// xs:string
break;
default:
// error
break;
}
}
else if (item.isNode()) {
QXmlNodeModelIndex i = item.toNodeModelIndex();
// process node
}
item = result.next();
}