RDF::RDFa reader/writer

RDFa parser for RDF.rb.

DESCRIPTION

RDF::RDFa is an RDFa reader and writer for Ruby using the RDF.rb library suite.

FEATURES

RDF::RDFa parses RDFa into statements or triples.

Install with 'gem install rdf-rdfa'

Usage

Reading RDF data in the RDFa format

RDF::RDFa::Reader.open("etc/foaf.html") do |reader|
  reader.each_statement do |statement|
    puts statement.inspect
  end
end

Writing RDF data using the XHTML+RDFa format

require 'rdf/rdfa'

RDF::RDFa::Writer.open("hello.html") do |writer|
  writer << RDF::Graph.new do |graph|
    graph << [:hello, RDF::DC.title, "Hello, world!"]
  end
end

Note that prefixes may be chained between Reader and Writer, so that the Writer will use the same prefix definitions found during parsing:

prefixes = {}
graph = RDF::Graph.load("etc/foaf.html", :prefixes => prefixes)
puts graph.dump(:rdfa, :prefixes => prefixes)

Template-based Writer

The RDFa writer uses Haml templates for code generation. This allows fully customizable RDFa output in a variety of host languages. The RDF::RDFa::Writer::DEFAULT_HAML">default template generates human readable HTML5 output. A RDF::RDFa::Writer::MIN_HAML">minimal template generates HTML, which is not intended for human consumption.

To specify an alternative Haml template, consider the following:

require 'rdf/rdfa'

RDF::RDFa::Writer.buffer(:haml => RDF::RDFa::Writer::MIN_HAML) << graph

The template hash defines four Haml templates:

Dependencies

Documentation

Full documentation available on RubyForge

Principle Classes

Additional vocabularies

TODO

Resources

Author

Contributors

Contributing

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

FEEDBACK