Markus -

Another confession: I've never been very good at puzzles and riddles :(
so...

On Wed, Apr 6, 2022 at 10:34 AM Markus Elfring <markus.elfr...@web.de>
wrote:

> > > Test result:
> > > T3|T4
> > > "line 1
> > > line 2?"|line 3\nline 4?
> > >
> > >
> > > Will any more clarification help here?
> >
> > …, but if you're asking "Why are there double quotes around my `T3`
> field?",
>
> Partly, yes.
> (But not really.)
>
> That's certainly a cryptic response! :)


>
> > then the answer appears to be in the CSV specification[1].
>
> Which impressions did you get from the other BaseX information sources
> which I pointed out?
>
> My impressions with the BaseX documentation, generally speaking, are very
positive, and when I have questions (or need clarification, or help, etc),
my impressions of the community here are even more positive: what a
welcoming and generous group of people. I'm lucky to participate.


> > So, the behavior you're seeing in your sample script matches the CSV RFC.
>
> What is your opinion for the data processing of the fields “T1”, “T2” and
> “T4”?
>

Wrapping up the other examples you've shared in this mail thread, along
with some changes:
e.g.
```
xquery version "3.1";
declare option output:method "csv";
declare option output:csv "header=yes,quotes=yes,separator=|";
declare variable $input :=
<test_data>
  <row>
    <ID>01</ID>
    <T1>X Y</T1>
    <T2>Y, X</T2>
    <T3>line 4
    or a line break in the T3 field.</T3>
    <T4>line 6\nor something - maybe this is line 7? It might not be: what
interprets the '\n' character? BaseX? Something else? Maybe we want the {
string-join(('&amp;','#','10',';','')) } character (linefeed literal)?</T4>
  </row>
  <row>
    <ID>02</ID>
    <T1>A 2nd row</T1>
  </row>
</test_data>;

<csv>
  {
    for $row in $input//row
    return (
      <record>
        {
          for $field in $row/child::*
          return (
            $field
          )
        }
      </record>
    )
  }
</csv>
```

Provides the results that I would expect:
```
ID|T1|T2|T3|T4
01|X Y|Y, X|"line 4
    or a line break in the T3 field."|line 6\nor something - maybe this is
line 7? It might not be: what interprets the '\n' character? BaseX?
Something else? Maybe we want the &#10; character (linefeed literal)?
02|A 2nd row|||
```
My opinion of these results is that they are correct - they meet my
expectations. Do you feel like these results are missing something? If so,
what specifically?
Is there something in the documentation that could change to make things
more explicit or provide better clarity?


>
> Regards,
> Markus
>

Best,
Bridger

Reply via email to