Introspector/RDF/Laces

From Wikibooks, open books for an open world
< Introspector
Jump to: navigation, search

The new RDF::Laces module for Perl is designed to allow the statement of RDF triples in Perl using natural perl expressions. For example, here are the first 2 resources from the Dublin Core, in Perl:

$doc
   ->dc
       ->title("The Dublin Core Element Set v1.1 namespace providing access to its content by means of an RDF Schema")
       ->publisher("The Dublin Core Metadata Initiative")
       ->description("The Dublin Core Element Set v1.1 namespace provides URIs for the Dublin Core Elements v1.1. Entries are declared using RDF Schema language to support RDF applications.")
       ->language("English")
       ->source(
           $doc->("http://dublincore.org/documents/dces/"),
           $doc->("http://dublincore.org/usage/decisions/"))
   ->dcterms
       ->issued("1999-07-02")
       ->modified("2003-03-24")
       ->isReferencedBy($doc->("http://www.dublincore.org/documents/2001/10/26/dcmi-namespace/"))
       ->isRequiredBy($doc->("http://purl.org/dc/terms/"))
       ->isReferencedBy($doc->("http://purl.org/dc/dcmitype/"))
->{title}
   ->rdfs
       ->label("Title")
       ->comment("A name given to the resource.")
       ->isDefinedBy($doc)
   ->dc
       ->description("Typically, a Title will be a name by which the resource is formally known.")
       ->type($doc->("http://dublincore.org/usage/documents/principles/#element"))
   ->dcterms
       ->issued("1999-07-02")
       ->modified("2002-10-04")
       ->hasVersion($doc->("http://dublincore.org/usage/terms/history/#title-004"))
;

The module currently prints out the ntriples for every statement made. More info will be forthcoming, as I'm planning to put it on CPAN.