map-entries sequence
Tuesday, 2 March 2021 · 2 messages
RS
Rob Stapper2 Mar 2021 10:35 #
Hi Christian,
In my casus I’m exporting and importing xQuery maps where the export-format is a xQuery-file or a json-file. Hereby the sequence of the exported map-entries is important: I want the sequence in which the entries are generated to stay in tact when exporting. I can’t get this working.
My current work-around is to place the map-entries in an array. It does the trick but it feels redundant. Is there a way to have this kind of control over map-entry sequence?
Thnx in advance,
Rob Stapper
Sent from Mail for Windows 10
--
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
CG
Christian Grün2 Mar 2021 11:14 #
Hi Rob,
Maps in XQuery have been defined to be unordered. Using sequences (or arrays) of maps is one way to preserve order. You could also have a look at Leo’s awesome data structures written in XQuery (look for ordered-map.xqm):
https://github.com/LeoWoerteler/xq-modules
Cheers,
Christian
Quoted text · Rob Stapper · 35 lines
On Tue, Mar 2, 2021 at 10:35 AM Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Hi Christian, > > > > In my casus I’m exporting and importing xQuery maps where the > export-format is a xQuery-file or a json-file. Hereby the sequence of the > exported map-entries is important: I want the sequence in which the entries > are generated to stay in tact when exporting. I can’t get this working. > > > > My current work-around is to place the map-entries in an array. It does > the trick but it feels redundant. > > Is there a way to have this kind of control over map-entry sequence? > > > > Thnx in advance, > > Rob Stapper > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for > Windows 10 > > > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon> Virus-free. > www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link> > <#m_7134064962127962653_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery