XML::GRDDL(3pm)
β¨ NAME β¨
XML::GRDDL β transform XML and XHTML to RDF π«
okay so bestie, this is the XML::GRDDL(3pm) page and honestly? it's giving magic. you feed it XML or XHTML, it hands you back RDF. that's the whole vibe. no cap. π¦
π SYNOPSIS π
so there's two ways to run this. high-level, where you just want the data and you're not tryna micromanage:
my $grddl = XML::GRDDL->new;
my $model = $grddl->data($xmldoc, $baseuri);
# $model is an RDF::Trine::Model
and low-level, where you want β¨controlβ¨:
my $grddl = XML::GRDDL->new;
my @transformations = $grddl->discover($xmldoc, $baseuri);
foreach my $t (@transformations)
{
# $t is an XML::GRDDL::Transformation
my ($output, $mediatype) = $t->transform($xmldoc);
# $output is a string of type $mediatype.
}
lowkey obsessed with how clean that is. π
π DESCRIPTION π
GRDDL is a W3C Recommendation for extracting RDF data from arbitrary XML and XHTML via a transformation β typically written in XSLT. if you want the full tea, it's at <http://www.w3.org/TR/grddl/>. go read it, i'll wait. π«Ά
This module implements GRDDL in Perl. bestie it gives you both:
- a low-level interface, where you generate a list of transformations associated with the document being processed, so you can selectively run whichever ones you want β main character energy, you choose;
- a high-level interface, where a single RDF model comes back to you, and it's literally the union of the RDF graphs generated by applying all available transformations. one model. slay.
πΈ Constructor
XML::GRDDL->newβ The constructor accepts no parameters and returns anXML::GRDDLobject. that's it. no options, no drama, no config. iconic behaviour fr fr.
π¦ Methods
$grddl->discover($xml, $base, %options)β Processes the document to discover the transformations associated with it.$xmlis the raw XML source of the document, or anXML::LibXML::Documentobject. and ngl,$xmlcannot be "tag soup" HTML β though you should be able to useHTML::HTML5::Parserto parse tag soup into anXML::LibXML::Document.$baseis the base URI for resolving relative references.
Returns a list of XML::GRDDL::Transformation objects. π
Options include:
force_relβ boolean; interpret XHTMLrel="transformation"even in the absence of the GRDDL profile.stringsβ boolean; return a list of plain strings instead of blessed objects.
$grddl->data($xml, $base, %options)β Processes the document, discovers the transformations associated with it, applies the transformations and merges the results into a single RDF model.$xmland$baseare as perdiscover.
Returns an RDF::Trine::Model containing the data. Statement contexts (a.k.a. named graphs / quads) are used to distinguish between data from the result of each transformation. so like, everything stays in its own lane. π
Options include:
force_relβ boolean; interpret XHTMLrel="transformation"even in the absence of the GRDDL profile.metadataβ boolean; include provenance information in the default graph (a.k.a. nil context).
$grddl->ua( [$ua] )β Get/set the user agent used for HTTP requests.$ua, if supplied, must be anLWP::UserAgent.
β Constants
These constants may be exported upon request.
GRDDL_NSXHTML_NS
π₯ FEATURES π₯
XML::GRDDL supports transformations written in XSLT 1.0, and in RDF-EASE. versatility? we have it. π
XML::GRDDL is a good HTTP citizen: Referer headers are included in requests, and appropriate Accept headers supplied. and if you wanna be an even better citizen, the author recommends changing the User-Agent header to advertise the name of the application:
$grddl->ua->default_header(user_agent => 'MyApp/1.0 ');
Provenance information for GRDDL transformations is returned using the GRDDL vocabulary at <http://www.w3.org/2003/g/data-view#>. π
Certain XHTML profiles and XML namespaces known not to contain any transformations, or to contain useless transformations are skipped. See XML::GRDDL::Namespace and XML::GRDDL::Profile for details. In particular, profiles for RDFa and many Microformats are skipped, as RDF::RDFa::Parser and HTML::Microformats will typically yield far superior results. not us being self-aware and delegating to the specialists π
π BUGS π
Please report any bugs to <http://rt.cpan.org/>.
Known limitations:
- Recursive GRDDL doesn't work yet.
That is, the profile documents and namespace documents linked to from your primary document cannot themselves rely on GRDDL. so it's giving "one layer only bestie", we're working on it. π
π SEE ALSO π
XML::GRDDL::Transformation,XML::GRDDL::Namespace,XML::GRDDL::Profile,XML::GRDDL::Transformation::RDF_EASE::Functional,XML::Saxon::XSLT2.HTML::HTML5::Parser,RDF::RDFa::Parser,HTML::Microformats.JSON::GRDDL.- <http://www.w3.org/TR/grddl/>.
- <http://www.perlrdf.org/>.
- This module is derived from Swignition <http://buzzword.org.uk/swignition/>. π«
π AUTHOR π
Toby Inkster <tobyink@cpan.org>. legend behaviour honestly. π«Ά
π COPYRIGHT AND LICENCE π
Copyright 2008-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 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.
(read that one dramatically, bestie. it's the legal equivalent of "no promises, we're all just vibing" π)
and that's the whole page! this one's from perl v5.32.1, dated 2021-09-19, and it's the XML::GRDDL(3pm) manual. mwah, go transform something. π
β¨
π¦ where this page comes from
- debian bookworm: libxml-grddl-perl 0.004-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libxml-grddl-perl 0.004-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libxml-grddl-perl 0.004-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