Project

Profile

Help

Bug #4366

Returning string of Maps in XQuery failing

Added by O'Neil Delpratt 11 months ago. Updated 11 months ago.

Status:
Resolved
Priority:
Normal
Category:
Saxon-C Internals
Start date:
2019-10-29
Due date:
% Done:

100%

Estimated time:
Found in version:
1.2.1
Fixed in version:

Description

Reported by user in the forum post: https://saxonica.plan.io/boards/4/topics/7645

Due to the lack of support of XdmFunctionItem objects in Saxon/C it should be possible to execute in XQuery to string a map object but this fails.

The following python script supplied by the user we add to our unit tests for investigation purposes:

import saxonc

with saxonc.PySaxonProcessor(license=False) as proc:
    print(proc.version)

    xquery_processor = proc.new_xquery_processor()

    query = """declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'json';

map { 'prop1' : 'value 1', 'prop2' : 'value 2' }"""

    xquery_processor.set_property("!method", "json")

    result = xquery_processor.run_query_to_string(query_text = query)

    print("string result: ", result)

    result = xquery_processor.run_query_to_value(query_text = query)

    print("value result: ", result)

Outputs:

Saxon/C 1.2.1 running with Saxon-HE 9.9.1.5J from Saxonica
string result:  None
value result:  None

The equivalent works fine in XSLT. When returning a value object this should in fact not be possible. An error message should be reported to the user stating that "FunctionItem found. Currently not be handled"


Related issues

Related to Saxon/C - Bug #4365: XdmFunctionItem not supportedNew2019-10-29

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

History

#1 Updated by O'Neil Delpratt 11 months ago

  • Related to Bug #4365: XdmFunctionItem not supported added

#2 Updated by O'Neil Delpratt 11 months ago

  • Status changed from New to In Progress

Update:

After some investigation the query is failing due to the Java API for Saxon/C not handling correctly the output properties supplied by the user. It is actually overwriting it with method=xml. As a workaround the XPath and XSLT APIs should work for serialising maps to string.

#3 Updated by O'Neil Delpratt 11 months ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
  • Found in version set to 1.2.1

Bug fixed in the net.sf.saxon.option.cpp.XQueryEngine class. Fix available in the next maintenance release.

Please register to edit this issue

Also available in: Atom PDF