RDF::T...r::RDFa(3pm)

✨ RDF::TrineX::Parser::RDFa ✨

okay bestie, gather round 🫢 this is the User Contributed Perl Documentation page for RDF::TrineX::Parser::RDFa, and honestly? it's a glow-up story.


🌸 NAME 🌸

RDF::TrineX::Parser::RDFa β€” an RDF::Trine::Parser-compatible interface for RDF::RDFa::Parser. no cap, that's the whole vibe.


πŸ’… DESCRIPTION πŸ’…

So like... RDF::RDFa::Parser is a genuinely good RDFa parser. iconic behavior. BUT. its interface is a tad... shall we say... crufty. πŸ™ˆ

RDF::TrineX::Parser::RDFa swoops in with a much nicer interface, and β€” this is the main character detail β€” it's a subclass of RDF::Trine::Parser, so you get super-polymorphic benefits. Yay! πŸŽ€

🧚 Class Method

  • parse_url_into_model($url, $model, %args) β€” just like the method of the same name in RDF::Trine::Parser: it grabs the URL and parses it into a model. BUT (and this is the twist) unlike RDF::Trine::Parser, this one always assumes you're trying to parse some variety of RDFa. no guessing games, periodt.

πŸŽ€ Constructor

  • new(%options) β€” constructs a brand new RDF::TrineX::Parser::RDFa parser. fresh out the box πŸ’–

The two important options are flavour (which defaults to 'xhtml') and version (which defaults to '1.1'). Every other option is documented over in RDF::RDFa::Parser::Config.

Let's imagine you wanna parse RDFa 1.1 in HTML5, and you also wanna parse the "role", "longdesc" and "cite" attibutes (which are not strictly part of RDFa, but nevertheless often interesting β€” lowkey juicy, honestly). Then you'd use:

my $parser = RDF::TrineX::Parser::RDFa->new(
  flavour        => 'html5',
  version        => '1.1',
  role_attr      => 1,
  longdesc_attr  => 1,
  cite_attr      => 1,
);

🌈 Object Methods

The following methods are supported, exactly as documented in RDF::Trine::Parser:

  • parse_into_model($base_uri, $data, $model [,context => $context])
  • parse($base_uri, $data, \&handler)
  • parse_file_into_model($base_uri, $fh, $model [,context => $context])
  • parse_file($base_uri, $fh, \&handler)

And the following additional methods are supported too:

  • rdfa_flavour β€” returns the RDFa host language being used. πŸ¦‹
  • rdfa_version β€” returns the RDFa version number being used. ⭐

πŸ‘‘ Subclasses

The following subclasses of RDF::TrineX::Parser::RDFa exist:

  • RDF::TrineX::Parser::XHTML_RDFa10
  • RDF::TrineX::Parser::HTML32_RDFa10
  • RDF::TrineX::Parser::HTML4_RDFa10
  • RDF::TrineX::Parser::HTML5_RDFa10
  • RDF::TrineX::Parser::XHTML5_RDFa10
  • RDF::TrineX::Parser::Atom_RDFa10
  • RDF::TrineX::Parser::DataRSS_RDFa10
  • RDF::TrineX::Parser::SVG_RDFa10
  • RDF::TrineX::Parser::XML_RDFa10
  • RDF::TrineX::Parser::OpenDocument_RDFa10
  • RDF::TrineX::Parser::XHTML_RDFa11
  • RDF::TrineX::Parser::HTML32_RDFa11
  • RDF::TrineX::Parser::HTML4_RDFa11
  • RDF::TrineX::Parser::HTML5_RDFa11
  • RDF::TrineX::Parser::XHTML5_RDFa11
  • RDF::TrineX::Parser::Atom_RDFa11
  • RDF::TrineX::Parser::DataRSS_RDFa11
  • RDF::TrineX::Parser::SVG_RDFa11
  • RDF::TrineX::Parser::XML_RDFa11
  • RDF::TrineX::Parser::OpenDocument_RDFa11

By using these classes, you can skip the need to pass the 'flavour' and 'version' options to the constructor. the way that saves you two whole lines... obsessed. For example:

my $parser = RDF::TrineX::Parser::HTML5_RDFa11->new(
  role_attr      => 1,
  longdesc_attr  => 1,
  cite_attr      => 1,
);
⚠️ real talk bestie: note that these are classes, but they are not modules. You should not attempt to load them with require or use. do not do it. i'm begging. πŸ’€

πŸ”₯ SEE ALSO πŸ”₯


🫢 AUTHOR 🫢

Toby Inkster <tobyink@cpan.org>.


Copyright 2012 Toby Inkster

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


😭 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.


and that's the whole page, bestie 🌸 this one came from perl v5.32.1, dated 2021-09-11, and it's filed as RDF::T...r::RDFa(3pm) β€” iykyk. go parse something cute πŸ’…βœ¨

πŸ“¦ where this page comes from