My comment, which I admit was quick and poorly phrased, was that not all
serializations are in a tree format.
I was obviously talking about RDF/XML; if I gave the impression I was talking
about XML in general, I apologize.
The fact that RDF is written in XML is secondary. On the lowest level XML is
hierarchical, since it is all about nested tags. However this is similar to
JSON being usually written in files with lines, but we never consider it a
line-oriented format.
Let me try and give an example. Suppose we have a list of people. A JSON
serialization might be:
“people”: [ {“name”: “Alice”, “gender”: “female”}, {“name”: “Bob”, “gender”:
“male”}, {“name”: “Charlie”, “gender”: “male”}]
That’s a tree.
But remember, we are talking about knowledge representation—what we know about
those people.
The exact same data may be serialized as:
Person is-a Class
Alice is-a Person
Bob is-a Person
Charlie is-a Person
Gender is-a Class
Male is-a Gender
Female is-a Gender
Alice hasGender Female
Bob hasGender Male
Charlie hasGender Male
This is simply a collection (list) of facts – and the different entities
appearing therein create a graph, not a tree. To make it even more visible, the
last fact may be replaced by an equivalent:
Male isGenderOf Charlie
As you can imagine, this is actually very close to what RDF representation
looks like. If, instead of triples, we want to use XML (yes, with nested tags)
we can produce a serialization of the information which is definitely not in a
tree format. (well, obviously a list may be considered a wide tree of depth 1,
but let’s not be pedantic).
Actually, in SPDX, in order to produce a single tree, you have to “cheat”
somehow and introduce fake nodes to produce a hierarchy and identifiers/names
to be able to refer to arbitrary nodes from other parts of the tree. It’s
perfectly fine to do that, of course, because of the constraints of the
serialization format (e.g., JSON).
I think the conclusion we reached at the end of our call yesterday is the best:
we should be working in parallel at the abstract knowledge representation
model, as well as at different serialization formats. As Gary mentioned, one
affects the other, and we have not always been able to proceed with this
parallel development in the past.
-- zvr
From: [email protected] <[email protected]> On Behalf Of David
Kemp
Sent: Tuesday, 15 June, 2021 21:51
To: SPDX-list <[email protected]>
Subject: [spdx-tech] XML and JSON
All,
During the call, someone mentioned that JSON is inherently tree-structured
while XML is not.
XML certainly seems to be hierarchical, and the popular Python XML
library<https://lxml.de/tutorial.html> even calls their API "Element Tree".
XML differs from JSON in that Elements have text that is distinguished from
other attributes, and that collection properties (ordered and unique) are not
built-in to the language as they are with JSON's array and object. But
elements are strictly contained within other elements, and nesting violations
are more strictly enforced than with HTML.
Could someone elaborate on in what sense XML is non-hierarchical?
v/r,
Dave
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#4084): https://lists.spdx.org/g/Spdx-tech/message/4084
Mute This Topic: https://lists.spdx.org/mt/83564830/21656
Group Owner: [email protected]
Unsubscribe: https://lists.spdx.org/g/Spdx-tech/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-