-
pabs
-
systwi
Is there any benefit to formatting XML data like this:
transfer.archivete.am/zxhVE/example2.xml
-
systwi
-
systwi
Are there particular use cases where one is preferred over the other?
-
systwi
or maybe even a hybrid of both?
-
JAA
Uh, I mean, HTML is a hybrid.
-
systwi
I meant, as in, are there any specific reasons why one might use the first example, the second example, or both together.
-
Frogging101
-
systwi
I've seen all three styles in use before.
-
Frogging101
It's over. It's well and truly over.
-
JAA
Not by itself, but you can give it semantic meaning. In HTML, subelements are tags and properties are attributes.
-
JAA
You could have: <department name="IT"><employee name="John Doe" /><employee name="Jane Doe" /></department>
-
JAA
That would be the HTML-like distinction between tags and attributes.
-
JAA
If you want to model this container-elements relationship, it almost always only makes sense as nested tags.
-
JAA
Representing properties of a container as a subtag then just makes it a bit messy, but there's no fundamental reason why you can't do it.
-
JAA
Or perhaps this: <department><name>IT</name><employees><employee><name>John Doe</name></employee><employee><name>Jane Doe</name></employee></employees></department>
-
JAA
Just comes down to personal preference, I think.
-
systwi
Okay. So, if I'm understanding it correctly, both of your examples essentially represent the same data (in XML, but maybe also in HTML?), but with different formatting.
-
systwi
No real difference aside from structure.
-
JAA
Yeah, it's just a different structure for the same data.
-
systwi
I see, I see.
-
systwi
Thank you for the help. :-)
-
JAA
And yeah, it could be valid HTML5 I think. IIRC, that allows you to define custom tags. I was thinking XML though.
-
systwi
XML was mainly what I was inquiring about, so that's okay.
-
JAA
Choose whatever you prefer, document it well, done. :-)
-
JAA
That's how I view it, anyway.
-
JAA
-
systwi
A couple of other things, on the subject of XML structure/formatting (if you don't mind). Include or omit a trailing newline? CRLF vs. LF? (CR-only is for madlads :-P ) `encoding="UTF-8"` vs. `encoding="utf-8"`?
-
systwi
Tabs vs. spaces?
-
systwi
They're all, probably, dependent on the interpreter (how tolerant it is built).
-
JAA
My personal preferences: include trailing newline, LF, UTF-8, tabs. Except for the capitalisation of UTF-8, same as any text/code-ish file I produce. :-)
-
systwi
Maybe I'm looking too deep into storing data, intended for human reading/writing, that could simply be stored in a spreadsheet, hahaha. :-)
-
JAA
If a parser can't handle these, it's broken.
-
JAA
I'd use JSON for everything anyway these days.
-
systwi
Nice, thanks. I used to use tabs for everything but switched to spaces a while ago. The rest of your preferences jive with mine, although my XML documents used capitalised `UTF-8`.
-
JAA
Well, maybe not spreadsheets, but if it's going to be a small dataset and intended to be directly edited by humans, something like JSON or TOML would be the way to go.
-
JAA
XML is a pain and very error-prone to edit manually.
-
systwi
I can never make up my mind as to which format I want to use. CSV/TSV, TOML, YAML, XML, JSON, etc. I start one, then move to the next, then eventually to SQLite, then to PostgreSQL, and that's where I say, "wait a minute, a Postgres database for tracking which Pokémon use which nicknames in my game?" :-P
-
JAA
Heh
-
systwi
The tough thing is finding validators that aren't all JS dumpster fires.
-
systwi
Notepad++ helps in some areas, but not all.
-
systwi
or Firefox, for validating an XML for example.
-
JAA
'Validating' has many meanings.
-
systwi
YAML sounded promising but I ran into that ^ issue re: offline validators.
-
JAA
One is whether it follows the markup language spec. (Have fun there with CSV/TSV, for which no specs exist.)
-
systwi
Ah, my meaning is, "does my syntax match what is expected of YAML/XML/... documents."
-
JAA
But you might also want to validate that it matches your schema.
-
systwi
Yeah, language spec, yeah.
-
JAA
On my system, I have `xmlparse` for XML validation, `python3 -m json.tool` for JSON (good enough is good enough). Haven't had a need for validating the others locally so far.
-
systwi
I've considered including a separate file.csv.ini file, detailing escape characters, whitespace collapsing, whether or not data types are taken into consideration, line terminators, etc.
-
systwi
(for CSV/TSV files, of course)
-
JAA
Eww
-
JAA
:-)
-
systwi
to put _some_ grasp on the no-spec madness.
-
systwi
Hehehe
-
JAA
By adding another underspecified, ancient format into the mix. lol
-
systwi
:-)
-
systwi
Maybe a JSON to describe the .ini file?
-
systwi
file.csv.ini.json
-
systwi
file.csv.ini.json.zst
-
systwi
for when it gets too big. :-P
-
JAA
I was just trying to think of another awful old format, but don't remember any others.
-
systwi
MSP for old mspaint images?
-
systwi
Not a markup document.
-
JAA
Yeah, document the INI format in an image just to fuck with people, that sounds good to me. :-)
-
JAA
And now I'm thinking of th MS Paint IDE again.
-
JAA
Would probably be the appropriate dev environment for implementing this Lovecraftian nightmare though. :-)
-
systwi
Compress the image using a proprietary compression algorithm, only uncompressable by hunting down a 1988 copy of the program (company went out of business around that time) and running it on old hardware.
-
systwi
"Haha, Rickrolled!"
-
systwi
:-P
-
JAA
Funny, there was someone in #python the other day trying to reverse-engineer an ancient proprietary database format. Only thing they had was files in the format and a decompiled Java code (i.e. no sensible variable names etc.).
-
systwi
An mspaint IDE might work, if you create a monochrome BMP with it and write in binary.
-
systwi
:-P
-
JAA
Although well, not quite 1988-ancient given it was Java. But same difference.
-
systwi
Hah, interesting. #python on hackint?
-
JAA
I was referring to this thing I found a few weeks ago and linked here at the time:
ms-paint-i.de
-
JAA
No, on Libera.
-
systwi
Hah, that's so weird, but cool!
-
systwi
I saw a video of somebody running Doom inside of an unmodified notepad.exe.
-
systwi
*unmodified binary
-
systwi
-
JAA
Nice
-
JAA
My favourite's still the pregnancy test, and I'm not sure that'll get beaten.
-
systwi
Get those kids started on Doom early. :-P
-
JAA
:-)
-
systwi
That's pretty cool, too. Forgot about that one.
-
systwi
Not Doom, but also equally...bizarre:
github.com/smealum/butthax
-
JAA
Heh, didn't see that one before, but there was one about a 'smart vibrator' as well.
-
JAA
-
systwi
Hah! Didn't see that issue thread before.