TriX Support for RDF.rb
RDF::TriX parses TriX into statements or quads. It also serializes to TriX.
gem install rdf-trix
- 100% free and unencumbered public domain software.
- Implements a complete parser and serializer for TriX.
- Compatible with Ruby >= 3.0, and JRuby 9+.
Support for xml:base
The TriX reader natively supports
xml:base in the top-level element without the need for an XSLT. This allows values of a
uri element to be relative URIs and resolved against that base. The base can also be specified as an option to the reader.
<TriX xmlns="http://www.w3.org/2004/03/trix/trix-1/" xml:base="http://example.org/"> <graph> <uri>graph1</uri> <triple> <uri>Bob</uri> <uri>wife</uri> <uri>Mary</uri> </triple> <triple> <uri>Bob</uri> <uri>name</uri> <plainLiteral>Bob</plainLiteral> </triple> <triple> <uri>Mary</uri> <uri>age</uri> <typedLiteral datatype="http://www.w3.org/2001/XMLSchema#integer">32</typedLiteral> </triple> </graph> </TriX>
Both reader and writer include provisional support for RDF-star.
RDF::Statement is treated as another resource, along with
RDF::Node, which allows an
RDF::Statement to have a
#object which is also an
RDF-star is supported by allowing a
triple element to contain another
triple as either or both the subject or object.
Note that this requires the
rdfstar option to be se.
Note: This feature is subject to change or elimination as the standards process progresses.
<TriX xmlns="http://www.w3.org/2004/03/trix/trix-1/"> <graph> <triple> <triple> <uri>http://example/s1</uri> <uri>http://example/p1</uri> <uri>http://example/o1</uri> </triple> <uri>http://example/p</uri> <uri>http://example/o</uri> </triple> </graph> </TriX>
Instantiate a reader from a local file:
repo = ::.("etc/doap.trix", :format => :trix)
@prefix definitions, and use for serialization using
Canonicalize and validate using
Write a repository to a file:
::::.("etc/test.trix") do |writer| writer << repo end
The recommended installation method is via RubyGems.
To install the latest official release of the
RDF::TriX gem, do:
% [sudo] gem install rdf-trix
To get a local working copy of the development repository, do:
% git clone git://github.com/ruby-rdf/rdf-trix.git
Alternatively, download the latest development version as a tarball as follows:
% wget https://github.com/ruby-rdf/rdf-trix/tarball/master
Refer to the accompanying CREDITS file.
This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.
- Do your best to adhere to the existing coding conventions and idioms.
- Don't use hard tabs, and don't leave trailing whitespace on any line.
Before committing, run
git diff --checkto make sure of this.
- Do document every method you add using [YARD] annotations. Read the [tutorial][YARD-GS] or just look at the existing code for examples.
- Don't touch the
VERSIONfiles. If you need to change them, do so on your private branch only.
- Do feel free to add yourself to the
CREDITSfile and the corresponding list in the the
README. Alphabetical order applies.
- Don't touch the
AUTHORSfile. If your contributions are significant enough, be assured we will eventually add you in there.
- Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you, which you will be asked to agree to on the first commit to a repo within the organization. Note that the agreement applies to all repos in the Ruby RDF organization.