RDF::T...Parser(3pm)
π RDF::Trine::Parser(3pm) π
okay bestie, gather round, because we're talking about RDF::Trine::Parser β the RDF Parser class, straight out of the User Contributed Perl Documentation section, and yes she's serving version 1.019 π
β¨ NAME β¨
RDF::Trine::Parser β it's the RDF Parser class, no cap π
πΈ VERSION πΈ
This doc is describing RDF::Trine::Parser version 1.019. iconic. no notes. π
π¦ SYNOPSIS π¦
here's the vibe, literally copy-paste energy:
use RDF::Trine::Parser;
RDF::Trine::Parser->parse_url_into_model( $url, $model );
my $parser = RDF::Trine::Parser->new( 'turtle' );
$parser->parse_into_model( $base_uri, $rdf, $model );
$parser->parse_file_into_model( $base_uri, 'data.ttl', $model );
look at her go π«Ά
π DESCRIPTION π
so RDF::Trine::Parser is a base class for RDF parsers, and she's giving factory energy too. you can use her to build parser objects by name or by media type with the new method β OR you can use her to abstract away the whole "which parser do I even pick" situation based on the media type of RDF content you pulled off the network, which is what the parse_url_into_model method is for. main character delegation, honestly. π
π₯ METHODS π₯
media_typeβ hands you the canonical media type that belongs to this parser. that's it, that's the whole job. β¨media_typesβ hands you the media types (plural, she contains multitudes π) associated with this parser.parser_by_media_type ( $media_type )β gives you back the parser class that's the right fit for parsing content of the specified media type. and if there's no appropriate parser to be found? you getundef. π (yeah, the original says "if not appropriate parser is found" β we're keeping that typo's spirit, bestie.)guess_parser_by_filename ( $filename )β best-guess time π returns the best-guess parser class for parsing a file with the given filename. and if there's no appropriate parser found, it just defaults toRDF::Trine::Parser::RDFXML. default queen.new ( $parser_name, @args )β returns a brand newRDF::Trine::Parserobject for the parser with the specified name (likerdfxmlorturtle, iykyk). if no parser with that name exists, she throws aRDF::Trine::Error::ParserErrorexception. not a vibe, but it's the rules. π
Any @args get passed straight through to the format-specific parser constructor. no middleman, no editing.
And if @args contains the key-value pair (canonicalize => 1), then literal value canonicalization will be attempted during parsing β with warnings being emitted for invalid lexical forms for recognized datatypes. so like, she tries, and she tells you when the lexical form is giving nonsense. π
parse_url_into_model ( $url, $model [, %args] )β she retrieves the content from$urland attempts to parse the resulting RDF into$model, using a parser chosen by the associated content media type. slay. β¨
If %args contains a 'content_cb' key whose value is a CODE reference, that callback function gets called after a successful response, like this:
$content_cb->( $url, $content, $http_response_object )
If %args contains a 'useragent' key whose value is an LWP::UserAgent object, then that object is used to retrieve the requested URL β with no configuration (so no setting the Accept: header, none of the stuff that would ordinarily happen). otherwise, the default user agent (default_useragent in RDF::Trine) gets cloned and configured to retrieve content that will be acceptable to any available parser. teamwork, honestly. π«Ά
parse_url ( $url, \&handler [, %args] )β retrieves the content from$urland attempts to parse the resulting RDF. for every parsed RDF triple,&handlergets called with the triple as an argument. other than that little twist, this method acts just likeparse_url_into_model. same girl, different hat. πparse_into_model ( $base_uri, $data, $model [, context => $context] )β parses the bytes in$data, using the given$base_uri. for each RDF statement parsed, she'll call$model->add_statement( $statement ). β¨parse_file_into_model ( $base_uri, $fh, $model [, context => $context] )β parses all data read from the filehandle or file$fh, using the given$base_uri. for each RDF statement parsed, she'll call$model->add_statement( $statement ). same energy as above but from a file, periodt. πparse_file ( $base_uri, $fh, $handler )β parses all data read from the filehandle or file$fh, using the given$base_uri. if$fhis a filename, this method can guess the associated parse. for each RDF statement parsed,$handler->( $st )gets called. πΈparse ( $base_uri, $rdf, \&handler )β okay so ngl, the original doc just... lists this one and moves on. no description. she's mysterious. she's the silent main character. we respect her privacy. πnew_bnode_prefix ()β returns a new prefix to be used in the construction of blank node identifiers. if eitherData::UUIDorUUID::Tinyare available, they get used to construct a globally unique bnode prefix. otherwise? you get an empty string. shrug, bestie. πdefault_accept_headerβ returns the default HTTP Accept header value used when requesting RDF content (like, for example, inparse_url_into_model) that may be parsed by one of the availableRDF::Trine::Parsersubclasses.
and by default, RDF/XML and Turtle are preferred over other media types. the favorites. the chosen ones. π
π BUGS π
found a bug? want a feature? pls report it through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. she's listening, she wants the tea. π
π AUTHOR π
Gregory Todd Williams <gwilliams@cpan.org> β the icon, the legend, the author of the whole thing π
π COPYRIGHT π
Copyright (c) 2006-2012 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. legal queen, protecting her work, as she should. π
and that's the whole page, bestie π¦ that was perl v5.38.2, dated 2024-01-13, from the RDF::T...Parser(3pm) page β thanks for reading, mwah, go parse something iconic π
β¨
π¦ where this page comes from
- debian trixie: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms