Skip to content

Feature/vfp cursortoxml - #2016

Merged
RobertvanderHulst merged 2 commits into
devfrom
feature/vfp-cursortoxml
Jul 26, 2026
Merged

Feature/vfp cursortoxml#2016
RobertvanderHulst merged 2 commits into
devfrom
feature/vfp-cursortoxml

Conversation

@Irwin1985

Copy link
Copy Markdown
Contributor

Implemented CURSORTOXML():

it receives an alias, an area number, or nothing at all for the current area. Output goes to a file or to a memvar and returns the bytes written. nRecords works, the three schema modes work (none, inline, external file), and so do cnameSpace and the continuous-string flag. Index order and filters are respected, and the record pointer ends up where VFP leaves it: at EOF if you wrote everything, on the last record if nRecords cut in short.

I didn't want to guess the output formar, so I ran the same cursor through a real VFP 9 and diffed the two. Once you ignore the XML declaration, tabs vs spaces, and vs , it comes out indentical to VFP for evething I tried except Double fields. The 20 tests in CursorToXmlTests.prg are basically that comparison turned into asserts.

One thing to flag: I had to touch DbDataTable. It was shoving DBF values straight into a typed DataTable, so any cursor with a data field died with "cannot convert DbData to IConvertible". Old bug, and it hits CursorAdapter and DbDataSource too. CURSORTOXML doesn't even end up using DbDataTable (I needed control over decimal scale and date formatting to match VFP), but leaving that crash sitting there made no sense.

It's marked as Partial on purpose. Only ELEMENTS is produced, nOutputFormat 2 and 3 get swallowed and ignored. Double (B) fields lose their decimals because the RDD doesn't report them (DBS_DEC gives 0, IFloat:Decimals gives -1), so I write the whole value instead of truncating it. The code page and encoding flags, CDATA and whitespaces one aren't done either, output is always UTF-8. cSchemaLocation isn't emmited, and SET SAFETY isn't checked when overwriting a file.

@RobertvanderHulst
RobertvanderHulst merged commit 37a6489 into dev Jul 26, 2026
1 check passed
@RobertvanderHulst
RobertvanderHulst deleted the feature/vfp-cursortoxml branch July 26, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants