Last active
December 31, 2015 01:59
-
-
Save nine9ths/7918271 to your computer and use it in GitHub Desktop.
In Saxon-EE 9.5.1.2 there seems to be a problem when evaluating predicates with equality tests from a variable that might be a document-node() which has a fallback instruction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet | |
version="2.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:ext="http://example.com/extensions" | |
extension-element-prefixes="ext" | |
exclude-result-prefixes="xs"> | |
<xsl:template match="/"> | |
<xsl:variable name="test" as="document-node(element(foo))?"> | |
<ext:instruction> | |
<!-- If the xsl:fallback here is removed the error clears --> | |
<xsl:fallback/> | |
</ext:instruction> | |
</xsl:variable> | |
<xsl:if test="$test/foo[@bar]"> | |
<xsl:message>This works fine</xsl:message> | |
</xsl:if> | |
<xsl:if test="$test/foo[@bar ne 'baz']"> | |
<xsl:message>This works fine</xsl:message> | |
</xsl:if> | |
<xsl:if test="$test/foo[@bar eq 'baz']"> | |
<xsl:message>This throws "XPTY0020: Leading '/' cannot select the root node of the tree containing the context item: the context item is an atomic value"</xsl:message> | |
</xsl:if> | |
<xsl:if test="$test/foo[@bar = 'baz']"> | |
<xsl:message>This also throws "XPTY0020: Leading '/' cannot select the root node of the tree containing the context item: the context item is an atomic value"</xsl:message> | |
</xsl:if> | |
<!-- This also works fine --> | |
<xsl:variable name="works" as="element()?"> | |
<ext:instruction> | |
<xsl:fallback/> | |
</ext:instruction> | |
</xsl:variable> | |
<xsl:if test="$works[@bar eq 'baz']"> | |
<xsl:message>This works fine</xsl:message> | |
</xsl:if> | |
<!-- This also works fine --> | |
<xsl:variable name="works.too" as="document-node(element(foo))?"> | |
<ext:instruction> | |
<xsl:fallback> | |
<xsl:document> | |
<foo/> | |
</xsl:document> | |
</xsl:fallback> | |
</ext:instruction> | |
</xsl:variable> | |
<xsl:if test="$works.too[@bar eq 'baz']"> | |
<xsl:message>This works fine</xsl:message> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment