A slight correction to the above – the sparql query in my previous email may be 
too simplistic in that it does not include files that are inside of packages 
(as package contents are not necessarily described with relationships).

This should produce the graph of both relationships and file contents:

prefix spdx: <http://spdx.org/rdf/terms#>

construct { ?sub ?pred ?obj .
            ?sub2 spdx:hasFile ?file}
where {
     ?sub spdx:relationship ?rel .
     ?rel spdx:relationshipType ?pred .
     ?rel spdx:relatedSpdxElement ?obj .
     ?sub2 spdx:hasFile ?file .

From: <spdx-boun...@lists.spdx.org> on behalf of Yev Bronshteyn 
Date: Wednesday, September 21, 2016 at 2:48 PM
To: "STAIR, MICHAEL A" <ms1...@att.com>, "spdx@lists.spdx.org" 
Subject: Re: SPDX RDF visualization

Hi, Michael,

I don’t know much about RDF graphing tools, but here’s a trick to make any tool 
you already have produce a better graph.

You can use this sparql query to reduce an SPDX document to an RDF where every 
relationship is reduced to a single triple:

prefix spdx: <http://spdx.org/rdf/terms#>

construct { ?sub ?pred ?obj }
where {
     ?sub spdx:relationship ?rel .
     ?rel spdx:relationshipType ?pred .
     ?rel spdx:relatedSpdxElement ?obj .

Here’s how you can apply this query with Apache Jena:

1.      Load your spdx document into Jena’s triple store:
tdbloader --loc=data mydoc.rdf

In the example above, “data” is an empty directory where you have write access 
(where Jena will build its datastore) and mydoc.rdf is your SPDX document.

2.      Apply the query, which in this example is loaded into 
“relConcat.sparql”. Pipe the results into a file.

tdbquery --loc=data --query=../relConcat.sparql --results=RDF

The resulting RDF should be a much more straightforward graph of all the 

From: <spdx-boun...@lists.spdx.org> on behalf of "STAIR, MICHAEL A" 
Date: Wednesday, September 21, 2016 at 2:16 PM
To: "spdx@lists.spdx.org" <spdx@lists.spdx.org>
Subject: SPDX RDF visualization


I was wondering if anyone can suggest a tool to visually in a graph (ideally 
interactive) SPDX RDF files, specifically to follow relationships? I am 
currently using gruff (http://franz.com/agraph/gruff/) , but it’s a little 
tedious. Thanks.

Michael Stair
Principal Member of Technical Staff
AT&T Chief Security Office (CSO)
Spdx mailing list

Reply via email to