Should serialize function take "newline" : "\r\n" option in the map parameter into account?

Tuesday, 4 September 2018 · 2 messages · last reply 25 Sep 2018
MH
Martin Honnen4 Sep 2018 11:29 #
When I run contains(serialize("Line 1.
Line 2.
Line 3.", map { "method" : "text", "newline" : "\r\n" }), '
') in BaseX 9.0.2 (from the command line basex.bat or in the GUI) I get the result "false" while I expected "true". Have I not provided the newline option correctly?
CG
Christian Grün25 Sep 2018 09:22 #
Hi Martin, when serializing text via fn:serialize, fn:xml-to-json, csv:serialize or json:serialize, newlines in the output will be normalized to \n. However, the chosen newline value will indeed be output if you define serialization parameters globally…
  (: Variant 1, specific to BaseX :)
  declare option output:newline '\r';
  1,2

  (: Variant 2 :)
  declare option output:item-separator '
';
  1,2
…or if you pass on serialization parameters to a function that serializes data to somewhere else (e.g., with file:write). I guess we should describe the details somewhere in our documentation. Best, Christian
Quoted text · Martin Honnen · 15 lines
On Tue, Sep 4, 2018 at 11:29 AM Martin Honnen <martin.honnen at gmx.de> wrote: > > > When I run > > contains(serialize("Line 1.&#10;Line 2.&#10;Line 3.", map { "method" : > "text", "newline" : "\r\n" }), '&#13;') > > in BaseX 9.0.2 (from the command line basex.bat or in the GUI) I get the > result "false" while I expected "true". > > > Have I not provided the newline option correctly? > >

⚡Generated with XQuery