Project

Profile

Help

Bug #5230

closed

Difficulty using xsl:xpath-default-namespace in conjunction with the key attribute of xsl:map-entry

Added by Matthew Boyd almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XSLT Conformance
Sprint/Milestone:
-
Start date:
2022-01-25
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

Using saxon-js and given this input:

<foo:root xmlns:foo='http://www.example.com'>
      <foo:bar>Hello world</foo:bar>
</foo:root>

And this stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xpath-default-namespace="http://www.example.com">

  <xsl:output method="json"/>

  <xsl:template match="/">
    <xsl:map-entry key="'greeting'" select="string(//bar)"/>
  </xsl:template>

</xsl:stylesheet>

I get this output:

{"greeting": "Hello world"}

However, if I attempt to use the same Xpath to select the key instead of the value, as such:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xpath-default-namespace="http://www.example.com">

  <xsl:output method="json"/>

  <xsl:template match="/">
    <xsl:map-entry key="string(//bar)" select="'greeting'"/>
  </xsl:template>

</xsl:stylesheet>

I get an empty string for the key:

{"": "greeting"}

Attempting this same transformation with the saxon processor bundled with oXygen (v 9.9.1.7 at time of writing) produces the output I expect, however:

{"Hello world":"greeting"}

Please register to edit this issue

Also available in: Atom PDF Tracking page