Actions
Bug #4659
closedCannot convert value class net.sf.saxon.ma.map.HashTrieMap of type map(xs:string, xs:string) to class java.util.Map
Start date:
2020-07-30
Due date:
% Done:
0%
Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Description
Hello,
We are hitting an issue with Saxon PE 9.7.0-21 where java code is invoked from XQuery and gets passed a HashTrieMap where a regular Map was expected.
Here is code to reproduce this:
package org.talend.transform.xquery.test;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.Serializer;
import net.sf.saxon.s9api.XQueryCompiler;
import net.sf.saxon.s9api.XQueryEvaluator;
import net.sf.saxon.s9api.XQueryExecutable;
public class Tdm8225Test {
@Test
public void t() throws Exception {
String script = "xquery version \"1.0\";\n" +
"declare namespace tdm8225Test = \"java:org.talend.transform.xquery.test.Tdm8225Test\";\n" +
"\n" +
"let $xml := <rootElement>\n" +
" <elementA>a</elementA>\n" +
" <elementA>b</elementA>\n" +
" <elementA>b</elementA>\n" +
" <elementA>b</elementA>\n" +
" <elementA>a</elementA>\n" +
" <elementA>c</elementA>\n" +
" <elementA>c</elementA>\n" +
" <elementA>c</elementA>\n" +
" <elementA>c</elementA>\n" +
" <elementA>c</elementA>\n" +
"</rootElement>\n" +
"\n" +
"return for $key in $xml/elementA\n" +
" return tdm8225Test:getValue(tdm8225Test:getMap(), $key)";
Processor proc = new Processor(true);
ActivateSaxon.activate(proc);
XQueryCompiler comp = proc.newXQueryCompiler();
XQueryExecutable exp = comp.compile(script);
Serializer out = proc.newSerializer();
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
out.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
out.setOutputStream(System.out);
XQueryEvaluator eval = exp.load();
eval.run(out);
}
public static Map<String, String> getMap() {
Map<String, String> myMap = new HashMap<>();
myMap.put("City","Bonn");
return myMap;
}
public static String getValue(Map<String, String> map, String key) {
return map.get(key);
}
}
Please register to edit this issue
Actions