Support #5136


Greater than symbol getting escaped in HTTP Post body text passed through map

Added by Gary Cornelius 10 months ago. Updated 5 months ago.

Start date:
Due date:
% Done:


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


I am trying to HTTP post some body text that has greater than symbols from Saxon-JS in a web page and I need the symbols to stay as '>' rather than getting escaped to '&gt'. I have tried disabled-output escaping, cdata, un-parsed text, entities, character map and some other things and nothing seems to work. Is this a bug or can you advise a method to get greater than symbols in the text posted from Saxon-JS through the HTTP post map?

My use case is along these lines where I am formatting some query text to be HTTP posted...

<xsl:variable name="body">
<xsl:text>from(bucket: "TEST") 
|> range(start: -15d)
|> filter(fn: (r) =>
  r._measurement == "000000"
    and (r._field == "00001")

And then I want to post in as a scheduled task through a map

<xsl:param name="request" select="map{
  'method': 'POST',
  'href': '',
  'media-type': 'application/vnd.flux',
  'headers': map{
                    'accept': 'application/csv',
                    'content-type': 'application/vnd.flux' 
  'body': serialize($body)

Many thanks in advance for any help or support with this!

Actions #1

Updated by Michael Kay 10 months ago

The spec says that it's implementation-defined whether ">" is (always) escaped as &gt;, and Saxon chooses to escape it. That's certainly not a bug.

I think that it should be possible to avoid the escaping using a character map that maps > to >.

Why do you need to avoid this escaping? Any well-behaved consumer of XML will accept both forms. You say you are posting "query text" but it's not clear what you mean by that. If it's not XML, then you shouldn't be using the XML output method.

Actions #2

Updated by Michael Kay 10 months ago

  • Description updated (diff)
Actions #3

Updated by Gary Cornelius 10 months ago , visible to Gary Cornelius ( from Gary Cornelius

  • Company set to Gary Cornelius
  • Contact person set to Gary Cornelius

Thanks for the help!
I think I had misunderstood about the XML output method being applied to this text inside the scheduled post request. Although the XSLT is producing XML/XHTML to the browser the output method for this text inside the HTTP Post I wanted to be different... I thought this output method was described somehow in the post map by 'media-type': 'application/vnd.flux'
Looks like I will need to either apply a different output method to that part of HTTP post text or use the character map in the way you had described!

Actions #4

Updated by Gary Cornelius 10 months ago , visible to Gary Cornelius ( from Gary Cornelius

Sadly, I remain confused regards how to fill the $body variable below with a text format so things such as greater than symbol > are not escaped. I have tried to change the output method and add a character map as described but it does not appear to apply to the context of the $body in this map (and rather applies on the main document result document which is XHTML). I also have the feeling that the behaviour has changed in the last few years of the serialization in this part of the request map.
<xsl:param name="request" select="map{
  'method': 'POST',
  'href': '',
  'body': $body
It seems like the $body needs to be a document node or serialized in a very particular way but I find it hard to understand what is going on here and  it is not clear to me the right way to set its output method to text only or a apply a character map to this serialized document fragment in this context .

Actions #5

Updated by Michael Kay 10 months ago

I don't think I understand the full picture of what you're trying to do. Why can't you simply do

'body': string($body)


Actions #6

Updated by Gary Cornelius 10 months ago , visible to Gary Cornelius ( from Gary Cornelius

Amazing, this works, you nailed it. So many thanks! 'body': string($body)

This would also explain how I thought it had worked previously too so I really appreciate not having to go back and test with all previous saxon-js versions. I guess I sort of understood this was a completely separate result document being created by XSLT but moving into this context inside a map gets a bit outside my comfort zone and it sort of feels to like I am loosing all the top level xsl controls of documents I know like with xsl:output. xsl:document, xsl:result-document. Also when I googled for saxon-js POST map examples I get lots of very complex examples from Martin-honnen which I followed and all had some serializing or document node creating and were also encoding my database queries in wrong way similar to my code too. 

Actions #7

Updated by Michael Kay 5 months ago

  • Tracker changed from Bug to Support
  • Status changed from New to Closed
  • Assignee set to Michael Kay

The user's problem was apparently resolved; closing the issue now.

Please register to edit this issue

Also available in: Atom PDF Tracking page