.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RDF::Lazy 3pm" .TH RDF::Lazy 3pm "2019-02-20" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RDF::Lazy \- Lazy typing access to RDF data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& ### How to create a graph \& \& $g = RDF::Lazy\->new( \& rdf => $data, # RDF::Trine::Model or ::Store (by reference) \& namespaces => { # namespace prefix, RDF::NS or RDF::Trine::NamespaceMap \& foaf => \*(Aqhttp://xmlns.com/foaf/0.1/\*(Aq, \& rdf => "http://www.w3.org/1999/02/22\-rdf\-syntax\-ns#", \& xsd => "http://www.w3.org/2001/XMLSchema#", \& } \& ); \& \& $g = RDF::Lazy\->new( $data, format => \*(Aqturtle\*(Aq ); # parse RDF/Turtle \& $g = RDF::Lazy\->new( $data, format => \*(Aqrdfxml\*(Aq ); # parse RDF/XML \& $g = RDF::Lazy\->new( "http://example.org/" ); # retrieve LOD \& \& ### How to get nodes \& \& $p = $g\->resource(\*(Aqhttp://xmlns.com/foaf/0.1/Person\*(Aq); # get node \& $p = $g\->uri(\*(Aq\*(Aq); # alternatively \& $p = $g\->uri(\*(Aqfoaf:Person); # same but lazier \& $p = $g\->foaf_Person; # same but laziest \& \& $l = $g\->literal(\*(AqAlice\*(Aq); # get literal node \& $l = $g\->literal(\*(AqAlice\*(Aq,\*(Aqen\*(Aq); # get literal node with language \& $l = $g\->literal(\*(Aq123\*(Aq,\*(Aqxsd:integer\*(Aq); # get literal node with datatype \& \& $b = $g\->blank(\*(Aqx123\*(Aq); # get blank node \& $b = $g\->blank; # get blank node with random id \& \& ### How to retrieve RDF \& \& $x\->rel(\*(Aqfoaf:knows\*(Aq); # retrieve a person that $x knows \& $x\->rev(\*(Aqfoaf:knows\*(Aq); # retrieve a person known by $x \& \& $x\->rels(\*(Aqfoaf:knows\*(Aq); # retrieve all people that $x knows \& $x\->revs(\*(Aqfoaf:knows\*(Aq); # retrieve all people known by $x \& \& $x\->foaf_knows; # short form of $x\->rel(\*(Aqfoaf:knows\*(Aq) \& $x\->foaf_knows_; # short form of $x\->rels(\*(Aqfoaf:knows\*(Aq) \& \& $x\->rels; # array reference with a list of properties \& $x\->revs; # same as rels, but other direction \& \& $x\->type; # same as $x\->rel(\*(Aqrdf:type\*(Aq) \& $x\->types; # same as $x\->rels(\*(Aqrdf:type\*(Aq) \& \& $g\->subjects( \*(Aqrdf:type\*(Aq, \*(Aqfoaf:Person\*(Aq ); # retrieve subjects \& $g\->predicates( $subject, $object ); # list predicates \& $g\->objects( $subject, \*(Aqfoaf:knows\*(Aq ); # list objects \& \& ### How to add RDF \& \& $g\->add( $rdfdata, format => \*(Aqrdfxml\*(Aq ); # parse and add \& $g\->add( $subject, $predicate, $object ); # add single triple \& \& ### How to show RDF \& \& $g\->turtle; # dump in RDF/Turtle syntax \& $g\->ttlpre; # dump in RDF/Turtle, wrapped in a HTML
 tag
\&  $g\->rdfxml;  # dump in RDF/XML
\&  $g\->rdfjson; # dump in RDF/JSON
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module wraps RDF::Trine::Node to provide simple node-centric access to
\&\s-1RDF\s0 data. It was designed to access \s-1RDF\s0 within Template Toolkit but the
module does not depend on or and can be used independently. Basically, an
instance of RDF::Lazy contains an unlabeled \s-1RDF\s0 graph and a set of namespace
prefixes. For lazy access and graph traversal, each \s-1RDF\s0 node
(RDF::Lazy::Node) is tied to the graph.
.SH "METHODS"
.IX Header "METHODS"
.ie n .SS "cache( [ $cache ] )"
.el .SS "cache( [ \f(CW$cache\fP ] )"
.IX Subsection "cache( [ $cache ] )"
Get and/or set a cache for loading \s-1RDF\s0 from URIs or URLs. A \f(CW$cache\fR can be
any blessed object that supports method \f(CW\*(C`get($uri)\*(C'\fR and \f(CW\*(C`set($uri,$value)\*(C'\fR.
For instance one can enable a simple file cache with \s-1CHI\s0 like this:
.PP
.Vb 6
\&    my $rdf = RDF::Lazy\->new(
\&        cache => CHI\->new(
\&            driver => \*(AqFile\*(Aq, root_dir => \*(Aq/tmp/cache\*(Aq,
\&            expires_in => \*(Aq1 day\*(Aq
\&        )
\&    );
.Ve
.PP
By default, \s-1RDF\s0 is stored in Turtle syntax for easy inspection.
.ie n .SS "load( $uri )"
.el .SS "load( \f(CW$uri\fP )"
.IX Subsection "load( $uri )"
Load \s-1RDF\s0 from an \s-1URI\s0 or \s-1URL. RDF\s0 data is optionally retrieved from a cache.
Returns the number of triples that have been added (which could be zero if
all loaded triples are duplicates).
.ie n .SS "new ( [ [ rdf => ] $rdf ] [, namespaces => $namespaces ] [ %options ])"
.el .SS "new ( [ [ rdf => ] \f(CW$rdf\fP ] [, namespaces => \f(CW$namespaces\fP ] [ \f(CW%options\fP ])"
.IX Subsection "new ( [ [ rdf => ] $rdf ] [, namespaces => $namespaces ] [ %options ])"
Return new \s-1RDF\s0 graph. Namespaces can be provided as hash reference or as
RDF::Trine::NamespaceMap or \s-1RDF::NS\s0. By default, the current local
version of \s-1RDF::NS\s0 is used.  \s-1RDF\s0 data can be  or
RDF::Trine::Store, which are used by reference, or many other forms, as
supported by add.
.ie n .SS "resource ( $uri )"
.el .SS "resource ( \f(CW$uri\fP )"
.IX Subsection "resource ( $uri )"
Return RDF::Lazy::Resource node. The following statements are equivalent:
.PP
.Vb 2
\&    $graph\->resource(\*(Aqhttp://example.org\*(Aq);
\&    $graph\->uri(\*(Aq\*(Aq);
.Ve
.ie n .SS "literal ( $string , $language_or_datatype, $datatype )"
.el .SS "literal ( \f(CW$string\fP , \f(CW$language_or_datatype\fP, \f(CW$datatype\fP )"
.IX Subsection "literal ( $string , $language_or_datatype, $datatype )"
Return RDF::Lazy::Literal node.
.ie n .SS "blank ( [ $identifier ] )"
.el .SS "blank ( [ \f(CW$identifier\fP ] )"
.IX Subsection "blank ( [ $identifier ] )"
Return RDF::Lazy::Blank node. A random identifier is generated unless you
provide an identifier as parameter.
.ie n .SS "uri ( $name | $node )"
.el .SS "uri ( \f(CW$name\fP | \f(CW$node\fP )"
.IX Subsection "uri ( $name | $node )"
Returns a node that is connected to the graph. Note that every valid \s-1RDF\s0 node
is part of any \s-1RDF\s0 graph: this method does not check whether the graph actually
contains a triple with the given node. You can either pass a name or an
instance of RDF::Trine::Node. This method is also called for any undefined
method, so the following statements are equivalent:
.PP
.Vb 2
\&    $graph\->true;
\&    $graph\->uri(\*(Aqtrue\*(Aq);
.Ve
.SS "rel / rels / rev / revs"
.IX Subsection "rel / rels / rev / revs"
Can be used to traverse the graph. See RDF::Lazy::Node:
.PP
.Vb 2
\&    $node\->rel( ... )           # where $node is located in $graph
\&    $graph\->rel( $node, ... )   # equivalent
.Ve
.SS "add"
.IX Subsection "add"
Add \s-1RDF\s0 data. \fISorry, not documented yet!\fR
.ie n .SS "ttl ( [ $node ] )"
.el .SS "ttl ( [ \f(CW$node\fP ] )"
.IX Subsection "ttl ( [ $node ] )"
Returns a RDF/Turtle representation of a node's bounded description.
.ie n .SS "ttlpre ( [ $node ] )"
.el .SS "ttlpre ( [ \f(CW$node\fP ] )"
.IX Subsection "ttlpre ( [ $node ] )"
Returns an \s-1HTML\s0 escaped RDF/Turtle representation of a node's bounded
description, wrapped in a \s-1HTML\s0 \f(CW\*(C`
\*(C'\fR element.
.ie n .SS "ns ( $prefix | $namespace | $prefix => $namespace )"
.el .SS "ns ( \f(CW$prefix\fP | \f(CW$namespace\fP | \f(CW$prefix\fP => \f(CW$namespace\fP )"
.IX Subsection "ns ( $prefix | $namespace | $prefix => $namespace )"
Gets or sets a namespace mapping for the entire graph. By default, RDF::Lazy
makes use of popular namespaces defined in \s-1RDF::NS\s0.
.PP
.Vb 3
\&   $g\->ns(\*(Aqdc\*(Aq);   # returns \*(Aqhttp://purl.org/dc/elements/1.1/\*(Aq
\&   $g\->ns(\*(Aqhttp://purl.org/dc/elements/1.1/\*(Aq);  # returns \*(Aqdc\*(Aq
\&   $g\->ns( dc => \*(Aqhttp://example.org/\*(Aq );       # modify mapping
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
RDF::Helper and RDF::TrineShortcuts provide similar APIs. Another similar framework
for \s-1PHP\s0 and Python is Graphite: http://graphite.ecs.soton.ac.uk/,
http://code.google.com/p/python\-graphite/.
.SH "AUTHOR"
.IX Header "AUTHOR"
Jakob Vo\*8 
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2013 by Jakob Vo\*8.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.