Debian Codegraph @

README

raw
1 NAME
2
3 RDF::aREF - Another RDF Encoding Form
4
5 SYNOPSIS
6
7 use RDF::aREF;
8
9 my $rdf = {
10 _id => 'http://example.com/people#alice',
11 foaf_name => 'Alice Smith',
12 foaf_age => '42^xsd_integer',
13 foaf_homepage => [
14 {
15 _id => 'http://personal.example.org/',
16 dct_modified => '2010-05-29^xsd_date',
17 },
18 'http://work.example.com/asmith/',
19 ],
20 foaf_knows => {
21 dct_description => 'a nice guy@en',
22 },
23 };
24
25 decode_aref( $rdf,
26 callback => sub {
27 my ($subject, $predicate, $object, $language, $datatype) = @_;
28 ...
29 }
30 );
31
32 my @lastmod = aref_query $rdf, 'foaf_homepage.dct_modified^';
33
34 my $model = RDF::Trine::Model->new;
35 decode_aref( $rdf, callback => $model );
36 print RDF::Trine::Serializer->new('Turtle')->serialize_model_to_string($model);
37
38 my $model = RDF::Trine::Model->new;
39 RDF::Trine::Parser->parse_url_into_model($url, $model);
40 my $aref = encode_aref $model;
41
42 DESCRIPTION
43
44 aREF (another RDF Encoding Form <http://gbv.github.io/aREF/>) is an
45 encoding of RDF graphs in form of arrays, hashes, and Unicode strings.
46 This module provides methods for decoding from aREF data to RDF triples
47 (RDF::aREF::Decoder), for encoding RDF data in aREF
48 (RDF::aREF::Encoder), and for querying parts of an RDF graph
49 (RDF::aREF::Query).
50
51 WARNING
52
53 aREF has been an attempt to solve problems that meanwhile have largely
54 been solved by JSON-LD <https://json-ld.org/>. Despite aRef having its
55 own benefits, please consider using a more established technology
56 (JSON-LD) instead!
57
58 EXPORTED FUNCTIONS
59
60 The following functions are exported by default.
61
62 decode_aref $aref [, %options ]
63
64 Decodes an aREF document given as hash reference with
65 RDF::aREF::Decoder. Equivalent to
66 RDF::aREF::Decoder->new(%options)->decode($aref).
67
68 encode_aref $graph [, %options ]
69
70 Construct an aREF subject mapfrom an RDF graph. The RDF::aREF::Encoder
71 for possible options. The $graph can be supplied as:
72
73 * instance of RDF::Trine::Model
74
75 * instance of RDF::Trine::Model::Iterator
76
77 * an URL or a filename (only if RDF::Trine is installed)
78
79 * instance of Attean::API::TripleIterator (experimental)
80
81 * instance of Attean::API::TripleStore (experimental)
82
83 * hash reference with RDF/JSON <http://www.w3.org/TR/rdf-json/>
84 format (as returned by method as_hashref in RDF::Trine::Model)
85
86 aref_query $graph, [ $origin ], @queries
87
88 Query parts of an aREF data structure by aREF query expressions
89 <http://gbv.github.io/aREF/aREF.html#aref-query> and return a list. See
90 RDF::aREF::Query for details.
91
92 aref_query_map( $graph, [ $origin ], $query_map )
93
94 Map parts of an aREF data structure to a flat key-value structure.
95
96 SEE ALSO
97
98 * aREF is specified at http://github.com/gbv/aREF.
99
100 * See Catmandu::RDF for an application of this module.
101
102 * Usee RDF::Trine for more elaborated handling of RDF data in Perl.
103
104 * See RDF::YAML for a similar (outdated) RDF encoding in YAML.
105
106 COPYRIGHT AND LICENSE
107
108 Copyright Jakob Voss, 2014-
109
110 This library is free software; you can redistribute it and/or modify it
111 under the same terms as Perl itself.
112