1RDF::Trine::Parser::NotUasteironC3o(n3t)ributed Perl DocRuDmFe:n:tTartiinoen::Parser::Notation3(3)
2
3
4
6 RDF::Trine::Parser::Notation3 - Notation 3 Parser
7
9 use RDF::Trine::Parser;
10 my $parser = RDF::Trine::Parser->new( 'Notation3' );
11 $parser->parse_into_model( $base_uri, $data, $model );
12
14 This module provides a Notation 3 parser for RDF::Trine.
15
16 Methods
17 This package exposes the standard RDF::Trine::Parser methods, plus:
18
19 forAll($handler)
20 Sets a callback handler for @forAll directives found in the top-
21 level graph. (@forAll found in nested formulae will not be passed
22 to this callback.)
23
24 The handler should be a coderef that takes a single argument: an
25 RDF::Trine::Node::Resource.
26
27 If you do not set a handler, a warning will be issued when this
28 directive are encountered in the top level graph, but parsing will
29 continue.
30
31 forSome($handler)
32 As "forAll" but handles @forSome directives.
33
34 "parse_formula($base, $input)"
35 Returns an RDF::Trine::Node::Formula object representing the
36 Notation 3 formula given as $input. $input should not include the
37 "{"..."}" wrappers.
38
39 Datatype Callbacks
40 The constructor accepts a hashref of callbacks associated with
41 datatypes, which will be triggered after a literal has been parsed with
42 that datatype. Let's imagine that you want to replace all xsd:integer
43 literals with URIs like "http:;//example.net/numbers/123"...
44
45 my $parser = RDF::Trine::Parser::Notation3->new(
46 datatype_callback => {
47 'http://www.w3.org/2001/XMLSchema#integer' => sub {
48 my ($lit, $tr_hnd) = @_;
49 return RDF::Trine::Node::Resource->new(
50 'http:;//example.net/numbers/' . $lit->literal_value
51 );
52 },
53 },
54 );
55
56 Note the second argument passed to the callback $tr_hnd. We don't use
57 it here, but it's a coderef that can be called with
58 RDF::Trine::Statement objects to add additional triples to the graph
59 being parsed.
60
61 This facility, combined with shortcuts from
62 RDF::Trine::Parser::ShorthandRDF is pretty useful for creating domain-
63 specific languages.
64
66 Please report any bugs to
67 <http://rt.cpan.org/Dist/Display.html?Queue=RDF-TriN3>.
68
70 RDF::Trine::Parser::NTriples, RDF::Trine::Parser::Turtle,
71 RDF::Trine::Parser::ShorthandRDF.
72
74 Toby Inkster "<tobyink@cpan.org>"
75
76 Based on RDF::Trine::Parser::Turtle by Gregory Todd Williams.
77
79 Copyright (c) 2006-2010 Gregory Todd Williams.
80
81 Copyright (c) 2010-2012 Toby Inkster.
82
83 This library is free software; you can redistribute it and/or modify it
84 under the same terms as Perl itself.
85
87 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
88 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
89 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
90
91
92
93perl v5.38.0 2023-07-21 RDF::Trine::Parser::Notation3(3)