Project

Profile

Help

Support #4862

closed

Testing a non-existent root node (likely not a bug, but just checking)

Added by Ken Holman almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-12-22
Due date:
% Done:

0%

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

Description

Hi, all!

I was expecting to pass the XPath address of a root node to exists(), but it appears I cannot. A transcript is below.

Is this a bug, or is there an obligation for Saxon to evaluate the XPath address before testing the node's existence?

No rush on a response ... I've worked around it easily ... but I thought I would report it in case this is an oversight.

Thanks for your thoughts!

Happy holidays to all of you!

. . . . . . Ken

~/t $ cat roottest.xsl 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">

<xsl:template match="/" name="start">
  <xsl:choose>
    <xsl:when test="exists(/)">Root exists&#xa;</xsl:when>
    <xsl:otherwise>Root does not exist&#xa;</xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>
~/t $ saxon9he -xsl:roottest.xsl -s:roottest.xsl 
<?xml version="1.0" encoding="UTF-8"?>Root exists
~/t $ saxon9he -xsl:roottest.xsl -it:start
Error at char 8 in xsl:when/@test on line 7 column 32 of roottest.xsl:
  XPDY0002: Finding root of tree: the context item is absent
Finding root of tree: the context item is absent
~/t $ 



Files

roottest.xsl (345 Bytes) roottest.xsl Ken Holman, 2020-12-22 21:13

Please register to edit this issue

Also available in: Atom PDF