-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TD 1.1 JSON-LD/RDF roundtripping example #2031
Comments
@wiresio has some experience within https://github.com/eclipse-thingweb/domus-tdd-api . Could you help here? |
Hi @DavideRossi, as @egekorkan wrote you can find everything in the repo above, especially in: https://github.com/eclipse-thingweb/domus-tdd-api/blob/main/tdd/td.py and https://github.com/eclipse-thingweb/domus-tdd-api/blob/main/tdd/sparql.py
When you extract the corresponding pieces from our code, you should be able to roundtrip your example via JSON-LD playground (JSON-LD to RDF), local Jena installation (store RDF and carry out the SPARQL query with JSON-LD as output format), and JSON-LD playground again (framing). |
In our AID plugin, available at https://github.com/wiresio/domus-tdd-api-plugin-aid, we go one step further and carry out a format conversion:
|
Thanks a lot @wiresio I'm definitively going to look into that! |
I was able to single out the problem I'm having with roundtripping (I have some half-baked Kotlin code for a Thing Directory). |
Please see here: #1193 |
Thanks @wiresio , but I don't know if that is the same problem. If I got it right (and this may very well not be the case) I should replace the TD's Post scriptum: I realized the |
OK, my previous message was clearly me misunderstanding what's going on here. Notice, it's not just Titanium. I tried the RDF conversion with the JSON-LD Playground as well and the result is:
where you have a id-less |
What happens if you try:
|
First of, @wiresio, thanks a lot for you continued assistance.
Notice: this TD is not valid since it's missing security related info, but I'm not interested in validation now.
By trying to understand what's going on I seen that in the context you can find:
Let's see what happens.
So far so good.
And that is Titanium (uncompacted):
Both use a value type for the title, but Titanium loses the language info and adds a |
Oh, and I forgot a bit (this thing is a bloody mess). You can force Titanium to behave like the Ruby/Javascript libs with strings by setting
So you either have messed up booleans or messed up strings! |
Oh well. These were two bugs in Titanium JSON-LD. |
@DavideRossi - sorry for the late reaction: Is the summary that you have / had challenges with the Titanium stack or do you thing that there is (still) an issue with the TD context? |
Yes, the issues I was experiencing were due to a couple of bugs in Titanium JSON-LD. |
Hi @DavideRossi, I'm a bit late for the conversation. But in the case it may help, I follow the same approach for framing as mentioned above. For the titanium issues, we tried to locate them and fix them with code after performing a regular round trip from RDF to JSON-LD 1.1. In all likelihood, there will be some cases we did not located yet but for fixing these issues we did not found another way. So for instance, translating from RDF to JSON-LD 1.1 requires the TD to have @type : Thing. However, many times TDs do not specifically provide the type and it is assumed they are td:Things. In these cases we store meta information about the TD where we specify a certain TD has no type, and we inject the type manually when stored in the triple store. When this TD is retrieved, we translate it into JSON-LD 1.1 and then reading the meta information we modify it, for instance, removing the type if the original TD hadn't it written. |
The are issues that are hard to fix with this approach, mostly related to type management. Localized strings come to mind, but in general JSON type conversions is broken in Titanium whenever you deal with a nested framing document (as in this case).
Yes, if you want "fully transparent round-trip" you have to resort to this kind of approaches. I'm not sure, however, about the need the keep track of things in the registration phase just to undo them for look-ups. |
It is true that Titanium has some issues, but most of those I struggled with come from the fact that JSON-LD 1.1 document needs to be exactly the same without differences as the original one. This is challenging because RDF is not meant for instance to have order (unless you rely on rdf:List), which makes challenging returning an array in the same order as the original TD document. Maybe, reviewing the I also remember to have some issues with the security, that was translated into RDF with a URI that when going back to JSON-LD 1.1 was not translated as the original term. In these cases there is no other way to solve the issue than developing these ad-hoc translations (which I'm not found as a solution). Finally, we need to consider that people use TDs adding some other vocabularies to improve the granularity of the data described. This also may lead to some minor issues but, maybe, this is a topic for a different issue. |
The security thing is again a problem with Titanium. In my fixed version it works no problem. |
I like your idea of storing the original Json as a literal, probably it would solve more than one headache I had |
One of my students implemented a WOT Directory (in Kotlin) by keeping an in-memory collection of the TDs as JSON, then each time a JSON TD is changed (or a new one is created) the associated RDF graph is reconstructed. You can check it at https://github.com/dvgniele/WoTerFlow. |
Can anyone provide a working example of TD roundtripping?
Say we start with this simple example TD
Link to thingweb TD playground
Encoding to RDF looks simple, it can be done online using the JSON-LD Playground.
So far so good, we have N-Quads RDF and we can use any RDF tool.
Now I start having issues. How should I convert back from RDF to TD?
Via compacting? Via framing (and where is the TD frame definition?)
Can anyone provide a working toolchain? Online converters, code, whatever. I would just like to see this thing working.
The text was updated successfully, but these errors were encountered: