Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes add implementations of the XQuery 4.0 functions
fn:csv-to-arrays
,fn:parse-csv
, andfn:csv-to-xml
.The implementation uses the same CSV parser as
csv:parse
, adapting it by adding new options to integrate additional functionality.There are 6 new
CsvOptions
, which now can be used bycsv:parse
as well:ROW_DELIMITER
QUOTE_CHARACTER
TRIM_WHITESPACE
TRIM_ROWS
SELECT_COLUMNS
STRICT_QUOTING
All but
STRICT_QUOTING
are defined in the XQuery 4.0.STRICT_QUOTING = false
serves for distinguishing the behaviour of the new functions with respect to quoting from the preserved behaviour ofcsv:parse
.TRIM_WHITESPACE
is not yet implemented as in qt4cg/qtspecs#1677, as it trims whitespace off of quoted fields too. In qt4cg/qtspecs#1675 I made the proposal to additionally allow whitespace outside of quotes. Once these issues have been completed, I will adapt the implementation accordingly.Empty-line handling had to be changed to conform to the XQuery 4.0 function specification. While empty lines used to be skipped by
csv:parse
, they are now unconditionally preserved even for that function, such that it now behaves like the new functions with respect to empty lines. Tests have been added toCsvModuleTest
and the changed behaviour has been annotated like this:With these changes BaseX passes most of the QT4 tests for the new functions. The remaining test failures are for different error codes than expected, e.g.