Project

Profile

Help

Bug #6107

closed

Can't use namespaced attributes on the root element of the body of a SaxonJS http-request

Added by Ben Weaver over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
IXSL extensions
Sprint/Milestone:
-
Start date:
2023-06-29
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 SaxonJS 2.3 / SaxonJ-EE 11.3, we encountered what appears to be a bug in the http-request code.

Trying to make an http-request with an xml body, on which - at root element level - there is a namespaced attribute, e.g.

<xsl:variable name="body">
    <node attrNs:myAttr="hello" xmlns:attrNs="foo" />
</xsl:variable>

The http request that is sent has a body like this, i.e. with the namespace declaration duplicated.

<node attrNs:myAttr="hello" xmlns:attrNs="foo" xmlns:attrNs="foo" />

This seems to occur no matter how the body is constructed, with the namespace declared on it vs only in the stylesheet root; with the prefix in exclude-result-prefixes or not; with the attribute given as a literal, or using xsl:attribute with a namespace attribute, or not, etc. etc.

Namespaced attributes that are not on the root node do not seem to trigger this problem (unfortunately our schema does not permit us to use this workaround).


I was able to make a minimal reproduction using the HelloWorldJS project, simple replacing the click handler and adding a template to catch the response (it doesn't matter that there is no endpoint to receive the request - the malformed payload is visible on the request)

  <xsl:template mode="ixsl:onclick" match="button[@id='pushme']">
    <xsl:variable name="body">
      <node attrNs:myAttr="hello"/>
    </xsl:variable>
    <xsl:variable name="request" as="map(*)">
      <xsl:map>
        <xsl:map-entry key="'href'" select="'http://localhost:9000/test'"/>
        <xsl:map-entry key="'method'" select="'POST'"/> <!-- or PUT, or PATCH... -->
        <xsl:map-entry key="'media-type'" select="'application/xml'"/>
        <xsl:map-entry key="'headers'" select="map{ 'Content-Type': 'application/xml' }"/>
        <xsl:map-entry key="'body'" select="$body"/>
      </xsl:map>
    </xsl:variable>
    <ixsl:schedule-action http-request="$request">
      <xsl:call-template name="debug"/>
    </ixsl:schedule-action>
  </xsl:template>

  <xsl:template name="debug">
    <xsl:result-document href="#button">
      <h2><xsl:value-of select="?status"/></h2>
      <pre><xsl:value-of select="?body"/></pre>
    </xsl:result-document>
  </xsl:template>

Thanks Ben

Please register to edit this issue

Also available in: Atom PDF Tracking page