Skip to content

Commit

Permalink
Change type of column-names option
Browse files Browse the repository at this point in the history
Change type of column-names map option to map(xs:string, xs:integer)
from map(xs:integer, xs:string). It turns out I had used this format for
all the examples, and the more I thought about it, the more it seemed
unhelpful to have a map like `map { 1: "a", 2: "b" }` produce a
`csv-columns-record` whose `names` entry was `map { "a": 1, "b": 2 }`.

Not least, that prevented the `names` entry from a `csv-columns-record`
being used as the `column-names` option in another invocation, which
might be desirable if a user has one CSV with headers and subsequent
CSVs of the same schema but without the header line (transaction logs
split for size, perhaps).
  • Loading branch information
fidothe committed Sep 27, 2023
1 parent 011dd7c commit 177e461
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21524,7 +21524,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
<fos:meaning>Determines whether the first row of the CSV should be treated as a list
of column names and returned as a <code>csv-columns-record</code> in the
<code>columns</code> entry of the returned map. Permitted values are a map of type
<code>map(xs:integer, xs:string)</code> or an <code>xs:boolean</code>.
<code>map(xs:string, xs:integer)</code> or an <code>xs:boolean</code>.
</fos:meaning>
<fos:type>item()</fos:type>
<fos:default>false</fos:default>
Expand All @@ -21544,7 +21544,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
the returned <code>parsed-csv-structure-record</code>. Implementations
<rfc2119>must not</rfc2119> exclude the first row from the <code>rows</code>
entry of the <code>parsed-csv-structure-record</code>.</fos:value>
<fos:value value="map(xs:integer, xs:string)">A <code>csv-columns-record</code> is
<fos:value value="map(xs:string, xs:integer)">A <code>csv-columns-record</code> is
constructed using the supplied map and returned as the <code>header</code>
entry of the <code>parsed-csv-structure-record</code>. The supplied map is used
as the <code>names</code> entry, and a sequence of strings for the
Expand Down Expand Up @@ -21758,7 +21758,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
</fos:test>
</fos:example>
<fos:variable name="csv-string" id="csv-string-no-headers">`Alice,Aachen{$crlf}Bob,Berlin{$crlf}`</fos:variable>
<fos:variable name="options" id="explicit-csv-column-opts">map { "column-names": map { 1: "Person", 2: "Location" } }</fos:variable>
<fos:variable name="options" id="explicit-csv-column-opts">map { "column-names": map { "Person": 1, "Location": 2 } }</fos:variable>
<fos:example>
<p>Specifying column names explicitly:</p>
<fos:test use="csv-string-no-headers escaped-crlf-2 explicit-csv-column-opts">
Expand Down Expand Up @@ -21807,7 +21807,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
<fos:example>
<p>Filtering columns, with <code>column-names: map { ... }</code></p>
<fos:test use="escaped-crlf-2 uneven-cols-csv-string">
<fos:expression>csv-to-xdm($csv-uneven-cols, map { "column-names": map { 1: "Person", 3: "Amount" }, "filter-columns": (2,1,4) })?columns</fos:expression>
<fos:expression>csv-to-xdm($csv-uneven-cols, map { "column-names": map { "Person": 1, "Amount": 3 }, "filter-columns": (2,1,4) })?columns</fos:expression>
<fos:result>map {
"names": map { "Person": 1, "Amount": 3 },
"fields": ("Person", "", "Amount")
Expand Down Expand Up @@ -21934,7 +21934,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
<fos:meaning>Determines whether the first row of the CSV should be treated as a list
of column headers and returned as <code><![CDATA[<column>]]></code> elements in
the <code><![CDATA[<header>]]></code> element. Permitted values are a map of type
<code>map(xs:integer, xs:string)</code> or an <code>xs:boolean</code>.
<code>map(xs:string, xs:integer)</code> or an <code>xs:boolean</code>.
</fos:meaning>
<fos:type>item()</fos:type>
<fos:default>false</fos:default>
Expand All @@ -21946,7 +21946,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
element.</fos:value>
<fos:value value="false">Implementations <rfc2119>must not</rfc2119> include a
<code><![CDATA[<header>]]></code> element in the output.</fos:value>
<fos:value value="map(xs:integer, xs:string)">The supplied map is used to
<fos:value value="map(xs:string, xs:integer)">The supplied map is used to
construct a sequence of <code><![CDATA[<column>]]></code> elements to populate
the <code><![CDATA[<header>]]></code> element. The <code>xs:integer</code>
denotes the column number, and the <code>xs:string</code> the column name. Gaps
Expand Down Expand Up @@ -22027,7 +22027,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>
<fos:example>
<p>An empty CSV with explicit column names:</p>
<fos:test>
<fos:expression>csv-to-xml("", map { "column-names": map { 1: "name", 3: "city"})</fos:expression>
<fos:expression>csv-to-xml("", map { "column-names": map { "name": 1, "city": 3 })</fos:expression>
<fos:result><![CDATA[
<fn:csv>
<fn:header>
Expand Down

0 comments on commit 177e461

Please sign in to comment.