Unescaping revritten element name

Friday, 10 April 2020 · 3 messages · last reply 11 Apr 2020
MM
Mauro Mugnaini10 Apr 2020 12:31 #
Hi all, After parsing strings in XML with direct representation (e.g. with CSV and JSON module parsing) the specific entries are represented via elements and their names are rewritten. In particular (as per documentation): "underscores are rewritten to two underscores (__), and characters that are not valid in element names are rewritten to an underscore and the character’s four-digit Unicode.” It is possible to convert back the element’s node name with an XQuery function present in some module? Regards, Mauro
CG
Christian Grün10 Apr 2020 19:51 #
Hi Mauro, It turns out we’ve thought about adding such a function (and another reverse one) to our modules just recently. We’re still wondering how to name the functions, though; suggestions are welcome! The attached script contains implementations of the conversions in XQuery; I hope they are helpful. All the best, Christian
Quoted text · Mauro Mugnaini · 7 lines
> After parsing strings in XML with direct representation (e.g. with CSV and JSON module parsing) the specific entries are represented via elements and their names are rewritten. In particular (as per documentation): "underscores are rewritten to two underscores (__), and characters that are not valid in element names are rewritten to an underscore and the character’s four-digit Unicode.” > > It is possible to convert back the element’s node name with an XQuery function present in some module? > > Regards, > > Mauro
CG
Christian Grün11 Apr 2020 13:23 #
…and a fixed version attached. Thank you to Hans-Jürgen Rennau for pointing me to a bug in my code.
Quoted text · Christian Grün · 24 lines
On Fri, Apr 10, 2020 at 7:51 PM Christian Grün <christian.gruen at gmail.com> wrote: > > Hi Mauro, > > It turns out we’ve thought about adding such a function (and another > reverse one) to our modules just recently. We’re still wondering how > to name the functions, though; suggestions are welcome! > > The attached script contains implementations of the conversions in > XQuery; I hope they are helpful. > > All the best, > Christian > > > > > After parsing strings in XML with direct representation (e.g. with CSV and JSON module parsing) the specific entries are represented via elements and their names are rewritten. In particular (as per documentation): "underscores are rewritten to two underscores (__), and characters that are not valid in element names are rewritten to an underscore and the character’s four-digit Unicode.” > > > > It is possible to convert back the element’s node name with an XQuery function present in some module? > > > > Regards, > > > > Mauro

⚡Generated with XQuery