RDF::R...:Config(3pm)

πŸ’– NAME πŸ’–

okay so this is RDF::RDFa::Parser::Config β€” it's the module that hands you configuration sets for the RDFa parser. that's it, that's the vibe. πŸŽ€

✨ DESCRIPTION ✨

bestie, listen. when you build an RDF::RDFa::Parser object, the third argument you pass to the constructor is a configuration set. and guess what β€” this module is where those configuration sets come from. πŸ¦‹

why do they even exist? because the parser has to know how to handle certain features, and those features vary depending on which host language you're in or which RDFa version you're doing. so like, it needs the tea. πŸ’…

the constructor (the only thing you truly need)

$config = RDF::RDFa::Parser::Config->new($host, $version, %options);

$host is the host language. you'd normally pass one of these constants β€” and the default is HOST_XHTML. internet media types are accepted too (like 'text/html' or 'image/svg+xml'), but ngl it's usually better to use a constant, because some media types are shared (HTML4 and HTML5 both use the same media type, iykyk).

  • RDF::RDFa::Parser::Config->HOST_ATOM
  • RDF::RDFa::Parser::Config->HOST_DATARSS
  • RDF::RDFa::Parser::Config->HOST_HTML32
  • RDF::RDFa::Parser::Config->HOST_HTML4
  • RDF::RDFa::Parser::Config->HOST_HTML5
  • RDF::RDFa::Parser::Config->HOST_OPENDOCUMENT_XML β€” flat XML, so like "FODT", "FODS", etc
  • RDF::RDFa::Parser::Config->HOST_OPENDOCUMENT_ZIP β€” the zipped ones, "ODT", "ODS", etc
  • RDF::RDFa::Parser::Config->HOST_SVG
  • RDF::RDFa::Parser::Config->HOST_XHTML
  • RDF::RDFa::Parser::Config->HOST_XHTML5
  • RDF::RDFa::Parser::Config->HOST_XML

$version is the RDFa version. again, you'd generally supply one of these constants, and the default is RDFA_LATEST. πŸ‘‘

  • RDF::RDFa::Parser::Config->RDFA_10
  • RDF::RDFa::Parser::Config->RDFA_11
  • RDF::RDFa::Parser::Config->RDFA_GUESS
  • RDF::RDFa::Parser::Config->RDFA_LATEST

version guessing, because of course: the root element gets inspected for an attribute called 'version'. if that attribute exists and matches /\bRDFa\s+(\d+\.\d+)\b/i then that match is the version. otherwise, the latest version is assumed. periodt.

%options is a hash of extra options that override the defaults. and yeah, a lot of them are useful, but heads up β€” they probably also reduce conformance to the official RDFa specifications. πŸ™ˆ here's everything that exists; the defaults for XHTML+RDFa1.0 and XHTML+RDFa1.1 are chillin' in brackets.

  • alt_stylesheet β€” the magic rel="alternate stylesheet". [0]
  • atom_elements β€” process <feed> and <entry> specially. [0]
  • atom_parser β€” extract Atom 1.0 native semantics. [0]
  • auto_config β€” go look at the "Auto Config" section. [0]
  • bookmark_start, bookmark_end, bookmark_name β€” elements to treat like OpenDocument's <text:bookmark-start> and <text:bookmark-end> element, plus the associated text:name attribute. you have to set all three to actually use this feature. use Clark Notation to specify namespaces. [all undef]
  • cite_attr β€” support @cite. [0]
  • datetime_attr β€” support the @datetime attribute and the HTML5 <time> element. [0]
  • default_profiles β€” 🚨 THIS OPTION IS NO LONGER SUPPORTED!
  • dom_parser β€” the parser used to turn a markup string into a DOM. 'html', 'opendocument' (i.e. zipped XML) or 'xml'. ['xml']
  • embedded_rdfxml β€” find plain RDF/XML chunks inside the document. 0=no, 1=handle, 2=skip. [0]
  • full_uris β€” support full URIs in CURIE-only attributes. [0, 1]
  • graph β€” turn on support for named graphs. [0]
  • graph_attr β€” the attribute to use for named graphs. use Clark Notation to specify a namespace. ['graph']
  • graph_type β€” graph attribute behaviour, either 'id' or 'about'. ['about']
  • graph_default β€” default graph name. [undef]
  • initial_context β€” space-separated list of URIs, which must be keys in %RDF::RDFa::Parser::InitialContext::Known. [?]
  • inlist_attr β€” support @inlist. [0, 1]
  • longdesc_attr β€” support @longdesc. [0]
  • lwp_ua β€” an LWP::UserAgent to use for HTTP requests. [undef]
  • ns β€” namespace for RDFa attributes. [undef]
  • prefix_attr β€” support @prefix instead of just @xmlns:*. [0, 1]
  • prefix_bare β€” support CURIEs with no colon+suffix. [0]
  • prefix_default β€” URI for the default prefix (like rel=":foo"). ['http://www.w3.org/1999/xhtml/vocab#']
  • prefix_nocase β€” DEPRECATED β€” it's just a shortcut for prefix_nocase_attr and prefix_nocase_xmlns.
  • prefix_nocase_attr β€” ignore case-sensitivity of CURIE prefixes defined via the @prefix attribute. [0, 1]
  • prefix_nocase_xmlns β€” ignore case-sensitivity of CURIE prefixes defined via xmlns. [0, 1]
  • profile_attr β€” 🚨 THIS OPTION IS NO LONGER SUPPORTED!
  • profile_pi β€” 🚨 THIS OPTION IS NO LONGER SUPPORTED!
  • property_resources β€” @property works for resources. [0, 1]
  • role_attr β€” support for XHTML @role. [0]
  • safe_anywhere β€” allow Safe CURIEs in @rel/@rev/etc. [0, 1]
  • safe_optional β€” allow Unsafe CURIEs in @about/@resource. [0, 1]
  • skolemize β€” mint URIs instead of blank node identifiers. [0]
  • src_sets_object β€” @src sets the object URI (like @href). [0, 1]
  • tdb_service β€” use thing-described-by.org to name some bnodes. [0]
  • typeof_resources β€” allow @typeof to occasionally apply to objects rather than subjects. [0, 1]
  • user_agent β€” a User-Agent header to use for HTTP requests. ignored if lwp_ua is provided. [undef]
  • use_rtnlx β€” use RDF::Trine::Node::Literal::XML. 0=no, 1=if available. [0]
  • value_attr β€” support the @value attribute (like @content). [0]
  • vocab_attr β€” support @vocab from RDFa 1.1. [0, 1]
  • vocab_default β€” default vocab URI (like rel="foo"). [undef]
  • vocab_triple β€” generate a triple from @vocab. [0, 1]
  • xhtml_base β€” process the <base> element. 0=no, 1=yes, 2=use it for RDF/XML too. [1]
  • xhtml_elements β€” process <head> and <body> specially. (different special handling for XHTML+RDFa 1.0 and 1.1, btw.) [1, 2]
  • xhtml_lang β€” support @lang rather than just @xml:lang. [0]
  • xml_base β€” support for the 'xml:base' attribute. 0=only RDF/XML; 1=except @href/@src; 2=always. [0]
  • xml_lang β€” support for the 'xml:lang' attribute. [1]
  • xmllit_default β€” generate XMLLiterals enthusiastically. [1, 0]
  • xmllit_recurse β€” look for RDFa inside XMLLiterals. [0, 1]
  • xmlns_attr β€” support for 'xmlns:foo' to define CURIE prefixes. [1]

there's also an alternative constructor, tagsoup, which comes preloaded with a genuinely useful set of options for dealing with content "from the wild". 🧚


🌸 EXAMPLES 🌸

this full example parses RDFa 1.1 inside an Atom document, and it also flips on the non-default 'atom_parser' option so native Atom elements get parsed into the graph too. πŸ’–

use RDF::RDFa::Parser;

$config = RDF::RDFa::Parser::Config->new(
  RDF::RDFa::Parser::Config->HOST_ATOM,
  RDF::RDFa::Parser::Config->RDFA_11,
  atom_parser => 1,
  );
$parser = RDF::RDFa::Parser->new_from_url($url, $config);
$data   = $parser->graph;

this next configuration set parses XHTML+RDFa 1.1 while also parsing any RDF/XML chunks embedded in the document. two for one, we love to see it. ✨

use RDF::RDFa::Parser::Config qw(HOST_XHTML RDFA_11);
$config = RDF::RDFa::Parser::Config->new(
  HOST_XHTML, RDFA_11, embedded_rdfxml=>1);
$parser = RDF::RDFa::Parser->new_from_url($url, $config);
$data   = $parser->graph;

and this one? this one is the config for dealing with (X)HTML content from the wild. iconic. πŸ¦‹

$config = RDF::RDFa::Parser::Config->tagsoup;
$parser = RDF::RDFa::Parser->new_from_url($url, $config);
$data   = $parser->graph;

πŸ‘€ SEE ALSO πŸ‘€

RDF::RDFa::Parser. that's the one. go read it. 🫢

πŸ’œ AUTHOR πŸ’œ

Toby Inkster <tobyink@cpan.org>. king behaviour, honestly. πŸ‘‘

Copyright 2008-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. so like, go off. πŸ’…

⚠️ 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.

no cap, it's giving "you're on your own" and honestly? that's the whole disclaimer. 😭


and that's the page, bestie!! this was pulled from perl v5.32.1, dated 2021-09-11, and it lives in the RDF::RDFa::Parser::Config section 3pm of the User Contributed Perl Documentation. mwah, go configure something cute. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from