Question

The Qt Documentation states that for-each-group is supported when using QXmlQuery. However I get an error when I try and use it:

"The element with local name for-each-group does not exist in XSL-T."

Am I missing something?

I am using Qt 4.8.4. I am calling QXmlQuery like this:

QXmlQuery xmlQuery(QXmlQuery::XSLT20);
xmlQuery.setMessageHandler(&messageHandler);
xmlQuery.setFocus(&xmlBuffer);
xmlQuery.setQuery(&queryFile);

The line from my XSL file looks like this:

<xsl:for-each-group select="../readings/slot" group-by="@slot_dtm">

Thanks.

No correct solution

OTHER TIPS

As of Qt 5.12, this issue is still present. It seems that Qt simply does not support xsl:for-each-group. That was also the result of a 2013 blog post where somebody analyzed this issue.

There are some limited ways to achieve the same functionality without xsl:for-each-group, see here. But this did not work for me due to a bug in Qt's XSLT variable binding. Finally I resorted to avoid even a xsl:for-each loop because the order and identity of the groups was known initially. See my code.

tl;dr: Unfortunately Qt XSLT is barely useful as of Qt 5.12; like they say, the implementation is "experimental". And it seems there was very little work done on it since 2013.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top