Project

Profile

Help

Bug #4785

closed

fn:path() for parentless element node gives /Q{}foo[1]

Added by Martin Honnen about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XPath Conformance
Sprint/Milestone:
-
Start date:
2020-10-07
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

When I test fn:path on a parentless element node in Saxon-JS 2 and XSLT 3 I get a result like /Q{}foo[1] while Saxon Java gives Q{http://www.w3.org/2005/xpath-functions}root(). I think Saxon-JS 2's result is a bug.

Complete stylesheet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="#all"
  expand-text="yes">
  
  <xsl:param name="doc1">
    <foo/>
    <bar/>
  </xsl:param>
  
  <xsl:param name="elements" as="element()*">
    <foo/>
    <bar/>
  </xsl:param>

  <xsl:output method="html" indent="yes" html-version="5"/>

  <xsl:template name="xsl:initial-template">
    <html>
      <head>
        <title>fn:path test on parentless element nodes</title>
      </head>
      <body>
        <section>
          <h1><code>fn:path</code> of elements in document fragment node</h1>
          <ol>
            <xsl:for-each select="$doc1/*">
              <li>node-name(): {node-name()}; path(): {path()}</li>
            </xsl:for-each>
          </ol>
        </section>
        <section>
          <h1><code>fn:path</code> of parentless elements in element sequence</h1>
          <ol>
            <xsl:for-each select="$elements">
              <li>node-name(): {node-name()}; path(): {path()}</li>
            </xsl:for-each>
          </ol>
        </section>
      </body>
    </html>
    <xsl:comment xmlns:saxon="http://saxon.sf.net/">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
  </xsl:template>

</xsl:stylesheet>
Actions #1

Updated by Michael Kay about 4 years ago

It looks like all the tests for path() applied to trees rooted at an element node have a dependency on XQuery, so they are not applicable to Saxon-JS. I don't think it's possible to construct a parentless element node with XPath alone, so I'll add some tests to the XSLT test suite.

Actions #2

Updated by Michael Kay about 4 years ago

  • Status changed from New to Resolved
  • Applies to JS Branch Trunk added
  • Fix Committed on JS Branch 2.0, Trunk added

I've added a number of tests to the XSLT3 test suite (test set accessor) to evaluate path() on non-document trees.

The Saxon-JS implementation of path() basically was making no attempt to handle this case. I've effectively rewritten it, and it now passes all the tests.

Actions #3

Updated by Community Admin almost 4 years ago

  • Applies to JS Branch 2 added
  • Applies to JS Branch deleted (2.0, Trunk)
Actions #4

Updated by Community Admin almost 4 years ago

  • Fix Committed on JS Branch 2 added
  • Fix Committed on JS Branch deleted (2.0, Trunk)
Actions #5

Updated by Debbie Lockett almost 4 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.1

Bug fix applied in the Saxon-JS 2.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page