I have prepared an implementation of QAbstractXmlNodeModel class from QtXmlPatterns module which makes it possible to run QXmlQuery-ies on a QDomDocument. I’ve run into problems with QXmlQuery though, because it doesn’t seem to support @Attribute queries either in QXmlQuery::XPath20 or QXmlQuery::XQuery10 mode. I’ve tested it without my custom model and as result got the same dreaded message:
Error XPST0003 in file:///tmp/qdomnodemodel, at line 1, column 13: syntax error, unexpected @, expecting end of file
Has any of the readers experienced similar issues with QXmlQuery? Is this a known limitation of QtXmlPatterns? Other queries seem to be working as expected.
PS. I’m attaching the source code of QDomNodeModel, BSD licensed. I hope QXmlQuery starts working one day 😉
Update 2010/01/08: Yay! It actually works. Qt requires expressions like this: /root/element/@attr instead of /root/element@attr to get attributes. I was under the impression that the latter was correct XPath but it turns out that I was wrong.