Hi Regina,
On 1/4/26 03:48, Regina Henschel wrote:
It is more about the internal code. Both work with the liborcus
library but do not have common methods. The "Insert Sheet from File"
uses the library with good results. The "Data Provider" uses the
library in case of CSV and XML and does not work for these cases.
I can give you some insight on the liborcus side of stuff.
First, let me use XML as an example. In the current master branch, you
can directly open a generic XML file, and if it contains repeated
records, it gets detected and is automatically imported into a sheet.
It's a new feature I just introduced for 26.2. You can also use the XML
Source dialog to manually define mapping rule and place it into a
selected location anywhere in the current document. This one has been
there for quite some time, at least 10+ years.
The new features have different entry points into the liborcus code, but
eventually both code paths will end up in the orcus::orcus_xml class
that handles mapping of XML structure into a table form. You can take a
look at who the code for the XML Source feature uses orcus::orcus_xml
internally, and use it in a similar fashion inside Data Provider. The
only difference between the two code paths is that, when opening the
file directly from the File Open dialog, a new document is created and
sheets are created ahead of time, and the mapping rule is automatically
defined based on the detected structure of the source XML file. When you
use XML Source, the user input in the dialog is used to define a custom
mapping rule, and the imported data it placed onto an existing sheet.
The rest of the code is the same.
The JSON format is also handled in a very similar fashion except that
there is no JSON equivalent of XML Source dialog. Similar to
orcus::orcus_xml, orcus::orcus_json class is the entry-point class for
handling JSON mapping.
The current header file for orcus_xml is here:
https://gitlab.com/orcus/orcus/-/blob/master/include/orcus/orcus_xml.hpp?ref_type=heads
The header file for orcus_json is here:
https://gitlab.com/orcus/orcus/-/blob/master/include/orcus/orcus_xml.hpp?ref_type=heads
If I were to tackle this, I would use orcus_xml and orcus_json classes
directly inside Data Provider code to handle data transformation. These
classes intentionally have very similar API. You just need to create a
UI for it (if it's not there already) and map the UI input into creating
appropriate transformation rule. I'm still not very familiar with the
Data Provider UI itself, so I can't comment on that side of things much.
Kohei