Skip to content

JSONPath relative #10

@didi-1101

Description

@didi-1101

Issue type: ❓ Question

Hello all,

I'm trying to map SBOMS

[
  {
    "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
    "bomFormat": "CycloneDX",
    "specVersion": "1.6",
    "version": 1,
    "metadata": {
      "timestamp": "2025-05-27T07:28:00Z",
      "tools": {},
      "component": {
        "bom-ref": "bomref1"
      },
      "properties": []
    },
    "components": [
      {
        "bom-ref": "bomref_lib01"
      },
      {
        "bom-ref": "bomref_lib02"
      }
    ],
    "dependencies": [],
    "vulnerabilities": []
  },
  {
    "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
    "bomFormat": "CycloneDX",
    "specVersion": "1.6",
    "version": 1,
    "metadata": {
      "timestamp": "2025-05-27T07:28:00Z",
      "tools": {},
      "component": {
        "bom-ref": "bomref2"
      },
      "properties": []
    },
    "components": [
      {
        "bom-ref": "bomref_lib01"
      },
      {
        "bom-ref": "bomref_lib03"
      }
    ],
    "dependencies": [],
    "vulnerabilities": []
  }
]

I need to say

bomref_lib01 :is_included_in bomref1
bomref_lib01 :is_included_in bomref2
bomref_lib02 :is_included_in bomref1
bomref_lib03 :is_included_in bomref2

so as did

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix mykg: <https://w3id.org/dseco/mykg/> .
@prefix dseco: <https://w3id.org/dseco/ontology/> .
@prefix org: <http://www.w3.org/ns/org#> .
@prefix observable: <https://ontology.unifiedcyberontology.org/uco/observable/> .
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

### Mapping 
mykg:MappingComponent a rml:LogicalSource ;
    rml:source "a.json" ;
    rml:referenceFormulation ql:JSONPath ;
    rml:iterator "$[*]" .

mykg:Triples_COMPONENT_is_included_in_COMPONENT a rr:TriplesMap ;
    rml:logicalSource mykg:MappingComponent ; 
    rr:subjectMap [
        rr:template "https://w3id.org/dseco/mykg/COMPONENT_{components[*].bom-ref}" ;
        rr:class dseco:COMPONENT ;
        rr:class owl:NamedIndividual ;

    ] ;
    rr:predicateObjectMap [
         rr:predicate dseco:is_included_in ;
         rr:objectMap [
            rr:template "https://w3id.org/dseco/mykg/COMPONENT_{metadata.component.bom-ref}" ;
        ] ;
    ] ;
    .

mykg:Triples_COMPONENT_in_metadata a rr:TriplesMap ;
    rml:logicalSource mykg:MappingComponent ; 
    rr:subjectMap [
        rr:template "https://w3id.org/dseco/mykg/COMPONENT_{metadata.component.bom-ref}" ;
        rr:class dseco:COMPONENT ;
        rr:class owl:NamedIndividual ;
    ] ;
    rr:predicateObjectMap [
        rr:predicate dseco:hasBomRef_pere ;
        rr:objectMap [ 
            rml:reference "metadata.component.bom-ref" ; rr:datatype xsd:string;
        ] ;
    ] ;
    .



and it works well (i filtered out the NamedIndividual and COMPONENT)

<https://w3id.org/dseco/mykg/COMPONENT_bomref1> <https://w3id.org/dseco/ontology/hasBomRef_pere> "bomref1" .
<https://w3id.org/dseco/mykg/COMPONENT_bomref2> <https://w3id.org/dseco/ontology/hasBomRef_pere> "bomref2" .
<https://w3id.org/dseco/mykg/COMPONENT_bomref_lib01> <https://w3id.org/dseco/ontology/is_included_in> <https://w3id.org/dseco/mykg/COMPONENT_bomref1> .
<https://w3id.org/dseco/mykg/COMPONENT_bomref_lib01> <https://w3id.org/dseco/ontology/is_included_in> <https://w3id.org/dseco/mykg/COMPONENT_bomref2> .
<https://w3id.org/dseco/mykg/COMPONENT_bomref_lib02> <https://w3id.org/dseco/ontology/is_included_in> <https://w3id.org/dseco/mykg/COMPONENT_bomref1> .
<https://w3id.org/dseco/mykg/COMPONENT_bomref_lib03> <https://w3id.org/dseco/ontology/is_included_in> <https://w3id.org/dseco/mykg/COMPONENT_bomref2> .

but now I also want to say for each "child" component that they also have a triplet like

COMPONENT_bomref_lib03 :hasBomRef "bomref_lib03"

And there i do not know how to write the new
rr:predicateObjectMap in mykg:Triples_COMPONENT_is_included_in_COMPONENT

because I cannot refer to the current item of my loop

Another approach was to loop on the children directly with something like

rml:iterator "$[*].components[*]" .

but in this case I cannot manage to refer to the bom-ref in metadata because notation like ..metadata.bom-refdoesn't seem to work

I would be most grateful to receive a response, thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions