Here you can find sources of a simple Qt 4.8 application that takes XML input and can do the following:
- check its validity according to given XML Schema
- make an XSLT transformation on it
- check validity of XSLT transformation output according to given XML Schema
The purpose of this simple application was to test how much of XML Schema and XSLT functionalities were implemented in Qt 4.8 and to help in debugging XML Schema and XSLT taking into account how much of it is supported. The result was that XML Schema 1.0 is supported pretty well, but XSLT isn’t implemented well enough for production neither in XSLT 1.0 nor XSLT 2.0 standard.
As stated here, Qt 4.8 implements XML Schema 1.0. One can read here that Qt 4.8 has only experimental support of XSLT 2.0. There’s also a list of unsupported features over there. Here are some things I found out:
- for-each-group doesn’t really work.
- for-each doesn’t work on a sequence of atomic types. For example, you can’t do that:
<xsl:for-each select="distinct-values(/lib:record/lib:name)">
The trick I used to bypass it in this case was simply by getting those values as nodes:
<xsl:for-each select="for $n in distinct-values(/lib:record/lib:name) return /lib:record[lib:name=$n][1]/lib:name">
- Sequence of nodes can’t be passed in xsl:call-template parameters. To bypass that, I simply passed some atomic type that would identify the sequence and recreated it in the called template.
- xsl:key doesn’t work (as stated in the documentation).
Generally, lack of support of many features can be bypassed without increasing the problem complexity by using weird tricks. As in example above, it’s always better to iterate over distinct-values (XSLT 2.0) and take them as nodes from the file instead of using dreadful square-time constructions like not(preceding-simbling::…) (which probably would be the case for XSLT 1.0 without xsl:key support). Though, I wouldn’t recommend using Qt 4.8 XSLT in real production unless the XSLT is really simple.