跳至正文

內省器/RDF/Laces

來自華夏公益教科書,面向開放世界的開放書籍

Perl 的新型 RDF::Laces 模組旨在允許在 Perl 中使用自然 perl 表示式陳述 RDF 三元組。例如,以下是都柏林核心中的前 2 個資源,用 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"))
;

該模組當前會打印出針對每條陳述所做的 ntriples。後續會有更多資訊,因為我計劃把它放在 CPAN.

華夏公益教科書