.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 .\" ======================================================================== .\" .IX Title "RDF::Trine::Parser::Notation3 3pm" .TH RDF::Trine::Parser::Notation3 3pm 2024-03-07 "perl v5.38.2" "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::Trine::Parser::Notation3 \- Notation 3 Parser .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& use RDF::Trine::Parser; \& my $parser = RDF::Trine::Parser\->new( \*(AqNotation3\*(Aq ); \& $parser\->parse_into_model( $base_uri, $data, $model ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides a Notation 3 parser for RDF::Trine. .SS Methods .IX Subsection "Methods" This package exposes the standard RDF::Trine::Parser methods, plus: .ie n .IP forAll($handler) 4 .el .IP \f(CWforAll($handler)\fR 4 .IX Item "forAll($handler)" Sets a callback handler for \f(CW@forAll\fR directives found in the top-level graph. (@forAll found in nested formulae will not be passed to this callback.) .Sp The handler should be a coderef that takes a single argument: an RDF::Trine::Node::Resource. .Sp If you do not set a handler, a warning will be issued when this directive are encountered in the top level graph, but parsing will continue. .ie n .IP forSome($handler) 4 .el .IP \f(CWforSome($handler)\fR 4 .IX Item "forSome($handler)" As \f(CW\*(C`forAll\*(C'\fR but handles \f(CW@forSome\fR directives. .ie n .IP """parse_formula($base, $input)""" 4 .el .IP "\f(CWparse_formula($base, $input)\fR" 4 .IX Item "parse_formula($base, $input)" Returns an RDF::Trine::Node::Formula object representing the Notation 3 formula given as \f(CW$input\fR. \f(CW$input\fR should not include the "{"..."}" wrappers. .SS "Datatype Callbacks" .IX Subsection "Datatype Callbacks" The constructor accepts a hashref of callbacks associated with datatypes, which will be triggered after a literal has been parsed with that datatype. Let's imagine that you want to replace all xsd:integer literals with URIs like \f(CW\*(C`http:;//example.net/numbers/123\*(C'\fR... .PP .Vb 10 \& my $parser = RDF::Trine::Parser::Notation3\->new( \& datatype_callback => { \& \*(Aqhttp://www.w3.org/2001/XMLSchema#integer\*(Aq => sub { \& my ($lit, $tr_hnd) = @_; \& return RDF::Trine::Node::Resource\->new( \& \*(Aqhttp:;//example.net/numbers/\*(Aq . $lit\->literal_value \& ); \& }, \& }, \& ); .Ve .PP Note the second argument passed to the callback \f(CW$tr_hnd\fR. We don't use it here, but it's a coderef that can be called with RDF::Trine::Statement objects to add additional triples to the graph being parsed. .PP This facility, combined with shortcuts from RDF::Trine::Parser::ShorthandRDF is pretty useful for creating domain-specific languages. .SH BUGS .IX Header "BUGS" Please report any bugs to . .SH "SEE ALSO" .IX Header "SEE ALSO" RDF::Trine::Parser::NTriples, RDF::Trine::Parser::Turtle, RDF::Trine::Parser::ShorthandRDF. .SH AUTHOR .IX Header "AUTHOR" Toby Inkster \f(CW\*(C`\*(C'\fR .PP Based on RDF::Trine::Parser::Turtle by Gregory Todd Williams. .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" Copyright (c) 2006\-2010 Gregory Todd Williams. .PP Copyright (c) 2010\-2012 Toby Inkster. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.