Hi Maud - Adding `json:serialize($docs, map { "format": "jsonml", "indent": false() })` seems to drop all of the whitespace and namespaces, too. I'm using v9.6.2 if that helps. It looks like `"indent": true()` is a default for serialization.
``` declare variable $input := <c audience="external" id="Rey17470124" level="item"> <did> <unitdate certainty="high" label="composition" normal="1747-01-24"/> <unitid>Bre 3-2</unitid> <repository> <corpname> <part>Amsterdam, UB, Bibliotheek der Vereeniging tot Bevordering van de Belangen des Boekhandels</part> </corpname> </repository> <didnote/> <physdescstructured coverage="whole" physdescstructuredtype="materialtype"> <quantity>1</quantity> <unittype>feuillet</unittype> </physdescstructured> </did> <relations> <relation href="Polier de Bottens, Georges Nicolas" linktitle="expediteur" relationtype="functionrelation"/> <relation href="Bousquet, Marc Michel" linktitle="destinataire" relationtype="functionrelation"/> <relation href="Lausanne" linktitle="expedition" relationtype="functionrelation"/> <relation href="Genève" linktitle="reception" relationtype="functionrelation"/> </relations> <relatedmaterial> <relatedmaterial localtype="imprime"> <bibref/> </relatedmaterial> <relatedmaterial localtype="edition"> <bibref/> </relatedmaterial> <relatedmaterial localtype="bibliographie"> <bibref/> </relatedmaterial> </relatedmaterial> <scopecontent localtype="Lettre"> <scopecontent localtype="adresse"> <p>oui</p> </scopecontent> <scopecontent localtype="incipit"> <blockquote> <p>Si vous ecrivés aujourdhui ou vendredi</p> </blockquote> </scopecontent> </scopecontent> <odd> <odd localtype="autographe"> <p>oui</p> </odd> <odd localtype="signature"> <p>oui</p> </odd> <odd localtype="contient"> <p>cette lettre a certainement transitée par Bousquet</p> </odd> </odd> </c>; json:serialize($input, map { "format": "jsonml", "indent": false() }) ``` returns: ``` ["c", {"audience":"external", "id":"Rey17470124", "level":"item"},["did",["unitdate", {"certainty":"high", "label":"composition", "normal":"1747-01-24"}],["unitid","Bre 3-2"],["repository",["corpname",["part","Amsterdam, UB, Bibliotheek der Vereeniging tot Bevordering van de Belangen des Boekhandels"]]],["didnote"],["physdescstructured", {"coverage":"whole", "physdescstructuredtype":"materialtype"},["quantity","1"],["unittype","feuillet"]]],["relations",["relation", {"href":"Polier de Bottens, Georges Nicolas", "linktitle":"expediteur", "relationtype":"functionrelation"}],["relation", {"href":"Bousquet, Marc Michel", "linktitle":"destinataire", "relationtype":"functionrelation"}],["relation", {"href":"Lausanne", "linktitle":"expedition", "relationtype":"functionrelation"}],["relation", {"href":"Genève", "linktitle":"reception", "relationtype":"functionrelation"}]],["relatedmaterial",["relatedmaterial", {"localtype":"imprime"},["bibref"]],["relatedmaterial", {"localtype":"edition"},["bibref"]],["relatedmaterial", {"localtype":"bibliographie"},["bibref"]]],["scopecontent", {"localtype":"Lettre"},["scopecontent", {"localtype":"adresse"},["p","oui"]],["scopecontent", {"localtype":"incipit"},["blockquote",["p","Si vous ecrivés aujourdhui ou vendredi"]]]],["odd",["odd", {"localtype":"autographe"},["p","oui"]],["odd", {"localtype":"signature"},["p","oui"]],["odd", {"localtype":"contient"},["p","cette lettre a certainement transitée par Bousquet"]]]] ``` On Wed, Oct 20, 2021 at 11:57 AM Maud Ingarao <maud.inga...@ens-lyon.fr> wrote: > Dear all > > We need to convert some xml data to json to create a nice js visualisation > in our webapp > > The json:serialize works fine, except the fact that it creates empty > strings data due to \n, \s and \t > > We can't find the option(s) to ignore them... And we would like to ignore > the namespace attributes as well. > > Below is an example of the input and output we get with > > let $docs := <ead>{db:open('rey', > 'inventaire-ead.xml')//*:c[.//*:scopecontent[@localtype='Lettre']]}</ead> > return json:serialize($docs, map{ 'format': 'jsonml' }) > > Thanks a lot ! > > Maud > Input > > <c audience="external" id="Rey17470124" level="item"> > <did> > <unitdate certainty="high" label="composition" > normal="1747-01-24"/> > <unitid>Bre 3-2</unitid> > <repository> > <corpname> > <part>Amsterdam, UB, Bibliotheek der Vereeniging tot > Bevordering van de Belangen des Boekhandels</part> > </corpname> > </repository> > <didnote/> > <physdescstructured coverage="whole" > physdescstructuredtype="materialtype"> > <quantity>1</quantity> > <unittype>feuillet</unittype> > </physdescstructured> > </did> > <relations> > <relation href="Polier de Bottens, Georges Nicolas" > linktitle="expediteur" relationtype="functionrelation"/> > <relation href="Bousquet, Marc Michel" > linktitle="destinataire" relationtype="functionrelation"/> > <relation href="Lausanne" linktitle="expedition" > relationtype="functionrelation"/> > <relation href="Genève" linktitle="reception" > relationtype="functionrelation"/> > </relations> > <relatedmaterial> > <relatedmaterial localtype="imprime"> > <bibref/> > </relatedmaterial> > <relatedmaterial localtype="edition"> > <bibref/> > </relatedmaterial> > <relatedmaterial localtype="bibliographie"> > <bibref/> > </relatedmaterial> > </relatedmaterial> > <scopecontent localtype="Lettre"> > <scopecontent localtype="adresse"> > <p>oui</p> > </scopecontent> > <scopecontent localtype="incipit"> > <blockquote> > <p>Si vous ecrivés aujourdhui ou vendredi</p> > </blockquote> > </scopecontent> > </scopecontent> > <odd> > <odd localtype="autographe"> > <p>oui</p> > </odd> > <odd localtype="signature"> > <p>oui</p> > </odd> > <odd localtype="contient"> > <p>cette lettre a certainement transitée par Bousquet</p> > </odd> > </odd> > </c> > Output > > ["c", {"xmlns":"http:\/\/ead3.archivists.org\/schema\/" > <http:%5C/%5C/ead3.archivists.org%5C/schema%5C/>, > "xmlns:xsi":"http:\/\/www.w3.org\/2001\/XMLSchema-instance" > <http:%5C/%5C/www.w3.org%5C/2001%5C/XMLSchema-instance>, > "audience":"external", "id":"Rey17470124", "level":"item"}, > "\n ", > ["did", > "\n ", > ["unitdate", {"certainty":"high", "label":"composition", > "normal":"1747-01-24"}], > "\n ", > ["unitid", > "Bre 3-2"], > "\n ", > ["repository", > "\n ", > ["corpname", > "\n ", > ["part", > "Amsterdam, UB, Bibliotheek der Vereeniging tot Bevordering van > de Belangen des Boekhandels"], > "\n "], > "\n "], > "\n ", > ["didnote"], > "\n ", > ["physdescstructured", {"coverage":"whole", > "physdescstructuredtype":"materialtype"}, > "\n ", > ["quantity", > "1"], > "\n ", > ["unittype", > "feuillet"], > "\n "], > "\n "], > "\n ", > ["relations", > "\n ", > ["relation", {"href":"Polier de Bottens, Georges Nicolas", > "linktitle":"expediteur", "relationtype":"functionrelation"}], > "\n ", > ["relation", {"href":"Bousquet, Marc Michel", > "linktitle":"destinataire", "relationtype":"functionrelation"}], > "\n ", > ["relation", {"href":"Lausanne", "linktitle":"expedition", > "relationtype":"functionrelation"}], > "\n ", > ["relation", {"href":"Genève", "linktitle":"reception", > "relationtype":"functionrelation"}], > "\n "], > "\n ", > ["relatedmaterial", > "\n ", > ["relatedmaterial", {"localtype":"imprime"}, > "\n ", > ["bibref"], > "\n "], > "\n ", > ["relatedmaterial", {"localtype":"edition"}, > "\n ", > ["bibref"], > "\n "], > "\n ", > ["relatedmaterial", {"localtype":"bibliographie"}, > "\n ", > ["bibref"], > "\n "], > "\n "], > "\n ", > ["scopecontent", {"localtype":"Lettre"}, > "\n ", > ["scopecontent", {"localtype":"adresse"}, > "\n ", > ["p", > "oui"], > "\n "], > "\n ", > ["scopecontent", {"localtype":"incipit"}, > "\n ", > ["blockquote", > "\n ", > ["p", > "Si vous ecrivés aujourdhui ou vendredi"], > "\n "], > "\n "], > "\n "], > "\n ", > ["odd", > "\n ", > ["odd", {"localtype":"autographe"}, > "\n ", > ["p", > "oui"], > "\n "], > "\n ", > ["odd", {"localtype":"signature"}, > "\n ", > ["p", > "oui"], > "\n "], > "\n ", > ["odd", {"localtype":"contient"}, > "\n ", > ["p", > "cette lettre a certainement transitée par Bousquet"], > "\n "], > "\n "], > "\n "], > > > -- > > Maud Ingarao > IHRIM - UMR 5317 > Institut d’histoire des représentations et des idées dans les modernités > École Normale Supérieure de Lyon > 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07 > +33 4 37 37 65 79 - maud.inga...@ens-lyon.fr > > *Présente les lundi - mardi - mercredi* > *At the office on mondays - tuesdays - wednesdays* > > http://ihrim.ens-lyon.fr/ > http://ahn.ens-lyon.fr/ > https://cahier.hypotheses.org/ >