RdfContext and RDF::RDFa support for RDFa 1.1 2008-08-03 draft semantics

Posted by Gregg Kellogg Wed, 01 Sep 2010 23:53:00 GMT

 I've updated both RdfContext and RDF::RDFa gems to support the latest RDFa Core 1.1 Editor's Draft  (2010-08-03) semantics. This includes support for the following:

  • Use of a Processor Graph to gather information and errors during the course of parsing. Use the :processor_graph option to specify a Graph in which to collect information. There is no published specification for the properties to use, but until there is, each event is saved with a Blank Node subject of type rdfa.UndefinedPrefixError, rdfa:UndefinedTermError, rdfa:HostLanguageMarkupError, rdfa:ProfileReferenceError, rdfa:InformationalMessage, rdfa;MiscellaneousWarning or rdfa:MiscellaneousError. Additionally statements with literals for dc:description, dc:date, rdfa:sequence and rdfa:source (path to HTML Node) are generated.
  • RDFa Profiles allow URI mappings for terms and prefixes along with the specification of a default vocabulary.
  • RDFa 1.1 preferes the use of @prefix to create prefix mappings, but @xmlns continues to be supported.
  • XMLLiterals must be declared explicitly by setting @datatype="rdf:XMLLiteral". In 1.0, any statement with a property that contained anything other than text nodes as children caused an XMLLiteral to be emitted.

Note that until RDFa Core 1.1 is published, all features are subject to change. I will not be attempting to maintain compatibility with draft features that are obsoleted during the standardization process.

Channel Islands July 2010

Posted by Gregg Kellogg Mon, 19 Jul 2010 06:19:00 GMT

 New photos from my recent dive trip to the Channel Islands.

I had some camera issues in the first couple of days, but things settled down by the time I got to the Macro photography on day 3. I like the perspective on the Nudibranchs. The last couple of shots may be of an embryonic Nudibramch.

The Gold and White Nudibranch is a Horned Aeolid (Hermissenda crassicornis), which is reasonably common in the Northern Channel Islands.

The Purple and Orange is a Spanish Shawl (Flabellina iodinea), also fairly common.

RdfContext version 0.5.4 with provisional RDFa 1.1 support

Posted by Gregg Kellogg Fri, 07 May 2010 05:25:00 GMT

I just released version 0.5.4 of RdfContext to GitHub and GemCutter. This version is notable for including support for RDFa 1.1 parsing. This is still based on an Working Draft, so it will likely change in the future.

RDFa 1.1 includes support for profiles, vocabularies and terms. And supports using URIs or CURIEs or terms anywhere that's legal within an HTML document. Right now, only the XHTML+RDFa profile is supported.

Default term URI using @vocab.

RDFa 1.1 allows URIs to be expressed using an NCName, called a term, by using the @vocab attribute, an author can define a URI to be used for a bare word to turn it into a URI. Take for example the following:

<div vocab="http://xmlns.com/foaf/0.1/">
   <p about="#me" typeof="Person" property="name">Gregg Kellogg</p>
</div>

willgenerate the following triples:

<#me> a foaf:Person;
  foaf:name "Gregg Kellogg" .

Profile documents for defining prefixes and terms

A Profile document allows the specification of a set of URI mappings and term mappings in a single document. These documents are RDF formatted, and may or may not be RDFa. The following shows an example Profile document:

@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
[ rdfa:prefix "foaf"; rdfa:uri "http://xmlns.com/foaf/0.1/"] .
[ rdfa:prefix "dc"; rdfa:uri "http://purl.org/dc/terms/"] .
[ rda:term "name"; rdfa:uri "http://xmlns.com/foaf/0.1/name"] .
[ rda:term "created"; rdfa:uri "http://purl.org/dc/terms/created"] .

This bit profile results in namespace mappings and a bare terms. Multiple vocabularies may be used together to create a namespace composed of terms from several vocabularies, without needing to describe them explicitly. These may then be used in a document as follows:

<div profile="http://example.com/my_vocab">
  <p about="#me">
    <span property="name">Gregg Kellogg</span>
    is the author of
    <a rel="created"
        resource="http://github.com/gkellogg/rdf_context">
      RdfContext
    </a>
  </p>
</div>

Namespace definitions

RDFa 1.1 deprecates the use of @xmlns for defining namespace prefixes. The @prefix attribute defines one or more mappings between prefixes and URIs. For example:

<div prefix="foaf: http://xmlns.com/foaf/0.1/ dc: http://purl.org/dc/terms/">
  <p about="#me">
    <span property="foaf:name">Gregg Kellogg</span>
    is the author of
    <a rel="dc:created"
        resource="http://github.com/gkellogg/rdf_context">
      RdfContext
    </a>
  </p>
</div>

Defines and uses two different namespace mappings.

URIs Everywhere

In RDFa 1.0, certain attributes took a URI, others a CURIE, and still others either a URI or a Safe CURIE. This is confusing, and RDFa 1.1 now allows either URIs, CURIEs, or SafeCURIEs to be used most anywhere (SafeCURIEs are maintained for backwards compatibility). For example:

<div>
    <p about="#me">
      <span property="http://xmlns.com/foaf/0.1/name">
        Gregg Kellogg
      </span>
      is the author of
      <a rel="http://purl.org/dc/terms/created"
          resource="http://github.com/gkellogg/rdf_context">
        RdfContext
      </a>
    </p>
  </div>
  

Change History

The following is the change log for this version of RdfContext. Note that one change may potentially break existing code: URIRef#namespace no longer throughs an exception if a mapping is not found. Other changes are noted here:

  • RDFa 1.1 parsing supported (based on RDFa Core 1.1 W3C Working Draft 22 April 2010)
  • Fix URIRef#short_name (and consequently #base and #namespace) to not extract a non-hierarchical path as a short_name
  • Namespace no longer uses URIRef, but just acts on strings.
  • Namespace#new does not take an optional _fragment_ argument any longer.
  • Added Namespace#to_s to output "prefix: uri" format
  • Graph#qname first trys generating using bound namespaces, then adds well-known namespaces.
  • URIRef#to_qname and #to_namespace No longer generates an exception. Each take either a Hash or an Array of namespaces and tries them from longest to shortest.
  • Improved Turtle and XML serializers in use of namespaces.
  • Generate pending messages if RDFa tests skipped due to lack of Redland installation.
  • Change dcterms: prefix to dc: (fully compatible with previous /elements/ definitions)

Socorro Slide Show

Posted by Gregg Kellogg Tue, 27 Apr 2010 20:09:00 GMT

 Just uploaded a slide show made from the the Socorro photo album I recently published. Enjoy.

Socorro Pictures 4

Posted by Gregg Kellogg Mon, 26 Apr 2010 23:35:00 GMT

 Just got back from Socorro and associated islands. We dove off of the Solmar V, a very nice dive boat operating out of Cabo San Lucas. I got some wonderful pictures of a friendly Giant Manta Rey who did several fly overs during the course of one dive off San Benedicto Island.

My picks for the best pictures of the trip can be found here. More pictures, including people and several sequences of Manta fly overs can be found here.

RdfContext version 0.5.1 brings Turtle and enhanced RDF/XML serializers

Posted by Gregg Kellogg Sat, 03 Apr 2010 05:57:00 GMT

 Just pushed version 0.5.1 of RdfContext to GitHub and Gemcutter. This version includes a Serializer framework, including a AbstractSerializer, RecursiveSerializer and Turtle and RDF/XML serializers based on these. The RDF/XML serializer is a big improvement over the previous version, including Typed element names an RDF Container folding using parseType="collection".

RdfContext includes native Ruby parsers for RDF/XML, RDFa and N3-rdf, which includes Turtle and N-Triples. All parsers pass W3C tests (included in specs). It also includes context-aware quad store, with in-memory and SQLite3 storage models.

RdfContext version 0.5.0 brings compliant notation-3/turtle parsing

Posted by Gregg Kellogg Mon, 22 Feb 2010 23:33:00 GMT

This version of 0.5.0 adds support for Ruby 1.9 and 1.8.6 in addition to 1.8.7. Full unicode character escapes are supported in Ruby 1.9. The N3 parser has been substantially re-written and updated to be compliant with W3C SWAP, CWM and Turtle test suites, although it is supported only to the N3-rdf level, with variables and formulae not yet supported.

See GitHub project page for more information. Available for download through Gemcutter.

Release notes for version 0.5.0

  • Support for Ruby 1.9, 1.8.7 and 1.8.6.
    • Unicode escapes and URIRefs only work properly in Ruby 1.9
    • Replaced some (&:meth) spells with {|c| c.meth} for Ruby 1.8.6 compatibility
  • Fully compliant N3 parser (n3-rdf level) with extnensive tests, including SWAP, CWM and Turtle test suites.
    • Supports paths, keywords, all semantic expressions.
    • No support yet for Formulae, variables, rules or automatic reification
    • Allow Triple#subject to be like an object, allowing literals and graphs
    • Allow Triple#predicate to be a BNode as well as a URIRef
  • Graph changes
    • Graph#properties(subject) returns properties of a subject expressed as a hash to arrays of objects.
    • Graph#seq(subject) returns ordered rdf:_n objects if subject is a rdf:Seq., or list of rdf:first/rdf:rest
    • Graph#qname(uri) as alternative to uri.qname, has namespaces available.
    • Graph#type_of(subject) array of RDF_TYPE objects.
    • Graph#allow_n3 (getter/setter and option) controls if extra N3 semantics for graphs are allowed. Otherwise, calls Triple#validate_rdf to raise exception
    • Real graph comparisons, including permutation search of triples containing BNodes (obviously, may be expensive)
    • Add QuotedGraph and AggregateGraph
  • Literal changes
    • Literal#== as alias to eql? Needed for sort and uniq.
    • Normalize valid typed literals
    • Added Literal#valid? to perform some content validations.
  • URIRef/Namespace changes
    • Fix URI generation, performing normalizations for normal URI refs, and not for Namespace URIs.
    • Fixed bug in URIRef#namespace & to_qname when namespace does not have a trailing / or #
    • URIRef#short_name may return a different value after a namespace is assigned.
  • Reduce dependency on Redland when running tests

RdfContext gem version 0.4.5 pushed

Posted by Gregg Kellogg Fri, 08 Jan 2010 22:11:00 GMT

Bug fixes and minor API changes:

  • Order includes to remove platform dependencies on load requirements.
  • Fix XML Comparison matcher
  • Add --store option to bin/rdf_context. Let Parser#detect_format intuit file type./li>
  • Add Graph#contents as alias to store
  • Add ConjunctiveGraph#triples to return all triples from store, not just default context
  • Add Graph#nsbinding to retreive Store#nsbinding<
  • Fix numerious SQLite3Store and AbstractSQLStore bugs. Add round-trip tests to Graph spec.

RdfContext gem released 1

Posted by Gregg Kellogg Sun, 03 Jan 2010 23:40:00 GMT

I've released version 0.4.4 of the RdfContext gem. As the name implies, RdfContext supports contextual data-stores bound to graphs, along with a ConjunctiveGraph providing the union of contexts within a given data-store.

  • Parses RDF/XML, RDFa and N3. RDF/XML and RDFa both pass all relevant W3C test cases (may be run through specs).
  • Graph and ConjunctiveGraph with pluggable data-stores. MemoryStore and SQLite3Store both support contexts as well as quoted-graphs and formulae, although no appropriate graph classes yet exist.
  • Graphs serialize to N-Triples and RDF/XML.
  • An RDF distiller runs on this site to test out different parsers. This is also useful for running automated RDFa Test Harness. 

RdfContext is based, in part on Tom Morris' Reddy gem. See the readme on GitHub for more information. MemoryStore, SQLite3Store and ConjunctiveGraph are largely ports of Python RDFLib.

RSpec soft failure for pending test cases

Posted by Gregg Kellogg Mon, 26 Oct 2009 18:40:00 GMT

 Recently, I've been playing with RSpec to run RDFa test cases. The suite has accepted and unreviewed test cases. My general way of testing is to parse the suite, and run each test through a generated spec as follows:

test_cases.each do |tc|
  specify "test #{tc.name}" do
    tc.run_test do |input|
      RdfaParser::RdfaParser.new.parse(input, tc.informationResourceInput)
    end
  end
end

The problem is, some tests are pending, so that a failure should be soft, and not hard. The way to do this is to catch Spec::Expectations::ExpectationNotMetError. This this, we can modify the above test as follows:

test_cases.each do |tc|
  specify "test #{tc.name}" do
    tc.run_test do |input|
      begin
        RdfaParser::RdfaParser.new.parse(input, tc.informationResourceInput)
      rescue Spec::Expectations::ExpectationNotMetError => e
        if tc.status == "unreviewed
          pending(e.message) {  raise }
        else
          raise
        end
      end
    end
  end
end