rdf-rdfa 1.99.3 → 2.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +487 -0
- data/VERSION +1 -1
- data/lib/rdf/rdfa.rb +0 -3
- data/lib/rdf/rdfa/context.rb +21 -9
- data/lib/rdf/rdfa/context/xml.rb +1 -0
- data/lib/rdf/rdfa/format.rb +6 -60
- data/lib/rdf/rdfa/reader.rb +55 -39
- data/lib/rdf/rdfa/reader/nokogiri.rb +1 -1
- data/lib/rdf/rdfa/writer.rb +119 -117
- metadata +134 -59
- data/README +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bbfc3d3119b217a814903fa6af591daadf41700c
|
4
|
+
data.tar.gz: 3339d6dedbeb3c11d37ee0c3d7486ef07d8f5c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5372e9ff514ccf44afbc60738b76544553c94306e2484085a80bf6350dec7f1f3fd842d76e3d1838f7a3dd3791016591612e8b92dbaf214e9ac2c9fb6951f2cd
|
7
|
+
data.tar.gz: 1fef36149174569a9663171755ccc579a0ed1eec66a57e379a63d772ef9d31c00ba8f20088df893a54aaa7c6196098ea6d1658e76cb0768f0dc9609f9beab1d8
|
data/README.md
ADDED
@@ -0,0 +1,487 @@
|
|
1
|
+
This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
|
2
|
+
# RDF::RDFa reader/writer
|
3
|
+
|
4
|
+
[RDFa][RDFa 1.1 Core] parser for RDF.rb.
|
5
|
+
|
6
|
+
[](http://badge.fury.io/rb/rdf-rdfa)
|
7
|
+
[](http://travis-ci.org/ruby-rdf/rdf-rdfa)
|
8
|
+
[](https://coveralls.io/r/ruby-rdf/rdf-rdfa)
|
9
|
+
|
10
|
+
## DESCRIPTION
|
11
|
+
RDF::RDFa is an RDFa reader and writer for Ruby using the [RDF.rb][RDF.rb] library suite.
|
12
|
+
|
13
|
+
## FEATURES
|
14
|
+
RDF::RDFa parses [RDFa][RDFa 1.1 Core] into statements or triples.
|
15
|
+
|
16
|
+
* Fully compliant RDFa 1.1 parser.
|
17
|
+
* Template-based Writer to generate XHTML+RDFa.
|
18
|
+
* Writer uses user-replacable [Haml][Haml]-based templates to generate RDFa.
|
19
|
+
* If available, uses Nokogiri for parsing HTML/SVG, falls back to REXML otherwise
|
20
|
+
|
21
|
+
Install with `gem install rdf-rdfa`
|
22
|
+
|
23
|
+
### Pure Ruby
|
24
|
+
In order to run as pure ruby (not requiring any C modules), this gem does not directly depend on [Nokogiri](http://www.nokogiri.org)
|
25
|
+
and falls back to using REXML. As REXML is not really an HTML parsing library, the results will only be useful if the HTML is well-formed.
|
26
|
+
For best performance, install the Nokogiri gem as well.
|
27
|
+
|
28
|
+
### Important changes from previous versions
|
29
|
+
RDFa is an evolving standard, undergoing some substantial recent changes partly due to perceived competition
|
30
|
+
with Microdata. As a result, the RDF Webapps working group is currently looking at changes in the processing model for RDFa. These changes are now being tracked in {RDF::RDFa::Reader}:
|
31
|
+
|
32
|
+
#### RDFa 1.1 Lite
|
33
|
+
This version fully supports the limited syntax of [RDFa Lite 1.1][]. This includes the ability to use `@property` exclusively.
|
34
|
+
|
35
|
+
#### Vocabulary Expansion
|
36
|
+
One of the issues with vocabularies was that they discourage re-use of existing vocabularies when terms from several vocabularies are used at the same time. As it is common (encouraged) for RDF vocabularies to form sub-class and/or sub-property relationships with well defined vocabularies, the RDFa vocabulary expansion mechanism takes advantage of this.
|
37
|
+
|
38
|
+
As an optional part of RDFa processing, an RDFa processor will perform limited
|
39
|
+
[OWL 2 RL Profile entailment](http://www.w3.org/TR/2009/REC-owl2-profiles-20091027/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules),
|
40
|
+
specifically rules prp-eqp1, prp-eqp2, cax-sco, cax-eqc1, and
|
41
|
+
cax-eqc2. This causes sub-classes and sub-properties of type and property IRIs to be added
|
42
|
+
to the output graph.
|
43
|
+
|
44
|
+
{RDF::RDFa::Reader} implements this using the `#expand` method, which looks for `rdfa:usesVocabulary` properties within the output graph and performs such expansion. See an example in the usage section.
|
45
|
+
|
46
|
+
#### Experimental support for rdfa:copy template expansion
|
47
|
+
RDFa 1.1 is just about an exact super-set of microdata, except for microdata's
|
48
|
+
`@itemref` feature. Experimental support is added for `rdfa:copy` and `rdfa:Pattern` to get a similar effect using expansion. To use this,
|
49
|
+
reference another resource using `rdfa:copy`. If that resource has the type
|
50
|
+
`rdfa:Pattern`, the properties defined there will be added to the resource
|
51
|
+
containing the `rdfa:copy`, and the pattern and `rdfa:copy` will be removed
|
52
|
+
from the output.
|
53
|
+
|
54
|
+
For example, consider the following:
|
55
|
+
|
56
|
+
<div>
|
57
|
+
<div typeof="schema:Person">
|
58
|
+
<link property="rdfa:copy" resource="_:a"/>
|
59
|
+
</div>
|
60
|
+
<p resource="_:a" typeof="rdfa:Pattern">Name: <span property="schema:name">Amanda</span></p>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
if run with vocabulary expansion, this will result in the following Turtle:
|
64
|
+
|
65
|
+
@prefix schema: <http://schema.org/> .
|
66
|
+
[a schema:Person; schema:name "Amanda"] .
|
67
|
+
|
68
|
+
|
69
|
+
#### RDF Collections (lists)
|
70
|
+
One significant RDF feature missing from RDFa was support for ordered collections, or lists. RDF supports this with special properties `rdf:first`, `rdf:rest`, and `rdf:nil`, but other RDF languages have first-class support for this concept. For example, in [Turtle][Turtle], a list can be defined as follows:
|
71
|
+
|
72
|
+
[ a schema:MusicPlayList;
|
73
|
+
schema:name "Classic Rock Playlist";
|
74
|
+
schema:numTracks 5;
|
75
|
+
schema:tracks (
|
76
|
+
[ a schema:MusicRecording; schema:name "Sweet Home Alabama"; schema:byArtist "Lynard Skynard"]
|
77
|
+
[ a schema:MusicRecording; schema:name "Shook you all Night Long"; schema:byArtist "AC/DC"]
|
78
|
+
[ a schema:MusicRecording; schema:name "Sharp Dressed Man"; schema:byArtist "ZZ Top"]
|
79
|
+
[ a schema:MusicRecording; schema:name "Old Time Rock and Roll"; schema:byArtist "Bob Seger"]
|
80
|
+
[ a schema:MusicRecording; schema:name "Hurt So Good"; schema:byArtist "John Cougar"]
|
81
|
+
)
|
82
|
+
]
|
83
|
+
|
84
|
+
defines a playlist with an ordered set of tracks. RDFa adds the @inlist attribute, which is used to identify values (object or literal) that are to be placed in a list. The same playlist might be defined in RDFa as follows:
|
85
|
+
|
86
|
+
<div vocab="http://schema.org/" typeof="MusicPlaylist">
|
87
|
+
<span property="name">Classic Rock Playlist</span>
|
88
|
+
<meta property="numTracks" content="5"/>
|
89
|
+
|
90
|
+
<div rel="tracks" inlist="">
|
91
|
+
<div typeof="MusicRecording">
|
92
|
+
1.<span property="name">Sweet Home Alabama</span> -
|
93
|
+
<span property="byArtist">Lynard Skynard</span>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<div typeof="MusicRecording">
|
97
|
+
2.<span property="name">Shook you all Night Long</span> -
|
98
|
+
<span property="byArtist">AC/DC</span>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<div typeof="MusicRecording">
|
102
|
+
3.<span property="name">Sharp Dressed Man</span> -
|
103
|
+
<span property="byArtist">ZZ Top</span>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div typeof="MusicRecording">
|
107
|
+
4.<span property="name">Old Time Rock and Roll</span>
|
108
|
+
<span property="byArtist">Bob Seger</span>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div typeof="MusicRecording">
|
112
|
+
5.<span property="name">Hurt So Good</span>
|
113
|
+
<span property="byArtist">John Cougar</span>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
This basically does the same thing, but places each track in an rdf:List in the defined order.
|
119
|
+
|
120
|
+
#### Magnetic @about/@typeof
|
121
|
+
The @typeof attribute has changed; previously, it always created a new subject, either using a resource from @about, @resource and so forth. This has long been a source of errors for people using RDFa. The new rules cause @typeof to bind to a subject if used with @about, otherwise, to an object, if either used alone, or in combination with some other resource attribute (such as @href, @src or @resource).
|
122
|
+
|
123
|
+
For example:
|
124
|
+
|
125
|
+
<div typeof="foaf:Person" about="http://greggkellogg.net/foaf#me">
|
126
|
+
<p property="name">Gregg Kellogg</span>
|
127
|
+
<a rel="knows" typeof="foaf:Person" href="http://manu.sporny.org/#this">
|
128
|
+
<span property="name">Manu Sporny</span>
|
129
|
+
</a>
|
130
|
+
</div>
|
131
|
+
|
132
|
+
results in
|
133
|
+
|
134
|
+
<http://greggkellogg.net/foaf#me> a foaf:Person;
|
135
|
+
foaf:name "Gregg Kellogg";
|
136
|
+
foaf:knows <http://manu.sporny.org/#this> .
|
137
|
+
<http://manu.sporny.org/#this> a foaf:Person;
|
138
|
+
foaf:name "Manu Sporny" .
|
139
|
+
|
140
|
+
Note that if the explicit @href is not present, i.e.,
|
141
|
+
|
142
|
+
<div typeof="foaf:Person" about="http://greggkellogg.net/foaf#me">
|
143
|
+
<p property="name">Gregg Kellogg</span>
|
144
|
+
<a href="knows" typeof="foaf:Person">
|
145
|
+
<span property="name">Manu Sporny</span>
|
146
|
+
</a>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
this results in
|
150
|
+
|
151
|
+
<http://greggkellogg.net/foaf#me> a foaf:Person;
|
152
|
+
foaf:name "Gregg Kellogg";
|
153
|
+
foaf:knows [
|
154
|
+
a foaf:Person;
|
155
|
+
foaf:name "Manu Sporny"
|
156
|
+
].
|
157
|
+
|
158
|
+
|
159
|
+
### Support for embedded RDF/XML
|
160
|
+
If the document includes embedded RDF/XML, as is the case with many SVG documents, and the RDF::RDFXML gem is installed, the reader will add extracted triples to the default graph.
|
161
|
+
|
162
|
+
For example:
|
163
|
+
|
164
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
165
|
+
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
|
166
|
+
xmlns:dc="http://purl.org/dc/terms/"
|
167
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
168
|
+
xml:base="http://example.net/"
|
169
|
+
xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
|
170
|
+
<desc property="dc:description">A yellow rectangle with sharp corners.</desc>
|
171
|
+
<metadata>
|
172
|
+
<rdf:RDF>
|
173
|
+
<rdf:Description rdf:about="">
|
174
|
+
<dc:title>Test 0304</dc:title>
|
175
|
+
</rdf:Description>
|
176
|
+
</rdf:RDF>
|
177
|
+
</metadata>
|
178
|
+
<!-- Show outline of canvas using 'rect' element -->
|
179
|
+
<rect x="1" y="1" width="1198" height="398"
|
180
|
+
fill="none" stroke="blue" stroke-width="2"/>
|
181
|
+
<rect x="400" y="100" width="400" height="200"
|
182
|
+
fill="yellow" stroke="navy" stroke-width="10" />
|
183
|
+
</svg>
|
184
|
+
|
185
|
+
generates the following turtle:
|
186
|
+
|
187
|
+
@prefix dc: <http://purl.org/dc/terms/> .
|
188
|
+
|
189
|
+
<http://example.net/> dc:title "Test 0304" ;
|
190
|
+
dc:description "A yellow rectangle with sharp corners." .
|
191
|
+
|
192
|
+
### Support for embedded N-Triples or Turtle
|
193
|
+
If the document includes a `<script>` element having an `@type` attribute whose value matches that of a loaded RDF reader (text/ntriples and text/turtle are loaded if they are availble), the data will be extracted and added to the default graph. For example:
|
194
|
+
|
195
|
+
<html>
|
196
|
+
<body>
|
197
|
+
<script type="text/turtle"><![CDATA[
|
198
|
+
@prefix foo: <http://www.example.com/xyz#> .
|
199
|
+
@prefix gr: <http://purl.org/goodrelations/v1#> .
|
200
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
201
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
202
|
+
|
203
|
+
foo:myCompany
|
204
|
+
a gr:BusinessEntity ;
|
205
|
+
rdfs:seeAlso <http://www.example.com/xyz> ;
|
206
|
+
gr:hasLegalName "Hepp Industries Ltd."^^xsd:string .
|
207
|
+
]]></script>
|
208
|
+
</body>
|
209
|
+
</html>
|
210
|
+
|
211
|
+
generates the following Turtle:
|
212
|
+
|
213
|
+
```
|
214
|
+
@prefix foo: <http://www.example.com/xyz#> .
|
215
|
+
@prefix gr: <http://purl.org/goodrelations/v1#> .
|
216
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
217
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
218
|
+
|
219
|
+
foo:myCompany
|
220
|
+
a gr:BusinessEntity ;
|
221
|
+
rdfs:seeAlso <http://www.example.com/xyz> ;
|
222
|
+
gr:hasLegalName "Hepp Industries Ltd."^^xsd:string .
|
223
|
+
```
|
224
|
+
|
225
|
+
### Support for Role Attribute
|
226
|
+
The processor will generate RDF triples consistent with the [Role Attr][] specification.
|
227
|
+
|
228
|
+
<div id="heading1" role="heading">
|
229
|
+
<p>Some contents that are a header</p>
|
230
|
+
</div>
|
231
|
+
|
232
|
+
generates the following Turtle:
|
233
|
+
|
234
|
+
@prefix xhv: <http://www.w3.org/1999/xhtml/vocab#> .
|
235
|
+
<#heading1> xhv:role xhv:heading.
|
236
|
+
|
237
|
+
### Support for microdata
|
238
|
+
The RDFa reader will call out to `RDF::Microdata::Reader`, if an `@itemscope` attribute is detected, and the microdata reader is loaded. This avoids a common problem when pages contain both microdata and RDFa, and only one processor is run.
|
239
|
+
|
240
|
+
### Support for value property
|
241
|
+
In an [RDFA+HTML Errata](https://www.w3.org/2001/sw/wiki/RDFa_1.1._Errata#Using_.3Cdata.3E.2C_.3Cinput.3E_and_.3Cli.3E_along_with_.40value), it was suggested that the `@value` attribute could be parsed to obtain a numeric literal; this is consistent with how it's treated in microdata+rdfa. This processor now parses the value of an `@value` property to determine if it is an `xsd:integer`, `xsd:float`, or `xsd:double`, and uses a plain literal otherwise. The datatype can be overriden using the `@datatype` attribute.
|
242
|
+
## Usage
|
243
|
+
|
244
|
+
### Reading RDF data in the RDFa format
|
245
|
+
|
246
|
+
graph = RDF::Graph.load("etc/doap.html", format: :rdfa)
|
247
|
+
|
248
|
+
### Reading RDF data with vocabulary expansion
|
249
|
+
|
250
|
+
graph = RDF::Graph.load("etc/doap.html", format: :rdfa, vocab_expansion: true)
|
251
|
+
|
252
|
+
or
|
253
|
+
|
254
|
+
graph = RDF::RDFa::Reader.open("etc/doap.html").expand
|
255
|
+
|
256
|
+
### Reading Processor Graph
|
257
|
+
|
258
|
+
graph = RDF::Graph.load("etc/doap.html", format: :rdfa, rdfagraph: :processor)
|
259
|
+
|
260
|
+
### Reading Both Processor and Output Graphs
|
261
|
+
|
262
|
+
graph = RDF::Graph.load("etc/doap.html", format: :rdfa, rdfagraph: [:output, :processor])
|
263
|
+
|
264
|
+
### Writing RDF data using the XHTML+RDFa format
|
265
|
+
|
266
|
+
require 'rdf/rdfa'
|
267
|
+
|
268
|
+
RDF::RDFa::Writer.open("etc/doap.html") do |writer|
|
269
|
+
writer << graph
|
270
|
+
end
|
271
|
+
|
272
|
+
Note that prefixes may be chained between Reader and Writer, so that the Writer will
|
273
|
+
use the same prefix definitions found during parsing:
|
274
|
+
|
275
|
+
prefixes = {}
|
276
|
+
graph = RDF::Graph.load("etc/doap.html", prefixes: prefixes)
|
277
|
+
puts graph.dump(:rdfa, prefixes: prefixes)
|
278
|
+
|
279
|
+
### Template-based Writer
|
280
|
+
The RDFa writer uses [Haml][Haml] templates for code generation. This allows
|
281
|
+
fully customizable RDFa output in a variety of host languages. The [default
|
282
|
+
template]({RDF::RDFa::Writer::DEFAULT_HAML}) generates human readable HTML5
|
283
|
+
output. A [minimal template]({RDF::RDFa::Writer::MIN_HAML}) generates HTML,
|
284
|
+
which is not intended for human consumption.
|
285
|
+
|
286
|
+
To specify an alternative Haml template, consider the following:
|
287
|
+
|
288
|
+
require 'rdf/rdfa'
|
289
|
+
|
290
|
+
RDF::RDFa::Writer.buffer(haml: RDF::RDFa::Writer::MIN_HAML) << graph
|
291
|
+
|
292
|
+
The template hash defines four Haml templates:
|
293
|
+
|
294
|
+
* _doc_: Document Template, takes an ordered list of _subject_s and yields each one to be rendered. From {RDF::RDFa::Writer#render_document}:
|
295
|
+
|
296
|
+
{include:RDF::RDFa::Writer#render_document}
|
297
|
+
|
298
|
+
This template takes locals _lang_, _prefix_, _base_, _title_ in addition to _subjects_
|
299
|
+
to create output similar to the following:
|
300
|
+
|
301
|
+
<!DOCTYPE html>
|
302
|
+
<html prefix='xhv: http://www.w3.org/1999/xhtml/vocab#' xmlns='http://www.w3.org/1999/xhtml'>
|
303
|
+
<head>
|
304
|
+
<base href="http://example/">
|
305
|
+
<title>Document Title</title>
|
306
|
+
</head>
|
307
|
+
<body>
|
308
|
+
...
|
309
|
+
</body>
|
310
|
+
</html>
|
311
|
+
|
312
|
+
Options passed to the Writer are used to supply _lang_ and _base_ locals.
|
313
|
+
_prefix_ is generated based upon prefixes found from the default profiles, as well
|
314
|
+
as those provided by a previous Reader. _title_ is taken from the first top-level subject
|
315
|
+
having an appropriate title property (as defined by the _heading\_predicates_ option).
|
316
|
+
|
317
|
+
* _subject_: Subject Template, take a _subject_ and an ordered list of _predicate_s and yields
|
318
|
+
each _predicate_ to be rendered. From {RDF::RDFa::Writer#render_subject}:
|
319
|
+
|
320
|
+
{include:RDF::RDFa::Writer#render_subject}
|
321
|
+
|
322
|
+
The template takes locals _rel_ and _typeof_ in addition to _predicates_ and _subject_ to
|
323
|
+
create output similar to the following:
|
324
|
+
|
325
|
+
<div resource="http://example/">
|
326
|
+
...
|
327
|
+
</div>
|
328
|
+
|
329
|
+
Note that if _typeof_ is defined, in this template, it will generate a textual description.
|
330
|
+
|
331
|
+
* _property\_value_: Property Value Template, used for predicates having a single value; takes
|
332
|
+
a _predicate_, and a single-valued Array of _objects_. From {RDF::RDFa::Writer#render_property}:
|
333
|
+
|
334
|
+
{include:RDF::RDFa::Writer#render_property}
|
335
|
+
|
336
|
+
In addition to _predicate_ and _objects_, the template takes _inlist_ to indicate that the
|
337
|
+
property is part of an `rdf:List`.
|
338
|
+
|
339
|
+
Also, if the predicate is identified as a _heading predicate_ (via _:heading\_predicates_ option),
|
340
|
+
it will generate a heading element, and may use the value as the document title.
|
341
|
+
|
342
|
+
Each _object_ is yielded to the calling block, and the result is rendered, unless nil.
|
343
|
+
Otherwise, rendering depends on the type of _object_. This is useful for recursive document
|
344
|
+
descriptions.
|
345
|
+
|
346
|
+
Creates output similar to the following:
|
347
|
+
|
348
|
+
<div class='property'>
|
349
|
+
<span class='label'>
|
350
|
+
xhv:alternate
|
351
|
+
</span>
|
352
|
+
<a property='xhv:alternate' href='http://rdfa.info/feed/'>http://rdfa.info/feed/</a>
|
353
|
+
</div>
|
354
|
+
|
355
|
+
Note the use of methods defined in {RDF::RDFa::Writer} useful in rendering the output.
|
356
|
+
|
357
|
+
* _property\_values_: Similar to _property\_value_, but for predicates having more than one value.
|
358
|
+
Locals are identical to _property\_values_, but _objects_ is expected to have more than one value. Described further in {RDF::RDFa::Writer#render_property}.
|
359
|
+
|
360
|
+
In this case, and unordered list is used for output. Creates output similar to the following:
|
361
|
+
|
362
|
+
<div class='property'>
|
363
|
+
<span class='label'>
|
364
|
+
xhv:bookmark
|
365
|
+
</span>
|
366
|
+
<ul rel='xhv:bookmark'>
|
367
|
+
<li>
|
368
|
+
<a href='http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/'>
|
369
|
+
http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/
|
370
|
+
</a>
|
371
|
+
</li>
|
372
|
+
<a href='http://rdfa.info/2010/05/31/new-rdfa-checker/'>
|
373
|
+
http://rdfa.info/2010/05/31/new-rdfa-checker/
|
374
|
+
</a>
|
375
|
+
</li>
|
376
|
+
</ul>
|
377
|
+
</div>
|
378
|
+
If _property\_values_ does not exist, repeated values will be replecated
|
379
|
+
using _property\_value_.
|
380
|
+
* Type-specific templates.
|
381
|
+
To simplify generation of different output types, the
|
382
|
+
template may contain a elements indexed by a URI. When a subject with an rdf:type
|
383
|
+
matching that URI is found, subsequent Haml definitions will be taken from
|
384
|
+
the associated Hash. For example:
|
385
|
+
|
386
|
+
{
|
387
|
+
document: "...",
|
388
|
+
subject: "...",
|
389
|
+
:property\_value => "...",
|
390
|
+
:property\_values => "...",
|
391
|
+
RDF::URI("http://schema.org/Person") => {
|
392
|
+
subject: "...",
|
393
|
+
:property\_value => "...",
|
394
|
+
:property\_values => "...",
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
## Dependencies
|
399
|
+
* [Ruby](http://ruby-lang.org/) (>= 2.0)
|
400
|
+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0)
|
401
|
+
* [Haml](https://rubygems.org/gems/haml) (>= 4.0)
|
402
|
+
* [HTMLEntities](https://rubygems.org/gems/htmlentities) (>= 4.3.1)
|
403
|
+
* Soft dependency on [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.6.1)
|
404
|
+
|
405
|
+
## Documentation
|
406
|
+
Full documentation available on [Rubydoc.info][RDFa doc]
|
407
|
+
|
408
|
+
### Principle Classes
|
409
|
+
* {RDF::RDFa::Format}
|
410
|
+
* {RDF::RDFa::HTML}
|
411
|
+
Asserts :html format, text/html mime-type and .html file extension.
|
412
|
+
* {RDF::RDFa::XHTML}
|
413
|
+
Asserts :html format, application/xhtml+xml mime-type and .xhtml file extension.
|
414
|
+
* {RDF::RDFa::SVG}
|
415
|
+
Asserts :svg format, image/svg+xml mime-type and .svg file extension.
|
416
|
+
* {RDF::RDFa::Reader}
|
417
|
+
* {RDF::RDFa::Reader::Nokogiri}
|
418
|
+
* {RDF::RDFa::Reader::REXML}
|
419
|
+
* {RDF::RDFa::Context}
|
420
|
+
* {RDF::RDFa::Expansion}
|
421
|
+
* {RDF::RDFa::Writer}
|
422
|
+
|
423
|
+
### Additional vocabularies
|
424
|
+
* {RDF::RDFA}
|
425
|
+
* {RDF::XML}
|
426
|
+
* {RDF::XSI}
|
427
|
+
|
428
|
+
## TODO
|
429
|
+
* Add support for LibXML and REXML bindings, and use the best available
|
430
|
+
* Consider a SAX-based parser for improved performance
|
431
|
+
|
432
|
+
## Resources
|
433
|
+
* [RDF.rb][RDF.rb]
|
434
|
+
* [Distiller](http://rdf.greggkellogg.net/distiller)
|
435
|
+
* [Documentation][RDFa doc]
|
436
|
+
* [History](file:History.md)
|
437
|
+
* [RDFa 1.1 Core][RDFa 1.1 Core]
|
438
|
+
* [XHTML+RDFa 1.1][XHTML+RDFa 1.1]
|
439
|
+
* [RDFa-test-suite](http://rdfa.info/test-suite/ "RDFa test suite")
|
440
|
+
|
441
|
+
## Author
|
442
|
+
* [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
|
443
|
+
|
444
|
+
## Contributors
|
445
|
+
* [Nicholas Humfrey](http://github.com/njh) - <http://njh.me/>
|
446
|
+
|
447
|
+
## Contributing
|
448
|
+
This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
|
449
|
+
|
450
|
+
* Do your best to adhere to the existing coding conventions and idioms.
|
451
|
+
* Don't use hard tabs, and don't leave trailing whitespace on any line.
|
452
|
+
* Do document every method you add using [YARD][] annotations. Read the
|
453
|
+
[tutorial][YARD-GS] or just look at the existing code for examples.
|
454
|
+
* Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
|
455
|
+
change them, do so on your private branch only.
|
456
|
+
* Do feel free to add yourself to the `CREDITS` file and the corresponding
|
457
|
+
list in the the `README`. Alphabetical order applies.
|
458
|
+
* Do note that in order for us to merge any non-trivial changes (as a rule
|
459
|
+
of thumb, additions larger than about 15 lines of code), we need an
|
460
|
+
explicit [public domain dedication][PDD] on record from you.
|
461
|
+
|
462
|
+
## License
|
463
|
+
|
464
|
+
This is free and unencumbered public domain software. For more information,
|
465
|
+
see <http://unlicense.org/> or the accompanying [UNLICENSE](UNLICENSE) file.
|
466
|
+
|
467
|
+
## FEEDBACK
|
468
|
+
|
469
|
+
* gregg@greggkellogg.net
|
470
|
+
* <http://rubygems.org/rdf-rdfa>
|
471
|
+
* <http://github.com/ruby-rdf/rdf-rdfa>
|
472
|
+
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
473
|
+
|
474
|
+
[RDF.rb]: http://rubygems.org/gems/rdf
|
475
|
+
[YARD]: http://yardoc.org/
|
476
|
+
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
477
|
+
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
478
|
+
[RDFa 1.1 Core]: http://www.w3.org/TR/2012/REC-rdfa-core-20120607/ "RDFa 1.1 Core"
|
479
|
+
[RDFa Lite 1.1]: http://www.w3.org/TR/2012/REC-rdfa-lite-20120607/ "RDFa Lite 1.1"
|
480
|
+
[XHTML+RDFa 1.1]: http://www.w3.org/TR/2012/REC-xhtml-rdfa-20120607/ "XHTML+RDFa 1.1"
|
481
|
+
[HTML+RDFa 1.1]: http://www.w3.org/TR/rdfa-in-html/ "HTML+RDFa 1.1"
|
482
|
+
[RDFa-test-suite]: http://rdfa.info/test-suite/ "RDFa test suite"
|
483
|
+
[Role Attr]: http://www.w3.org/TR/role-attribute/ "Role Attribute"
|
484
|
+
[RDFa doc]: http://rubydoc.info/github/ruby-rdf/rdf-rdfa/frames
|
485
|
+
[Haml]: http://haml-lang.com/
|
486
|
+
[Turtle]: http://www.w3.org/TR/2011/WD-turtle-20110809/
|
487
|
+
[Backports]: http://rubygems.org/gems/backports
|