Hi Indrajeect,

Your $params variable is an element (the serialization of a map), not a map. 
You can use the map constructor function to convert the XML serialization of a 
map to map:

return map:keys(map:map($params))

Thanks.

-jb

From: Indrajeet Verma 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, April 28, 2015 at 3:05 PM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Error in getting map keys in ML8

Hi,

Could somebody help me what I am missing in below query. I am using this code 
in ML8

let $params := <map:map xmlns:map="http://marklogic.com/xdmp/map";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";>
    <map:entry key="USERSESSION:483d4d2f1a54a7f0eb42f6f1dfa6518c|4/29/2015 
3:41:5 AM">
        <map:value>
            <map:map>
                <map:entry key="user">
                    <map:value>
                        <user-profile 
wk-pid="USR-b740cbc5-5e27-8b1c-d97a-1329625f6b39">
                            <docType>Users</docType>
                            <username type="string"
                                
>USR-b740cbc5-5e27-8b1c-d97a-1329625f6b39</username>
                        </user-profile>
                    </map:value>
                </map:entry>
                <map:entry key="session">
                    <map:value>
                        <session 
wk-pid="483d4d2f1a54a7f0eb42f6f1dfa6518c|4/29/2015 3:41:5 AM">
                            
<username>USR-b740cbc5-5e27-8b1c-d97a-1329625f6b39</username>
                            <created>2015-04-28T23:41:05.172+05:30</created>
                        </session>
                    </map:value>
                </map:entry>
            </map:map>
        </map:value>
    </map:entry>
</map:map>
return map:keys($params)

Error that I am seeing,

[1.0-ml] XDMP-ARGTYPE: (err:XPTY0004) map:keys(<map:map 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:map="http://marklogic.com/xdmp/map";><map:entry 
key="USERSESSION:483d4d2f1a54a7f0eb42f6f1dfa6518c|4/2...</map:map>) -- arg1 is 
not of type map:map

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to