Project

Profile

Help

Bug #3840

closed

Migrating from sourceforge saxon to Saxonica Saxon-EE, problem with sorting xslt

Added by Rick Vlaming almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2018-07-14
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:

Description

We are switching from sourceforge saxon 9.1.0.8 to saxonica saxon-ee 9.8.0.12. We are having trouble with a xslt which task is to translate to a sorted xml. The same xslt, which we used against the sourceforge saxon, is given an error using against the saxon-ee parser. There is no output.

We are developing using XML-Spy where we set saxon-ee as the external XSL transformation program to use via the following setting: java -jar C:\rick\xslt\saxon-ee-9.8.0.12.jar -s:%1 -o:%2 -xsl:%3

The error says: Error at char 9 in xsl:apply-templates/@select on line 17 column 44 of postXslt.xslt: Cannot evaluate net.sf.saxon.expr.sort.SortKeyDefinition in built-in template rule for /Products in the unnamed mode Cannot evaluate net.sf.saxon.expr.sort.SortKeyDefinition

The original XSLT, which works fine with sourceforge saxon, is:

<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns="http://xml.XXXX.nl/schemas/XXXX/2017/01"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="no"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/*">
		<xsl:copy>
			<xsl:apply-templates select="ns:person">
				<xsl:sort select="ns:personTypeA/ns:idA"/>
				<xsl:sort select="ns:personTypeB/ns:idB"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:participation">
				<xsl:sort select="ns:notificationId"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field1"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field2"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field3"/>
				<xsl:sort select="ns:participant/ns:participantTypeB/ns:field4"/>
				<xsl:sort select="ns:participant/ns:participantTypeB/ns:field5"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:notification">
				<xsl:sort select="ns:notificationId"/>
			</xsl:apply-templates>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>

via deduction the problem is within de select of participation. Because when this select is omitted then the transformation works (offcourse without the participation part)

Translation of the following XML with the following XSLT gives the following output:

<Products xmlns="http://xml.XXXX.nl/schemas/XXXX/2017/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://xml.XXXX.nl/schemas/XXXX/2017/01 file://pc.XXXX.nl/Homes/Usr/XXXX/Mijn%20Documenten/Desktop/xml/XXXX/Products.xsd">
	<person>
		<personTypeB>
			<idB>4455667</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455669</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455671</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeA>
			<idA>10001109</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001111</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001110</idA>
		</personTypeA>
	</person>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1960-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeB>
				<field4>8050901</field4>
				<field5>The Blues Company</field5>
			</participantTypeB>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1950-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<notification>
		<notificationId>1111222214</notificationId>
	</notification>
	<notification>
		<notificationId>1111222213</notificationId>
	</notification>
</Products>
<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns="http://xml.XXXX.nl/schemas/XXXX/2017/01"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="no"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/*">
		<xsl:copy>
			<xsl:apply-templates select="ns:person">
				<xsl:sort select="ns:personTypeA/ns:idA"/>
				<xsl:sort select="ns:personTypeB/ns:idB"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:notification">
				<xsl:sort select="ns:notificationId"/>
			</xsl:apply-templates>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<Products xmlns="http://xml.XXXX.nl/schemas/XXXX/2017/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<person>
		<personTypeB>
			<idB>4455667</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455669</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455671</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeA>
			<idA>10001109</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001110</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001111</idA>
		</personTypeA>
	</person>
	<notification>
		<notificationId>1111222213</notificationId>
	</notification>
	<notification>
		<notificationId>1111222214</notificationId>
	</notification>
</Products>

When only the participation with only sort on notificationId is added then the same error arises again. That's the following XSLT:

<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns="http://xml.XXXX.nl/schemas/XXXX/2017/01"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="no"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/*">
		<xsl:copy>
			<xsl:apply-templates select="ns:person">
				<xsl:sort select="ns:personTypeA/ns:idA"/>
				<xsl:sort select="ns:personTypeB/ns:idB"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:participation">
				<xsl:sort select="ns:notificationId"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:notification">
				<xsl:sort select="ns:notificationId"/>
			</xsl:apply-templates>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>

A collegue found out that it looks like trouble arises because of a sort notificationId within two different selects. When on one of them a data-type is specified the xslt is working again. Ofcours not the sort we want in the final version.

<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns="http://xml.XXXX.nl/schemas/XXXX/2017/01"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="no"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/*">
		<xsl:copy>
			<xsl:apply-templates select="ns:person">
				<xsl:sort select="ns:personTypeA/ns:idA"/>
				<xsl:sort select="ns:personTypeB/ns:idB"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:participation">
				<xsl:sort select="ns:notificationId" data-type="text"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:notification">
				<xsl:sort select="ns:notificationId"/>
			</xsl:apply-templates>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<Products xmlns="http://xml.XXXX.nl/schemas/XXXX/2017/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<person>
		<personTypeB>
			<idB>4455667</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455669</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455671</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeA>
			<idA>10001109</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001110</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001111</idA>
		</personTypeA>
	</person>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1960-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeB>
				<field4>8050901</field4>
				<field5>The Blues Company</field5>
			</participantTypeB>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1950-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<notification>
		<notificationId>1111222213</notificationId>
	</notification>
	<notification>
		<notificationId>1111222214</notificationId>
	</notification>
</Products>

Then added the other sorts into the participation select and the translation works. BUT.... with this small xml it does. When I used a much bigger xml to translate the error arises again.... Very strange..

<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ns="http://xml.XXXX.nl/schemas/XXXX/2017/01"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" encoding="UTF-8" indent="no" omit-xml-declaration="no"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/*">
		<xsl:copy>
			<xsl:apply-templates select="ns:person">
				<xsl:sort select="ns:personTypeA/ns:idA"/>
				<xsl:sort select="ns:personTypeB/ns:idB"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:participation">
				<xsl:sort select="ns:notificationId"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field1"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field2"/>
				<xsl:sort select="ns:participant/ns:participantTypeA/ns:field3"/>
				<xsl:sort select="ns:participant/ns:participantTypeB/ns:field4"/>
				<xsl:sort select="ns:participant/ns:participantTypeB/ns:field5"/>
			</xsl:apply-templates>
			<xsl:apply-templates select="ns:notification">
				<xsl:sort select="ns:notificationId" data-type="text"/>
			</xsl:apply-templates>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<Products xmlns="http://xml.XXXX.nl/schemas/XXXX/2017/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<person>
		<personTypeB>
			<idB>4455667</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455669</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeB>
			<idB>4455671</idB>
		</personTypeB>
	</person>
	<person>
		<personTypeA>
			<idA>10001109</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001110</idA>
		</personTypeA>
	</person>
	<person>
		<personTypeA>
			<idA>10001111</idA>
		</personTypeA>
	</person>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeB>
				<field4>8050901</field4>
				<field5>The Blues Company</field5>
			</participantTypeB>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1950-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<participation>
		<notificationId>123</notificationId>
		<participant>
			<participantTypeA>
				<field1>10001110</field1>
				<field2>Hetfield</field2>
				<field3>1960-10-01</field3>
			</participantTypeA>
		</participant>
	</participation>
	<notification>
		<notificationId>1111222213</notificationId>
	</notification>
	<notification>
		<notificationId>1111222214</notificationId>
	</notification>
</Products>

Please register to edit this issue

Also available in: Atom PDF