Skip to content

Commit

Permalink
csv-to-xml returns document node
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Nov 26, 2024
1 parent dd6003c commit 024fa74
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26484,7 +26484,7 @@ return csv-to-arrays(

<fos:function name="csv-to-xml" prefix="fn">
<fos:signatures>
<fos:proto name="csv-to-xml" return-type="element(fn:csv)?">
<fos:proto name="csv-to-xml" return-type="document-node(fn:csv)?">
<fos:arg name="value" type="xs:string?"/>
<fos:arg name="options" type="map(*)?" usage="inspection" default="{}"/>
</fos:proto>
Expand All @@ -26510,23 +26510,25 @@ return csv-to-arrays(

<eg><![CDATA[let $parsedCSV := parse-csv($value, $options)
let $colNames := $parsedCSV?columns
return <csv xmlns="http://www.w3.org/2005/xpath-functions"> {
if (exists($colNames)) {
<columns>{ $colNames ! <column>{ . }</column> }</columns>
},
<rows>{
for $row in $parsedCSV?rows
return <row>{
for member $field at $col in $row
return <field>{
if ($colnames[$col]) {
attribute column { $colnames[$col] }
},
$field
}</field>
}</row>
}</rows>
}</csv>]]></eg>
return document {
<csv xmlns="http://www.w3.org/2005/xpath-functions"> {
if (exists($colNames)) {
<columns>{ $colNames ! <column>{ . }</column> }</columns>
},
<rows>{
for $row in $parsedCSV?rows
return <row>{
for member $field at $col in $row
return <field>{
if ($colnames[$col]) {
attribute column { $colnames[$col] }
},
$field
}</field>
}</row>
}</rows>
}</csv>
}]]></eg>

<p>The namespace prefix used in the names of elements (or its absence) is
<termref def="implementation-dependent"/>.</p>
Expand All @@ -26539,7 +26541,7 @@ return <csv xmlns="http://www.w3.org/2005/xpath-functions"> {
<p>The base URI of the element nodes in the result is <termref
def="implementation-dependent"/>.</p>

<p>A schema is defined for the structure of the returned element: see <specref
<p>A schema is defined for the structure of the returned document: see <specref
ref="schema-for-csv"/>.</p>

<p>The result of the function will always be such that validation against this schema would succeed.
Expand All @@ -26548,7 +26550,6 @@ return <csv xmlns="http://www.w3.org/2005/xpath-functions"> {
that is, whether the elements and attributes in the returned tree have type annotations that reflect
the result of validating against this schema.</p>

<p>The returned element node has no parent node.</p>


</fos:rules>
Expand Down Expand Up @@ -26833,7 +26834,7 @@ return <csv xmlns="http://www.w3.org/2005/xpath-functions"> {
</fos:example>
</fos:examples>
<fos:changes>
<fos:change PR="533 719 834 1066" issue="413 1052"><p>New in 4.0</p></fos:change>
<fos:change PR="533 719 834 1066 1605" issue="413 1052"><p>New in 4.0</p></fos:change>
</fos:changes>
</fos:function>

Expand Down

0 comments on commit 024fa74

Please sign in to comment.