QXmlQuery issue
-
Hi,
I have an xml file, and I need to convert it into a new xml file applying an xslt transformation.
In my xslt file I have a xsl::choose element, in which are nested several xsl::when elements.
The code I am using for this transformation is very simple:@QXmlQuery qry(QXmlQuery::XSLT20);
qry.setFocus(QUrl("data.xml"));
qry.setQuery(QUrl("transf.xslt"));
QString result = "";
qry.evaluateTo(&result);@I have experienced that if the number of xsl::when elements is greater than 23, I get the following error:
Error XPST0003 in file:///D:/test/debug/transf.xslt, at line 154, column 14: memory exhausted
Else, if I have less than 23 elements, removing randomly some elements, the transformation is applied successfully.
Following is the xml file (data.xml):@<?xml version="1.0" encoding="ISO-8859-1"?>
<RootDoc ConnectionID="1">
<DOC>
<TABLE Name="table1">
<Tr ID="113"/>
<Tr ID="240"/>
</TABLE>
</DOC>
</RootDoc>@and the xslt file (transf.xslt):
@<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/RootDoc">
<Studies>
xsl:choose
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=240]">
<Proc>
<TypeId>1.2.1.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=239]">
<Proc>
<TypeId>1.2.1.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=241]">
<Proc>
<TypeId>1.2.1.3</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=114]">
<Proc>
<TypeId>1.2.2.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=115]">
<Proc>
<TypeId>1.2.2.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=116]">
<Proc>
<TypeId>1.2.2.3</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=9]">
<Proc>
<TypeId>1.2.3.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=29]">
<Proc>
<TypeId>1.2.3.3</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=31]">
<Proc>
<TypeId>1.2.3.5</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=27]">
<Proc>
<TypeId>1.2.3.6</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=24]">
<Proc>
<TypeId>1.2.3.7</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=25]">
<Proc>
<TypeId>1.2.3.8</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=28]">
<Proc>
<TypeId>1.2.3.8</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=30]">
<Proc>
<TypeId>1.2.3.8</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=32]">
<Proc>
<TypeId>1.2.3.8</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=33]">
<Proc>
<TypeId>1.2.3.8</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=227]">
<Proc>
<TypeId>1.3</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=228]">
<Proc>
<TypeId>2.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=83]">
<Proc>
<TypeId>2.5.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=225]">
<Proc>
<TypeId>2.6</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=147]">
<Proc>
<TypeId>3.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=149]">
<Proc>
<TypeId>3.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=153]">
<Proc>
<TypeId>3.3</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=152]">
<Proc>
<TypeId>3.4</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=74]">
<Proc>
<TypeId>3.5</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=148]">
<Proc>
<TypeId>4.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=291]">
<Proc>
<TypeId>5.1</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=232]">
<Proc>
<TypeId>5.2</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=234]">
<Proc>
<TypeId>5.4</TypeId>
</Proc>
</xsl:when>
<xsl:when test="DOC/TABLE[@Name='table1']/Tr[@ID=235]">
<Proc>
<TypeId>5.5</TypeId>
</Proc>
</xsl:when>
</xsl:choose>
</Studies>
</xsl:template>
</xsl:stylesheet>@
I am not able to find out the reason for this memory exhausted related problem.
Using other tools like MS Visual Studio (xslt debugger), or notepad++ (xml plugin) the transformation is successfull with all the elements.
Thanks, Andrea -
In the absence of any answer, I solved the problem completely removing the QtXmlPatterns Module, and using libxslt. With the same xml data and the same xslt sheet, it works correctly.
-
Hello,
My answer won't solve your problem but you could fill a bug report in about that: https://bugreports.qt-project.org
Cheers