W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > July 2015

Re: Parsing & validating a document

From: Gregg Kellogg <gregg@greggkellogg.com>
Date: Wed, 22 Jul 2015 19:08:25 -0700
Message-ID: <1455582130235188642@unknownmsgid>
To: Stefan Novak <novast@ohsu.edu>
Cc: Gregg Kellogg <gregg@greggkellogg.net>, "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
On Jul 22, 2015, at 6:42 PM, Stefan Novak <novast@ohsu.edu> wrote:

  Hey Gregg,

Thanks for the quick reply! The CWL schemas are still in draft form, but I
can look into getting a PR prepped for the rdf-vocab repository. Are there
any recommendations for maintaining different versions of vocabularies? For
example, CWL has a draft-2 and draft-3 version available.

I did make some progress on my end:


   I can create a Graph directly from a Turtle schema that I have available.

   I can create a context from that graph and attach it to the document to
   expand it.

   I can convert that context to a document graph to validate and query.

 This can be seen here

Last last piece of the puzzle is to query that graph. Since my attribute
values are being parsed and stored in the @id attribute, I assume that I
would bind the id: attribute to a solution field (such as :text). However,
as you can see in the above Gist, I’m getting node names returned. Is there
a way to query the @id attribute?

I appreciate any feedback in the last step for querying the RDF graph.

Briefly, you might want to consider querying the graph using the sparql
gem, or with RDF::Query natively. Otherwise, framing is a kind of query for
JSON-LD and jsonpath for JSON generically.

Most RDF applications will query with SPARQL or a native graph query


 Thanks again for writing clean specs and good docs – they’re super helpful!


 On Jul 22, 2015, at 12:43 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote:

  On Jul 21, 2015, at 6:30 PM, Stefan Novak <novast@ohsu.edu> wrote:


First off, thanks for piecing together a well-rounded library! I really
appreciate the documentation and specs available to make it easier to
implement RDF in a project of mine.

I’m having a bit of trouble wrapping my head around the best way to
implement a Ruby version of the Common Workflow Langauge

Specifically, I’m trying to figure out the best way to parse out a
Workflow object.
I’d appreciate any feedback to get up and running!

My assumptions:


   There’s a Turtle schema available
   contains a list of classes. I can successfully process that schema as a
   RDF Schema
   and convert it to a JSON-LD object

   There’s a JSON-LD context
   for the schema. (Thanks for the rdf-turtle gem!)

   I can take the above graph from the schema and the context to create the
   input for a data frame

   With that input, I’m trying to frame a document (a simple CLW workflow
   however the object I get back contains just the @context attribute and
   no @graph property. According to the example in the JSON-LD docs
   <https://github.com/ruby-rdf/json-ld#frame-a-document>, I was hoping to
   get a @graph object that I can convert back to an RDF graph object.

 So – my questions are:


   Is this the right approach?

   At what point can I validate that my document (i.e., cat1-tool.cwl)
   conforms to the schema.

   Is it better to traverse the framed document in the JSON-LD form? Or
   should I convert it back to an RDF graph to traverse / query it there?

 Thanks! I appreciate any feedback!

 Seems like you generally have the right approach. Generate an RDF graph
and then serialize/frame as JSON-LD.

 Validation probably needs to be done with the graph, rather than a
particular serialization. If you create an RDF::Vocabulary sub-class using
the schema, you can validate the graph using that, along with other loaded
vocabularies. You can create a local version of the vocabulary to use with
your code using RDF::VocabularyLoader (see the rdf-vocab gem Rakefile, for
an example [1]). Eventually, it may be that the vocabulary would go into
the rdf-vocab gem.

 Validation is done using the rdf-reasoner gem, with specific methods that
are described there. The structured-data Linter [2][3] makes use of this to
validate input documents against loaded vocabularies, so that might be
something for you to look into.

 It’s probably better to break down the task and just produce unframed
JSON-LD. You can then use the JSON-LD playground [4] to frame your data.
Once you’re happy with that, you can frame using the json-ld gem, as you do
now; if the frame isn’t correct, it might not result in any output, so
that’s probably the problem you’re dealing with right now.


 [1] https://github.com/ruby-rdf/rdf-vocab
[2] http://linter.structured-data.org
[3] https://github.com/structured-data/linter
[4] http://json-ld.org/playground/index.html
Received on Thursday, 23 July 2015 02:09:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:18 UTC