Project

Profile

Help

Bug #4630

Elements not matched when using `match="foo[. is key('some-key', value)[1]]"` if elements are in a namespace and xpath-default-namespace is used

Added by Martin Honnen about 1 month ago. Updated 18 days ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
XSLT Conformance
Sprint/Milestone:
-
Start date:
2020-07-03
Due date:
% Done:

0%

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

Description

When trying to eliminate duplicates using the "modernized" XSLT 2/3 version of Muenchian grouping with e.g.

    <xsl:template match="foo[. is key('foo-group', key)[1]]">
        <xsl:copy>
            <xsl:apply-templates select="*, (key('foo-group', key) => tail())/(* except key)"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="foo[not(. is key('foo-group', key)[1])]"/>

Saxon-JS 2 fails to match any foo and doesn't output any of them if the input elements are in a namespace and the stylesheet uses xpath-default-namespace for that namespace.

Sample stylesheet is

<?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"
    xpath-default-namespace="http://example.com/ns1"
    exclude-result-prefixes="#all"
    expand-text="yes">
    
    <xsl:mode on-no-match="shallow-copy"/>
    
    <xsl:strip-space elements="*"/>
    <xsl:output indent="yes"/>
    
    <xsl:key name="foo-group" match="foo" use="key"/>
    
    <xsl:template match="foo[. is key('foo-group', key)[1]]">
        <xsl:copy>
            <xsl:apply-templates select="*, (key('foo-group', key) => tail())/(* except key)"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="foo[not(. is key('foo-group', key)[1])]"/>
    
</xsl:stylesheet>

Input is:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://example.com/ns1">
    <data>
        <header>
            <name>header 1</name>
        </header>
        <foo>
            <key>a</key>
            <data>data 1</data>
            <message>message 1</message>
        </foo>
        <foo>
            <key>a</key>
            <data>data 2</data>
            <message>message 2</message>
        </foo>
    </data>
</root>

Result with xslt3 from the command line:

PS C:\SomePath\saxon-js-2\is-operator-and-key-with-namespace> xslt3 -t -s:.\input-sample-with-ns2.xml -xsl:.\eliminate-duplicates-with-key2.xsl
Saxon-JS 2.0 from Saxonica
Node.js version v12.18.0
Compiling stylesheet C:\SomePatg\saxon-js-2\is-operator-and-key-with-namespace\eliminate-duplicates-with-key2.xsl
Stylesheet compilation time: 0.142s
SEF generated by Saxon-JS 2.0 at 2020-07-03T14:38:26.465+02:00 with -target:JS -relocate:true
<?xml version="1.0" encoding="UTF-8"?>

<root xmlns="http://example.com/ns1">
   <data>
      <header>
         <name>header 1</name>
      </header>
   </data>
</root>

Output with Saxon Java:

<root xmlns="http://example.com/ns1">
   <data>
      <header>
         <name>header 1</name>
      </header>
      <foo>
         <key>a</key>
         <data>data 1</data>
         <message>message 1</message>
         <data>data 2</data>
         <message>message 2</message>
      </foo>
   </data>
</root>
eliminate-duplicates-with-key2.xsl (778 Bytes) eliminate-duplicates-with-key2.xsl Martin Honnen, 2020-07-03 14:43
input-sample-with-ns2.xml (431 Bytes) input-sample-with-ns2.xml Martin Honnen, 2020-07-03 14:43

Related issues

Is duplicate of Saxon-JS - Bug #4624: Matching with namespaces in SaxonJS / NodeJSResolved2020-06-29

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by Martin Honnen about 1 month ago

Might be a duplicate of https://saxonica.plan.io/issues/4624 I see now.

#2 Updated by Michael Kay about 1 month ago

Yes, closing as a duplicate.

#3 Updated by Debbie Lockett 18 days ago

  • Is duplicate of Bug #4624: Matching with namespaces in SaxonJS / NodeJS added

#4 Updated by Debbie Lockett 18 days ago

  • Status changed from New to Duplicate

Please register to edit this issue

Also available in: Atom PDF Tracking page