Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change csv-to-xml() to produce an XHTML table #1017

Closed
michaelhkay opened this issue Feb 11, 2024 · 4 comments
Closed

Change csv-to-xml() to produce an XHTML table #1017

michaelhkay opened this issue Feb 11, 2024 · 4 comments
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. Propose Closing with No Action The WG should consider closing this issue with no action XQFO An issue related to Functions and Operators

Comments

@michaelhkay
Copy link
Contributor

michaelhkay commented Feb 11, 2024

I propose (a) renaming csv-to-xml as csv-to-table, and (b) changing the output to be an XHTML table. Specifically, instead of outputting

<csv xmlns="http://www.w3.org/2005/xpath-functions">
   <columns>
      <column>name</column>
      <column>city</column>
   </columns>
   <rows>
      <row>
         <field column="name">Bob</field>
         <field column="city">Berlin</field>
      </row>
      <row>
         <field column="name">Alice</field>
         <field column="city">Aachen</field>
      </row>
   </rows>
</csv>

it should output:

<table xmlns="http://www.w3.org/1999/xhtml">
   <thead>
      <tr>
          <th>name</th>
          <th>city</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td title="name">Bob</td>
         <td title="city">Berlin</td>
      </tr>
      <tr>
         <td title="name">Alice</td>
         <td title="city">Aachen</td>
      </tr>
   </thead>
</table>

Benefits:

(a) the data is just as easy to manipulate or transform as the current output
(b) it can be copied directly into HTML transformation output if required
(c) it is familiar to users
(d) we don't have to write, test, and document a schema
(e) there may well be libraries that can perform further transformations on the structure, for example conversion to other table representations, extraction to spreadsheet formats, etc.

@ndw
Copy link
Contributor

ndw commented Feb 11, 2024

This seems like a very user-friendly change. But I think we should try to produce tables that meet accessibility guidelines. That means scope attributes on column headers and (where rows have headers) row headers.

I'm not sure about that use of title. I think that level of cross-reference would be done with IDs and header attributes in a more accessible table. But generating IDs is fraught with peril.

@ChristianGruen ChristianGruen added XQFO An issue related to Functions and Operators Editorial Minor typos, wording clarifications, example fixes, etc. labels Feb 11, 2024
@ChristianGruen
Copy link
Contributor

I’m not that convinced. Aren’t there much more use cases for processing XML than “just producing HTML”? Would it have been a good idea to introduce an fn:json-to-html function? Some more concerns:

  • We have no fixed namespace for the http://www.w3.org/1999/xhtml namespace. Instead of .//fn:row, one would need to write .//*:row or .//Q{http://www.w3.org/1999/xhtml}row.
  • For non-HTML usecases, it feels unnatural to work with thead and tbody elements.
  • We would reduce consistency (we already have fn:json-to-xml)

With a language that was initially designed for processing XML data, we shouldn’t lose our focus on pure XML processing, and make no concessions for target formats. It would be nice to have something as simple as csv-doc('input.csv')//field[@column = 'City'].

@michaelhkay michaelhkay added the Propose Closing with No Action The WG should consider closing this issue with no action label Feb 29, 2024
@michaelhkay
Copy link
Contributor Author

I detect a lack of enthusiasm so suggest closure with no action.

@ndw
Copy link
Contributor

ndw commented Mar 5, 2024

The CG agreed to close this issue without further action at meeting 068 .

@ndw ndw closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. Propose Closing with No Action The WG should consider closing this issue with no action XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

3 participants