Thanks for reporting this. I've logged it here:

https://dev.saxonica.com/community/issues/1572

and have committed a patch. Unfortunately I can't suggest an easy circumvention.

I don't know if you constructed the example deliberately, but it just happens that the two keys in your map have the same hashcode as computed by the java.lang.String.hashcode() method, and none of our test cases had any keys with duplicate hash codes.

Michael Kay
Saxonica

On 29/06/2012 13:29, Johann LEGAYE wrote:
Hello everyone,

I am using SaxonEE9-4-0-4J and I try to use maps in a query but I get this error :

java.lang.ClassCastException: equals on StringValue is not allowed
        at net.sf.saxon.value.StringValue.equals(StringValue.java:319)
        at java.util.HashMap.put(Unknown Source)
        at java.util.HashSet.add(Unknown Source)
        at com.saxonica.functions.map.ImmutableMap.keys(ImmutableMap.java:431)
        at com.saxonica.functions.map.ImmutableMap.size(ImmutableMap.java:148)
        at com.saxonica.functions.map.MapSize$1.call(MapSize.java:94)
        at net.sf.saxon.functions.IntegratedFunctionCall.call(IntegratedFunction
Call.java:298)
        at CE_main_1433936385.process(file:/query12_s_test.xqy:65535)
        at com.saxonica.bytecode.CompiledExpression.process(CompiledExpression.j
ava:60)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:414)
        at net.sf.saxon.Query.runQuery(Query.java:860)
        at net.sf.saxon.Query.doQuery(Query.java:376)
        at net.sf.saxon.Query.main(Query.java:97)
Fatal error during query: java.lang.ClassCastException: equals on StringValue is
 not allowed

This is my query :

declare namespace map="http://www.w3.org/2005/xpath-functions/map";

<result>
{
let $test := ( '0P' ,'11')
let $ids := map:new(
   for $item in distinct-values($test)
       return map:entry(string($item),true()) 

return <test>{map:size($ids)}</test>
}
</result>

I don't understand what is wrong in this specific example.

Can someone help me ?

Thank you,

Johann


--
Signature messagerie
Johann LEGAYE
 
 

Johann LEGAYE
Ingénieur Développement 8 avenue Yves Brunaud - 31770 Colomiers Tél : 05.67.20.20.34 - Std : 05.67.20.20.30 - Fax : 05.67.20.20.30
 
 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help