跳至正文

内省器/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.

华夏公益教科书