1RDF::RDFa::Generator(3)User Contributed Perl DocumentatioRnDF::RDFa::Generator(3)
2
3
4

NAME

6       RDF::RDFa::Generator - Generate data for RDFa serialization
7

DESCRIPTION

9   Constructor
10       "$gen = RDF::RDFa::Generator->new(style => $style, %options)"
11           Creates a new generator object. $style is one of the following
12           case-sensitive strings: 'HTML::Head' (the default), 'HTML::Hidden'
13           or 'HTML::Pretty'. You can also construct an object like this:
14
15             $gen = RDF::RDFa::Generator::HTML::Head->new(%options);
16
17           Options include:
18
19base - the base URL where the output data will be published.
20               This allows in some cases for the generated RDFa to include
21               relative URIs.
22
23data_context - if non-null, an Attean Blank or IRI object or an
24               RDF::Trine::Node which indicates the context (named graph)
25               containing the data to generate RDFa for.
26
27namespacemap - a URI::NamespaceMap object containing preferred
28               CURIE prefixes. This is the preferred method, see note below.
29
30namespaces - a {prefix=>uri} hashref of preferred CURIE
31               prefixes.
32
33ns - a {uri=>prefix} hashref of preferred CURIE prefixes.
34               DEPRECATED - use namespaces instead.
35
36prefix_attr - use the @prefix attribute for CURIE prefixes
37               (RDFa 1.1 only).  Boolean, defaults to false.
38
39safe_xml_literals - prevents XML literals from injecting
40               arbitrary XHTML into the output. Boolean, defaults to FALSE.
41
42title - assign a <title> element for generated XHTML documents.
43
44version - set generated RDFa version. Valid values are '1.0'
45               (the default) or '1.1'.
46
47   Public Methods
48       "$gen->create_document($model, %opts)"
49           Creates a new RDFa file containing triples. $model is an
50           RDF::Trine::Model object providing the triples. Returns an
51           XML::LibXML::Document object suitable for serializing using its
52           "toString" method.
53
54           If you're planning on serving the RDFa with the text/html media
55           type, then it is recommended that you use HTML::HTML5::Writer to
56           serialize the document rather than "toString".
57
58           Can also be called as a class method:
59
60            $document = RDF::RDFa::Generator->create_document($model)
61            # Same as:
62            # $document = RDF::RDFa::Generator->new->create_document($model)
63
64           Options can also be passed as a HASH. This is typically used for
65           style-specific options.
66
67       "$gen->inject_document($document, $model)"
68           Injects an existing document with triples. $document is an
69           XML::LibXML::Document to inject, or a well-formed XML string.
70           $model is an RDF::Trine::Model object providing the triples.
71           Returns an XML::LibXML::Document object suitable for serializing
72           using its "toString" method.
73
74           See "create_document" for information about serving the RDFa with
75           the text/html media type.
76
77           Can also be called as a class method. See "create_document" for
78           details.
79
80       "$gen->nodes($model)"
81           Provides triple-laden XML::LibXML::Elements to be added to a
82           document.  $model is an RDF::Trine::Model object providing the
83           triples. If called in list context, returns a list of
84           XML::LibXML::Element objects which can be added to a document;
85           otherwise returns an XML::LibXML::NodeList containing a list of
86           such elements.
87
88           Can also be called as a class method. See "create_document" for
89           details.
90
91           The HTML::Pretty generator can be passed a couple of additional
92           options:
93
94             $gen->nodes($model, notes_heading=>'Additional Info', notes=>\@notes);
95
96           The notes are a list of RDF::RDFa::Generator::HTML::Pretty::Note
97           objects which are added as notes to the end of each subject's data.
98

UPGRADING TO 0.200

100       The recommended upgrade path is to migrate your application to use
101       Attean rather than RDF::Trine as your RDF library. If that is not an
102       option, you may continue to use RDF::Trine, by using a compatibility
103       layer.  If you are using this module directly, to upgrade from earlier
104       releases, you would simply add
105
106        use RDF::TrineX::Compatibility::Attean;
107
108       alongside the import of this module. It is in a separate distribution
109       that needs to be installed. If you use the RDF::Trine::Serializer
110       methods, you should instead use RDF::Trine::Serializer::RDFa.
111

NOTE

113       Version 0.200 introduced a large number of changes to be compatible
114       with both Attean and RDF::Trine. Some of these were backwards-
115       incompatible, some were to support new features, such as the use of
116       URI::NamespaceMap.
117
118   Backwards-incompatible changes
119       The methods "serialize_model_to_file", "serialize_model_to_string",
120       "serialize_iterator_to_file" and "serialize_iterator_to_string" that
121       were provided for compatibility with the RDF::Trine::Serializer
122       interface have been moved to a module RDF::Trine::Serializer::RDFa that
123       has to be installed separately to use this with RDF::Trine.
124
125       "data_context" previously accepted a plain-text string URI. Now, it
126       requires an appropriate object, as documented.
127
128       Since RDF 1.1 abandons untyped literals, this module also ceases to
129       emit them.
130
131   Namespace mappings
132       The way namespace mappings are handled have been rewritten. Now, the
133       preferred method to add them is to pass an URI::NamespaceMap object to
134       "namespacemap". This will override any other options.
135
136       The namespace mappings for the following prefixes will always be added:
137       "rdfa", "rdf", "rdfs" and "xsd".
138
139       If URI::NamespaceMap is not used, but "namespaces" is given as a
140       hashref of prefix-URI pairs, the pairs will be added. If neither are
141       given, all mappings from RDF::NS::Curated, which includes all if RDFa
142       Initial Context will be added. Finally, any pairs from the deprecated
143       "ns" option will be added, but a warning will be emitted.
144

BUGS

146       Please report any bugs to
147       <https://github.com/kjetilk/p5-rdf-rdfa-generator/issues>.
148

SEE ALSO

150       You may want to use the framework-specific frontends:
151       RDF::Trine::Serializer::RDFa or AtteanX::Serializer::RDFa.
152
153       Other relevant modules:
154
155       HTML::HTML5::Writer, XML::LibXML, RDF::RDFa::Parser, RDF::Trine,
156       URI::NamespaceMap, Attean.
157

AUTHOR

159       Toby Inkster <tobyink@cpan.org>.
160
161       Kjetil Kjernsmo <kjetilk@cpan.org>.
162
164       Copyright (C) 2010 by Toby Inkster, 2017, 2018 Kjetil Kjernsmo
165
166       This library is free software; you can redistribute it and/or modify it
167       under the same terms as Perl itself, either Perl version 5.8 or, at
168       your option, any later version of Perl 5 you may have available.
169
170   Icons
171       RDF::RDFa::Generator::HTML::Pretty uses the FamFamFam Silk icons; see
172       <http://famfamfam.com/lab/icons/silk/>.
173
174
175
176perl v5.36.0                      2022-07-22           RDF::RDFa::Generator(3)
Impressum