Open sumutcan opened 3 years ago
could this be related to the multiple join condition support I saw in one of the issues in RML repo, @ThibaultGerrier?
Hey Umut,
I understand the problem, since the items do not have any unique field, there is nothing to join. I had the same problem with some other mappings, so I introduced the "PATH~" extension to jsonpath for rocketrml that returns the json-pointer (path) of a given element. Since the path of every element is unique you can use that to join. It is used like:
PATH~<jsonpath>
e.g. PATH~
returns path of current element, while PATH~^
returns path of parent.
In your case you could then be using:
- [vao:origin, {mapping: subTripOrigin, join: [PATH~, PATH~^]}]
So join whenever the path of the current element is the same as the path of the parent of the element from the subTripOrigin mapping are the same.
(you can also simply use it like - [schema:path, "$PATH~)"]
to see the paths themselves, for debugging reasons)
However in this project there is a bug in the conversion of yarrrml+ (which allows this join: [idx, ^idx]}
shorthand, which doesn't exist in yarrrml) to yarrrml. This transformation is regex based and does not include the tilde ~
symbol in its regex, so the transformation of join: [PATH~, PATH~^]
will fail. So you'd have to use the traditional yarrrml join method:
- [vao:origin, {mapping: subTripOrigin, condition:{function:equal,parameters:[[str1,"$(PATH~)"],[str2,"$(PATH~^)"]]}}]
(same for destination) With that your mapping should do what it is supposed to.
BTW you are missing some semi colons in the last 3 mappings:
- [a schema:Place]
--> - [a, schema:Place]
very cool, thanks! this PATH~ is something you invented or is it part of jsonpath+ ? I know there is the ~ operator for getting the property names but have not seen any PATH~ syntax.
It's something I invented. jsonpath doesn't have such a feature, so i added it. It is also available for xml and csv mappings. In xml it also returns the path to the current node, while in csv it returns the line number. Xpath does have a built-in feature to return the path (path()
), but only in newer xpath versions. The default xpath lib in rocketrml does not support that feature, since it only supports "old" xpath features, while if you choose the fontoxpath version, you can use that xpath path() function.
Hi Thibault,
I have an issue with joining three objects.
There are trips, their legs (subtrips), origin and destination for each leg. Here is the mapping file and input:
Here is the input file:
Here is the result. Pay attention that there are double entries for origin and destination of each subtrip.
The problem here is that the subtriporigin and subtripdestination mappings are joined with subtrip, but not with the trip mapping so for each trip there is an origin and destination in each subtrip. This happens because the idx value of a leg is only unique within a trip and there is no other property that can serve as a primary key. Is there a way to solve this? I was thinking about adding a second join condition like idx, ^^^^idx, basically joining the trip idx reached from each origin and destination. Would that work with the current implementation?