On Wed, Nov 21, 2012 at 1:25 AM, sini narayanan <[email protected]>wrote:

> Hi MIke,
>
> Now that I have the xml file in my DB, how do I loop through the xml keys
> to get its corresponding values?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <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="1">
>     <map:value xsi:type="xs:string">hello</map:value>
>   </map:entry>
>   <map:entry key="2">
>     <map:value xsi:type="xs:string">world</map:value>
>   </map:entry>
> </map:map>
>
>
You need to first initialize the map from the document, and iterate through
the keys.  map:map() returns an empty map by default! -->

(: david definitely did not test the below at all :)
let $map := map:map(fn:doc("/map.xml")/node())
for $key in map:keys($map)
return
     <store-result key="{ $key }">{  map:get($map, $key)   } </store-result>



> Tried the below code : Which is not returning any value
>
> xquery version "1.0-ml";
>      let $map := map:map()
>     let $value := for $keys in fn:doc("/map.xml")
>                   return map:get($map,"1")
>
>    return
>         <store-result>
>            <value>{$value}</value>
>         </store-result>
>
> Please help.
> Thanks
>
>
> On Tue, Nov 20, 2012 at 7:06 PM, Michael Blakeley <[email protected]>wrote:
>
>> Use document { $map } to get the XML for the map. With that XML you can
>> call xdmp:document-insert, etc.
>>
>> See http://docs.marklogic.com/guide/app-dev/hashtable especially
>> http://docs.marklogic.com/guide/app-dev/hashtable#id_88528
>>
>> -- Mike
>>
>> On 20 Nov 2012, at 09:18 , sini narayanan <[email protected]>
>> wrote:
>>
>> > Hi,
>> >
>> > I have a map to be created as below:
>> >
>> > let $map := map:map()
>> > let $key := map:put($map, "1", "hello")
>> > let $key := map:put($map, "2", "world")
>> > return $map
>> >
>> > How do I store this as a file in MarkLogic DB?
>> > What would be the format in which maps are saved ?
>> >
>> > I want to access this map from an xqy module which would pass the key
>> as input to the map file to get the output.
>> > Please advice.
>> >
>> > Thanks
>> > _______________________________________________
>> > General mailing list
>> > [email protected]
>> > http://developer.marklogic.com/mailman/listinfo/general
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to