Re: Add JSON, XML, CSV to Baby X resource compiler

Liste des GroupesRevenir à l c 
Sujet : Re: Add JSON, XML, CSV to Baby X resource compiler
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.c
Date : 25. May 2024, 19:18:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2t6gf$2ve9k$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 20/05/2024 20:27, bart wrote:
On 20/05/2024 17:14, Scott Lurndal wrote:
bart <bc@freeuk.com> writes:
On 19/05/2024 11:16, Malcolm McLean wrote:
The Baby X resource compiler takes data - fonts, images, audio, strings
- and converts them into C source so that they can be read by C programs
without relying on external data files.
>
>
I looked online at an XML to CSV converter, which I thought would do
something clever, but it seems to just turn each XML line into one
string per line.
>
You use stylesheets (XSL) with a stylesheet processor to make
arbitrary transformations to an XML document.  The output can
be XML, HTML, CSV, or any custom format required for an application.
 The OP wanted to be able to directly process XML; I suggest that it first be transformed into something more regular.
 
I've made an attempt.
The approach is to convert JSON and CSV to XML, and then handle the data with one unified function.
So the user has three options
/* This one just makes a best guess for what you want */
<dataframe src="mydata.xml" />
/* This one tells the program that the records are in nodes with the tag "record" */
<dataframe src="mydata.xml" xpath="//record" />
/* This one declares your own structure, picking fields from the xml document */
<dataframe src="mydata.xml">
<field name="title" />
         <field name="author" xpath="books/authors/author@name" />
<field name="copyright">
<field name="year" xpath="//copyright/year" />
<field name="owner" xpath="books/authors/author@name" />
</field>
</dataframe>
It's basically working, but it needs quite a bit more work to allow the user tighter control of types.
To explain, a "dataframe" is 2 dimenensional table of values, which can be numbers or non-numerical values. So most statistics are done with dataframes.
But of course XML can also represent trees, which are a diferent ball game. That would be a different tag.
Anyone wants to have a play, or dive in with suggestions, it's all on github. (https://github.com/MalcolmMcLean/babyxrc the changes are on the branch topic/dataimport).
--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Date Sujet#  Auteur
19 May 24 * Add JSON, XML, CSV to Baby X resource compiler10Malcolm McLean
20 May 24 `* Re: Add JSON, XML, CSV to Baby X resource compiler9bart
20 May 24  +- Re: Add JSON, XML, CSV to Baby X resource compiler1Michael S
20 May 24  +* Re: Add JSON, XML, CSV to Baby X resource compiler3Mikko
20 May 24  i`* Re: Add JSON, XML, CSV to Baby X resource compiler2Malcolm McLean
21 May 24  i `- Re: Add JSON, XML, CSV to Baby X resource compiler1Mikko
20 May 24  `* Re: Add JSON, XML, CSV to Baby X resource compiler4bart
21 May 24   +* Re: Add JSON, XML, CSV to Baby X resource compiler2Malcolm McLean
22 May 24   i`- Re: Add JSON, XML, CSV to Baby X resource compiler1Ben Bacarisse
25 May 24   `- Re: Add JSON, XML, CSV to Baby X resource compiler1Malcolm McLean

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal