1RDF::Trine(3) User Contributed Perl Documentation RDF::Trine(3)
2
3
4
6 RDF::Trine - An RDF Framework for Perl
7
9 This document describes RDF::Trine version 1.019
10
12 use RDF::Trine;
13
14 my $store = RDF::Trine::Store::Memory->new();
15 my $model = RDF::Trine::Model->new($store);
16
17 # parse some web data into the model, and print the count of resulting RDF statements
18 RDF::Trine::Parser->parse_url_into_model( 'http://kasei.us/about/foaf.xrdf', $model );
19 print $model->size . " RDF statements parsed\n";
20
21 # Create a namespace object for the foaf vocabulary
22 my $foaf = RDF::Trine::Namespace->new( 'http://xmlns.com/foaf/0.1/' );
23
24 # Create a node object for the FOAF name property
25 my $pred = $foaf->name;
26 # alternatively:
27 # my $pred = RDF::Trine::Node::Resource->new('http://xmlns.com/foaf/0.1/name');
28
29 # Create an iterator for all the statements in the model with foaf:name as the predicate
30 my $iter = $model->get_statements(undef, $pred, undef);
31
32 # Now print the results
33 print "Names of things:\n";
34 while (my $st = $iter->next) {
35 my $s = $st->subject;
36 my $name = $st->object;
37
38 # $s and $name have string overloading, so will print correctly
39 print "The name of $s is $name\n";
40 }
41
43 RDF::Trine provides an Resource Descriptive Framework (RDF) with an
44 emphasis on extensibility, API stability, and the presence of a test
45 suite. The package consists of several components:
46
47 • RDF::Trine::Model - RDF model providing access to a triple store.
48 This module would typically be used to access an existing store by
49 a developer looking to "Just get stuff done."
50
51 • RDF::Trine::Parser - RDF parsers for various serialization formats
52 including RDF/XML, Turtle, RDFa, and RDF/JSON.
53
54 • RDF::Trine::Store::Memory - An in-memory, non-persistant triple
55 store. Typically used for temporary data.
56
57 • RDF::Trine::Store::DBI - A triple store for MySQL, PostgreSQL, and
58 SQLite, based on the relational schema used by Redland. Typically
59 used to for large, persistent data.
60
61 • RDF::Trine::Iterator - Iterator classes for variable bindings and
62 RDF statements, used by RDF::Trine::Store, RDF::Trine::Model, and
63 RDF::Query.
64
65 • RDF::Trine::Namespace - A convenience class for easily constructing
66 RDF::Trine::Node::Resource objects from URI namespaces.
67
69 "iri ( $iri )"
70 Returns a RDF::Trine::Node::Resource object with the given IRI
71 value.
72
73 "blank ( $id )"
74 Returns a RDF::Trine::Node::Blank object with the given identifier.
75
76 "literal ( $value, $lang, $dt )"
77 Returns a RDF::Trine::Node::Literal object with the given value and
78 optional language/datatype.
79
80 "variable ( $name )"
81 Returns a RDF::Trine::Node::Variable object with the given variable
82 name.
83
84 "statement ( @nodes )"
85 Returns a RDF::Trine::Statement object with the supplied node
86 objects.
87
88 "store ( $config )"
89 Returns a RDF::Trine::Store object based on the supplied
90 configuration string.
91
92 "default_useragent ( [ $ua ] )"
93 Returns the LWP::UserAgent object used by default for any operation
94 requiring network requests. Ordinarily, the calling code will
95 obtain the default user agent, and clone it before further
96 configuring it for a specific request, thus leaving the default
97 object untouched.
98
99 If $ua is passed as an argument, sets the global default user agent
100 to this object.
101
103 Please report any bugs or feature requests to through the GitHub web
104 interface at <https://github.com/kasei/perlrdf/issues>.
105
107 <http://www.perlrdf.org/>
108
110 Gregory Todd Williams "<gwilliams@cpan.org>"
111
113 Copyright (c) 2006-2012 Gregory Todd Williams. This program is free
114 software; you can redistribute it and/or modify it under the same terms
115 as Perl itself.
116
117
118
119perl v5.38.0 2023-07-21 RDF::Trine(3)