rdf-rdfa 0.3.1.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -1,4 +1,4 @@
1
- --title "RDFa parser for RDF.rb."
1
+ --title "RDFa reader/writer for RDF.rb."
2
2
  --output-dir doc/yard
3
3
  --protected
4
4
  --no-private
@@ -10,3 +10,4 @@ AUTHORS
10
10
  History.md
11
11
  CONTRIBUTORS
12
12
  VERSION
13
+ UNLICENSE
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ gem 'addressable', '2.2.4'
3
+ gem 'rdf', :git => "https://github.com/gkellogg/rdf.git", :branch => "query-algebra"
4
+ gem 'haml', '>= 3.0.0'
5
+ gem 'nokogiri', '>= 1.3.3'
6
+
7
+ group :development do
8
+ gem 'open-uri-cached', '>= 0.0.3'
9
+ gem 'rdf-spec', :git => "https://github.com/gkellogg/rdf-spec.git", :branch => "query-algebra", :require => 'rdf/spec'
10
+ gem 'rdf-isomorphic', '>= 0.3.4', :require => 'rdf/isomorphic'
11
+ gem 'rdf-n3', '>= 0.3.1', :require => 'rdf/n3'
12
+ gem 'rspec', '>= 2.1.0'
13
+ gem 'sxp', :git => "https://github.com/gkellogg/sxp-ruby.git", :branch => "query-algebra"
14
+ gem 'sparql-algebra', :git => "https://github.com/gkellogg/sparql-algebra.git", :require => 'sparql/algebra'
15
+ gem 'sparql-grammar', :git => "https://github.com/gkellogg/sparql-grammar.git", :require => 'sparql/grammar'
16
+ gem 'spira', '>= 0.0.12'
17
+ gem 'yard', '>= 0.6.4'
18
+ end
data/History.md CHANGED
@@ -1,5 +1,18 @@
1
+ ### 0.3.3
2
+ * Major update to writer using Haml templates, rather than Nokogiri node creation.
3
+
4
+ ### 0.3.2
5
+ * Added RDFa Writer, to perform templated serialization of RDF content to RDFa.
6
+ * Uses Haml to define default and minimal templates for RDFa serialization.
7
+ * Allows templates to be specified on invocation, for arbitrary RDFa serialization.
8
+ * Update to pre-LC2 drafts of RDFa
9
+ * Add support for cached profiles, and include cached profiles for XML+RDFa and XHTML+RDFa.
10
+ * Profiles are processed left to right
11
+ * Detect 1.0 using @version
12
+ * Automatically load profiles based on host language
13
+
1
14
  ### 0.3.1.2
2
- * Assert :html and xhtml as a format types (by creating RDF::RDFa::HTML/XHTML as a sub-classs of Format that uses RDFa::Reader/Writer)
15
+ * Assert :html and xhtml as a format types (by creating RDF::RDFa::HTML/XHTML as a sub-class of Format that uses RDFa::Reader/Writer)
3
16
  * Added :svg format, image/svg+xml and .svg as looks for RDFa parser as well.
4
17
 
5
18
  ### 0.3.1
data/README ADDED
@@ -0,0 +1,291 @@
1
+ # RDF::RDFa reader/writer
2
+
3
+ [RDFa][RDFa 1.1 Core] parser for RDF.rb.
4
+
5
+ ## DESCRIPTION
6
+ RDF::RDFa is an RDFa reader and writer for Ruby using the [RDF.rb][RDF.rb] library suite.
7
+
8
+ ## FEATURES
9
+ RDF::RDFa parses [RDFa][RDFa 1.1 Core] into statements or triples.
10
+
11
+ * Fully compliant RDFa 1.1 parser.
12
+ * Template-based Writer to generate XHTML+RDFa.
13
+ * Writer uses user-replacable [Haml][Haml]-based templates to generate RDFa.
14
+ * Uses Nokogiri for parsing HTML/SVG
15
+ * [RDFa tests][RDFa-test-suite] use SPARQL for most tests due to Rasqal limitations. Other tests compare directly against N-triples.
16
+
17
+ Install with 'gem install rdf-rdfa'
18
+
19
+ ## Usage
20
+
21
+ ### Reading RDF data in the RDFa format
22
+
23
+ RDF::RDFa::Reader.open("etc/foaf.html") do |reader|
24
+ reader.each_statement do |statement|
25
+ puts statement.inspect
26
+ end
27
+ end
28
+
29
+ ### Writing RDF data using the XHTML+RDFa format
30
+
31
+ require 'rdf/rdfa'
32
+
33
+ RDF::RDFa::Writer.open("hello.html") do |writer|
34
+ writer << RDF::Graph.new do |graph|
35
+ graph << [:hello, RDF::DC.title, "Hello, world!"]
36
+ end
37
+ end
38
+
39
+ Note that prefixes may be chained between Reader and Writer, so that the Writer will
40
+ use the same prefix definitions found during parsing:
41
+
42
+ prefixes = {}
43
+ graph = RDF::Graph.load("etc/foaf.html", :prefixes => prefixes)
44
+ puts graph.dump(:rdfa, :prefixes => prefixes)
45
+
46
+ ### Template-based Writer
47
+ The RDFa writer uses [Haml][Haml] templates for code generation. This allows fully customizable
48
+ RDFa output in a variety of host languages. The [default template]({RDF::RDFa::Writer::DEFAULT_HAML})
49
+ generates human readable HTML5 output. A [minimal template]({RDF::RDFa::Writer::MIN_HAML})
50
+ generates HTML, which is not intended for human consumption.
51
+
52
+ To specify an alternative Haml template, consider the following:
53
+
54
+ require 'rdf/rdfa'
55
+
56
+ RDF::RDFa::Writer.buffer(:haml => RDF::RDFa::Writer::MIN_HAML) << graph
57
+
58
+ The template hash defines four Haml templates:
59
+
60
+ * _doc_: Document Template, takes an ordered list of _subject_s and yields each one to be rendered.
61
+ Described further in {RDF::RDFa::Writer#render_document}.
62
+
63
+ !!! XML
64
+ !!! 5
65
+ %html{:xmlns => "http://www.w3.org/1999/xhtml", :lang => lang, :profile => profile, :prefix => prefix}
66
+ - if base || title
67
+ %head
68
+ - if base
69
+ %base{:href => base}
70
+ - if title
71
+ %title= title
72
+ %body
73
+ - subjects.each do |subject|
74
+ != yield(subject)
75
+
76
+ This template takes locals _lang_, _profile_, _prefix_, _base_, _title_ in addition to _subjects_
77
+ to create output similar to the following:
78
+
79
+ <!DOCTYPE html>
80
+ <html prefix='xhv: http://www.w3.org/1999/xhtml/vocab#' xmlns='http://www.w3.org/1999/xhtml'>
81
+ <head>
82
+ <base href="http://example/">
83
+ <title>Document Title</title>
84
+ </head>
85
+ <body>
86
+ ...
87
+ </body>
88
+ </html>
89
+
90
+ Options passed to the Writer are used to supply _lang_, _profile_ and _base_ locals.
91
+ _prefix_ is generated based upon prefixes found from default or supplied profiles, as well
92
+ as those provided by a previous Reader. _title_ is taken from the first top-level subject
93
+ having an appropriate title property (as defined by the _heading_predicates_ option).
94
+
95
+ * _subject_: Subject Template, take a _subject_ and an order list of _predicate_s and yields
96
+ each _predicate_ to be rendered. Described further in {RDF::RDFa::Writer#render_subject}.
97
+
98
+ - if element == :li
99
+ %li{:about => get_curie(subject), :typeof => typeof}
100
+ - if typeof
101
+ %span.type!= typeof
102
+ - predicates.each do |predicate|
103
+ != yield(predicate)
104
+ - elsif rel && typeof
105
+ %div{:rel => get_curie(rel)}
106
+ %div{:about => get_curie(subject), :typeof => typeof}
107
+ %span.type!= typeof
108
+ - predicates.each do |predicate|
109
+ != yield(predicate)
110
+ - elsif rel
111
+ %div{:rel => get_curie(rel), :resource => get_curie(subject)}
112
+ - predicates.each do |predicate|
113
+ != yield(predicate)
114
+ - else
115
+ %div{:about => get_curie(subject), :typeof => typeof}
116
+ - if typeof
117
+ %span.type!= typeof
118
+ - predicates.each do |predicate|
119
+ != yield(predicate)
120
+
121
+ The template takes locals _rel_ and _typeof_ in addition to _predicates_ and _subject_ to
122
+ create output similar to the following:
123
+
124
+ <div about="http://example/">
125
+ ...
126
+ </div>
127
+
128
+ Note that if _typeof_ is defined, in this template, it will generate a textual description.
129
+
130
+ * _property\_value_: Property Value Template, used for predicates having a single value; takes
131
+ a _predicate_, and a single-valued Array of _objects_. Described further in {RDF::RDFa::Writer#render\_property}.
132
+
133
+ - object = objects.first
134
+ - if heading_predicates.include?(predicate) && object.literal?
135
+ %h1{:property => get_curie(predicate), :content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
136
+ - else
137
+ %div.property
138
+ %span.label
139
+ = get_predicate_name(predicate)
140
+ - if res = yield(object)
141
+ != res
142
+ - elsif object.node?
143
+ %span{:resource => get_curie(object), :rel => get_curie(predicate)}= get_curie(object)
144
+ - elsif object.uri?
145
+ %a{:href => object.to_s, :rel => get_curie(predicate)}= object.to_s
146
+ - elsif object.datatype == RDF.XMLLiteral
147
+ %span{:property => get_curie(predicate), :lang => get_lang(object), :datatype => get_dt_curie(object)}<!= get_value(object)
148
+ - else
149
+ %span{:property => get_curie(predicate), :content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
150
+
151
+ In addition to _predicate_ and _objects_, the template takes locals _property_ and/or _rel_, which are
152
+ copies of _predicate_ and indicate use in the @property or @rel attributes. Either or both may be
153
+ specified, as the conditions dictate.
154
+
155
+ Also, if the predicate is identified as a _heading predicate_ (via _:heading\_predicates_ option),
156
+ it will generate a heading element, and may use the value as the document title.
157
+
158
+ Each _object_ is yielded to the calling block, and the result is rendered, unless nil.
159
+ Otherwise, rendering depends on the type of _object_. This is useful for recursive document
160
+ descriptions.
161
+
162
+ Creates output similar to the following:
163
+
164
+ <div class='property'>
165
+ <span class='label'>
166
+ xhv:alternate
167
+ </span>
168
+ <a href='http://rdfa.info/feed/' rel='xhv:alternate'>http://rdfa.info/feed/</a>
169
+ </div>
170
+
171
+ Note the use of methods defined in {RDF::RDFa::Writer} useful in rendering the output.
172
+
173
+ * _property\_values_: Similar to _property\_value_, but for predicates having more than one value.
174
+ Locals are identical to _property\_values_, but _objects_ is expected to have more than one value.
175
+
176
+ %div.property
177
+ %span.label
178
+ = get_predicate_name(predicate)
179
+ %ul{:rel => (get_curie(rel) if rel), :property => (get_curie(property) if property)}
180
+ - objects.each do |object|
181
+ - if res = yield(object)
182
+ != res
183
+ - elsif object.node?
184
+ %li{:resource => get_curie(object)}= get_curie(object)
185
+ - elsif object.uri?
186
+ %li
187
+ %a{:href => object.to_s}= object.to_s
188
+ - elsif object.datatype == RDF.XMLLiteral
189
+ %li{:lang => get_lang(object), :datatype => get_curie(object.datatype)}<!= get_value(object)
190
+ - else
191
+ %li{:content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
192
+
193
+ In this case, and unordered list is used for output. Creates output similar to the following:
194
+
195
+ <div class='property'>
196
+ <span class='label'>
197
+ xhv:bookmark
198
+ </span>
199
+ <ul rel='xhv:bookmark'>
200
+ <li>
201
+ <a href='http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/'>
202
+ http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/
203
+ </a>
204
+ </li>
205
+ <a href='http://rdfa.info/2010/05/31/new-rdfa-checker/'>
206
+ http://rdfa.info/2010/05/31/new-rdfa-checker/
207
+ </a>
208
+ </li>
209
+ </ul>
210
+ </div>
211
+
212
+ ## Dependencies
213
+ * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.1)
214
+ * [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.3.3)
215
+ * [Haml](https://rubygems.org/gems/haml) (>= 3.0.0)
216
+
217
+ ## Documentation
218
+ Full documentation available on [RubyForge](http://rdf.rubyforge.org/rdfa)
219
+
220
+ ### Principle Classes
221
+ * {RDF::RDFa::Format}
222
+ * {RDF::RDFa::HTML}
223
+ Asserts :html format, text/html mime-type and .html file extension.
224
+ * {RDF::RDFa::XHTML}
225
+ Asserts :html format, application/xhtml+xml mime-type and .xhtml file extension.
226
+ * {RDF::RDFa::SVG}
227
+ Asserts :svg format, image/svg+xml mime-type and .svg file extension.
228
+ * {RDF::RDFa::Reader}
229
+ * {RDF::RDFa::Profile}
230
+ * {RDF::RDFa::Writer}
231
+
232
+ ### Additional vocabularies
233
+ * {RDF::PTR}
234
+ * {RDF::RDFA}
235
+ * {RDF::XHV}
236
+ * {RDF::XML}
237
+ * {RDF::XSI}
238
+
239
+ ## TODO
240
+ * Add support for LibXML and REXML bindings, and use the best available
241
+ * Consider a SAX-based parser for improved performance
242
+
243
+ ## Resources
244
+ * [RDF.rb][RDF.rb]
245
+ * [Distiller](http://distiller.kellogg-assoc)
246
+ * [Documentation](http://rdf.rubyforge.org/rdfa)
247
+ * [History](file:file.History.html)
248
+ * [RDFa 1.1 Core][RDFa 1.1 Core]
249
+ * [XHTML+RDFa 1.1][XHTML+RDFa 1.1]
250
+ * [RDFa-test-suite](http://rdfa.digitalbazaar.com/test-suite/ "RDFa test suite")
251
+
252
+ ## Author
253
+ * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
254
+
255
+ ## Contributors
256
+ * [Nicholas Humfrey](http://github.com/njh)
257
+
258
+ ## Contributing
259
+
260
+ * Do your best to adhere to the existing coding conventions and idioms.
261
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
262
+ * Do document every method you add using [YARD][] annotations. Read the
263
+ [tutorial][YARD-GS] or just look at the existing code for examples.
264
+ * Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
265
+ change them, do so on your private branch only.
266
+ * Do feel free to add yourself to the `CREDITS` file and the corresponding
267
+ list in the the `README`. Alphabetical order applies.
268
+ * Do note that in order for us to merge any non-trivial changes (as a rule
269
+ of thumb, additions larger than about 15 lines of code), we need an
270
+ explicit [public domain dedication][PDD] on record from you.
271
+
272
+ ## License
273
+
274
+ This is free and unencumbered public domain software. For more information,
275
+ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
276
+
277
+ ## FEEDBACK
278
+
279
+ * gregg@kellogg-assoc.com
280
+ * <http://rubygems.org/rdf-rdfa>
281
+ * <http://github.com/gkellogg/rdf-rdfa>
282
+ * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
283
+
284
+ [RDF.rb]: http://rdf.rubyforge.org/
285
+ [YARD]: http://yardoc.org/
286
+ [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
287
+ [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
288
+ [RDFa 1.1 Core]: http://www.w3.org/TR/2010/WD-rdfa-core-20100422/ "RDFa 1.1 Core"
289
+ [XHTML+RDFa 1.1]: http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100422/ "XHTML+RDFa 1.1"
290
+ [RDFa-test-suite]: http://rdfa.digitalbazaar.com/test-suite/ "RDFa test suite"
291
+ [Haml]: http://haml-lang.com/
data/README.md CHANGED
@@ -1,21 +1,24 @@
1
1
  # RDF::RDFa reader/writer
2
2
 
3
- RDFa parser for RDF.rb.
3
+ [RDFa][RDFa 1.1 Core] parser for RDF.rb.
4
4
 
5
5
  ## DESCRIPTION
6
- RDF::RDFa is an RDFa reader for Ruby using the [RDF.rb](http://rdf.rubyforge.org/) library suite.
6
+ RDF::RDFa is an RDFa reader and writer for Ruby using the [RDF.rb][RDF.rb] library suite.
7
7
 
8
8
  ## FEATURES
9
- RDF::RDFa parses RDFa into statements or triples.
9
+ RDF::RDFa parses [RDFa][RDFa 1.1 Core] into statements or triples.
10
10
 
11
- * Fully compliant XHTML/RDFa 1.1 parser.
12
- * Uses Nokogiri for parsing XHTML
13
- * RDFa tests use SPARQL for most tests due to Rasqal limitations. Other tests compare directly against N-triples.
11
+ * Fully compliant RDFa 1.1 parser.
12
+ * Template-based Writer to generate XHTML+RDFa.
13
+ * Writer uses user-replacable [Haml][Haml]-based templates to generate RDFa.
14
+ * Uses Nokogiri for parsing HTML/SVG
15
+ * [RDFa tests][RDFa-test-suite] use SPARQL for most tests due to Rasqal limitations. Other tests compare directly against N-triples.
14
16
 
15
17
  Install with 'gem install rdf-rdfa'
16
18
 
17
19
  ## Usage
18
- Instantiate a parser and parse source, specifying type and base-URL
20
+
21
+ ### Reading RDF data in the RDFa format
19
22
 
20
23
  RDF::RDFa::Reader.open("etc/foaf.html") do |reader|
21
24
  reader.each_statement do |statement|
@@ -23,17 +26,208 @@ Instantiate a parser and parse source, specifying type and base-URL
23
26
  end
24
27
  end
25
28
 
29
+ ### Writing RDF data using the XHTML+RDFa format
30
+
31
+ require 'rdf/rdfa'
32
+
33
+ RDF::RDFa::Writer.open("hello.html") do |writer|
34
+ writer << RDF::Graph.new do |graph|
35
+ graph << [:hello, RDF::DC.title, "Hello, world!"]
36
+ end
37
+ end
38
+
39
+ Note that prefixes may be chained between Reader and Writer, so that the Writer will
40
+ use the same prefix definitions found during parsing:
41
+
42
+ prefixes = {}
43
+ graph = RDF::Graph.load("etc/foaf.html", :prefixes => prefixes)
44
+ puts graph.dump(:rdfa, :prefixes => prefixes)
45
+
46
+ ### Template-based Writer
47
+ The RDFa writer uses [Haml][Haml] templates for code generation. This allows fully customizable
48
+ RDFa output in a variety of host languages. The [default template]({RDF::RDFa::Writer::DEFAULT_HAML})
49
+ generates human readable HTML5 output. A [minimal template]({RDF::RDFa::Writer::MIN_HAML})
50
+ generates HTML, which is not intended for human consumption.
51
+
52
+ To specify an alternative Haml template, consider the following:
53
+
54
+ require 'rdf/rdfa'
55
+
56
+ RDF::RDFa::Writer.buffer(:haml => RDF::RDFa::Writer::MIN_HAML) << graph
57
+
58
+ The template hash defines four Haml templates:
59
+
60
+ * _doc_: Document Template, takes an ordered list of _subject_s and yields each one to be rendered.
61
+ Described further in {RDF::RDFa::Writer#render_document}.
62
+
63
+ !!! XML
64
+ !!! 5
65
+ %html{:xmlns => "http://www.w3.org/1999/xhtml", :lang => lang, :profile => profile, :prefix => prefix}
66
+ - if base || title
67
+ %head
68
+ - if base
69
+ %base{:href => base}
70
+ - if title
71
+ %title= title
72
+ %body
73
+ - subjects.each do |subject|
74
+ != yield(subject)
75
+
76
+ This template takes locals _lang_, _profile_, _prefix_, _base_, _title_ in addition to _subjects_
77
+ to create output similar to the following:
78
+
79
+ <!DOCTYPE html>
80
+ <html prefix='xhv: http://www.w3.org/1999/xhtml/vocab#' xmlns='http://www.w3.org/1999/xhtml'>
81
+ <head>
82
+ <base href="http://example/">
83
+ <title>Document Title</title>
84
+ </head>
85
+ <body>
86
+ ...
87
+ </body>
88
+ </html>
89
+
90
+ Options passed to the Writer are used to supply _lang_, _profile_ and _base_ locals.
91
+ _prefix_ is generated based upon prefixes found from default or supplied profiles, as well
92
+ as those provided by a previous Reader. _title_ is taken from the first top-level subject
93
+ having an appropriate title property (as defined by the _heading_predicates_ option).
94
+
95
+ * _subject_: Subject Template, take a _subject_ and an order list of _predicate_s and yields
96
+ each _predicate_ to be rendered. Described further in {RDF::RDFa::Writer#render_subject}.
97
+
98
+ - if element == :li
99
+ %li{:about => get_curie(subject), :typeof => typeof}
100
+ - if typeof
101
+ %span.type!= typeof
102
+ - predicates.each do |predicate|
103
+ != yield(predicate)
104
+ - elsif rel && typeof
105
+ %div{:rel => get_curie(rel)}
106
+ %div{:about => get_curie(subject), :typeof => typeof}
107
+ %span.type!= typeof
108
+ - predicates.each do |predicate|
109
+ != yield(predicate)
110
+ - elsif rel
111
+ %div{:rel => get_curie(rel), :resource => get_curie(subject)}
112
+ - predicates.each do |predicate|
113
+ != yield(predicate)
114
+ - else
115
+ %div{:about => get_curie(subject), :typeof => typeof}
116
+ - if typeof
117
+ %span.type!= typeof
118
+ - predicates.each do |predicate|
119
+ != yield(predicate)
120
+
121
+ The template takes locals _rel_ and _typeof_ in addition to _predicates_ and _subject_ to
122
+ create output similar to the following:
123
+
124
+ <div about="http://example/">
125
+ ...
126
+ </div>
127
+
128
+ Note that if _typeof_ is defined, in this template, it will generate a textual description.
129
+
130
+ * _property\_value_: Property Value Template, used for predicates having a single value; takes
131
+ a _predicate_, and a single-valued Array of _objects_. Described further in {RDF::RDFa::Writer#render\_property}.
132
+
133
+ - object = objects.first
134
+ - if heading_predicates.include?(predicate) && object.literal?
135
+ %h1{:property => get_curie(predicate), :content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
136
+ - else
137
+ %div.property
138
+ %span.label
139
+ = get_predicate_name(predicate)
140
+ - if res = yield(object)
141
+ != res
142
+ - elsif object.node?
143
+ %span{:resource => get_curie(object), :rel => get_curie(predicate)}= get_curie(object)
144
+ - elsif object.uri?
145
+ %a{:href => object.to_s, :rel => get_curie(predicate)}= object.to_s
146
+ - elsif object.datatype == RDF.XMLLiteral
147
+ %span{:property => get_curie(predicate), :lang => get_lang(object), :datatype => get_dt_curie(object)}<!= get_value(object)
148
+ - else
149
+ %span{:property => get_curie(predicate), :content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
150
+
151
+ In addition to _predicate_ and _objects_, the template takes locals _property_ and/or _rel_, which are
152
+ copies of _predicate_ and indicate use in the @property or @rel attributes. Either or both may be
153
+ specified, as the conditions dictate.
154
+
155
+ Also, if the predicate is identified as a _heading predicate_ (via _:heading\_predicates_ option),
156
+ it will generate a heading element, and may use the value as the document title.
157
+
158
+ Each _object_ is yielded to the calling block, and the result is rendered, unless nil.
159
+ Otherwise, rendering depends on the type of _object_. This is useful for recursive document
160
+ descriptions.
161
+
162
+ Creates output similar to the following:
163
+
164
+ <div class='property'>
165
+ <span class='label'>
166
+ xhv:alternate
167
+ </span>
168
+ <a href='http://rdfa.info/feed/' rel='xhv:alternate'>http://rdfa.info/feed/</a>
169
+ </div>
170
+
171
+ Note the use of methods defined in {RDF::RDFa::Writer} useful in rendering the output.
172
+
173
+ * _property\_values_: Similar to _property\_value_, but for predicates having more than one value.
174
+ Locals are identical to _property\_values_, but _objects_ is expected to have more than one value.
175
+
176
+ %div.property
177
+ %span.label
178
+ = get_predicate_name(predicate)
179
+ %ul{:rel => (get_curie(rel) if rel), :property => (get_curie(property) if property)}
180
+ - objects.each do |object|
181
+ - if res = yield(object)
182
+ != res
183
+ - elsif object.node?
184
+ %li{:resource => get_curie(object)}= get_curie(object)
185
+ - elsif object.uri?
186
+ %li
187
+ %a{:href => object.to_s}= object.to_s
188
+ - elsif object.datatype == RDF.XMLLiteral
189
+ %li{:lang => get_lang(object), :datatype => get_curie(object.datatype)}<!= get_value(object)
190
+ - else
191
+ %li{:content => get_content(object), :lang => get_lang(object), :datatype => get_dt_curie(object)}&= get_value(object)
192
+
193
+ In this case, and unordered list is used for output. Creates output similar to the following:
194
+
195
+ <div class='property'>
196
+ <span class='label'>
197
+ xhv:bookmark
198
+ </span>
199
+ <ul rel='xhv:bookmark'>
200
+ <li>
201
+ <a href='http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/'>
202
+ http://rdfa.info/2009/12/12/oreilly-catalog-uses-rdfa/
203
+ </a>
204
+ </li>
205
+ <a href='http://rdfa.info/2010/05/31/new-rdfa-checker/'>
206
+ http://rdfa.info/2010/05/31/new-rdfa-checker/
207
+ </a>
208
+ </li>
209
+ </ul>
210
+ </div>
211
+
26
212
  ## Dependencies
27
- * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.0)
213
+ * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.1)
28
214
  * [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.3.3)
215
+ * [Haml](https://rubygems.org/gems/haml) (>= 3.0.0)
29
216
 
30
217
  ## Documentation
31
218
  Full documentation available on [RubyForge](http://rdf.rubyforge.org/rdfa)
32
219
 
33
220
  ### Principle Classes
34
221
  * {RDF::RDFa::Format}
222
+ * {RDF::RDFa::HTML}
223
+ Asserts :html format, text/html mime-type and .html file extension.
224
+ * {RDF::RDFa::XHTML}
225
+ Asserts :html format, application/xhtml+xml mime-type and .xhtml file extension.
226
+ * {RDF::RDFa::SVG}
227
+ Asserts :svg format, image/svg+xml mime-type and .svg file extension.
35
228
  * {RDF::RDFa::Reader}
36
229
  * {RDF::RDFa::Profile}
230
+ * {RDF::RDFa::Writer}
37
231
 
38
232
  ### Additional vocabularies
39
233
  * {RDF::PTR}
@@ -45,47 +239,53 @@ Full documentation available on [RubyForge](http://rdf.rubyforge.org/rdfa)
45
239
  ## TODO
46
240
  * Add support for LibXML and REXML bindings, and use the best available
47
241
  * Consider a SAX-based parser for improved performance
48
- * Port SPARQL tests to native SPARQL processor, when one becomes available.
49
- * Add generic XHTML+RDFa Writer
50
242
 
51
243
  ## Resources
52
- * [RDF.rb](http://rdf.rubyforge.org/)
244
+ * [RDF.rb][RDF.rb]
53
245
  * [Distiller](http://distiller.kellogg-assoc)
54
246
  * [Documentation](http://rdf.rubyforge.org/rdfa)
55
247
  * [History](file:file.History.html)
56
- * [RDFa 1.1 Core](http://www.w3.org/TR/2010/WD-rdfa-core-20100422/ "RDFa 1.1 Core")
57
- * [XHTML+RDFa 1.1 Core](http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100422/ "XHTML+RDFa 1.1 Core")
248
+ * [RDFa 1.1 Core][RDFa 1.1 Core]
249
+ * [XHTML+RDFa 1.1][XHTML+RDFa 1.1]
58
250
  * [RDFa-test-suite](http://rdfa.digitalbazaar.com/test-suite/ "RDFa test suite")
59
251
 
60
- ## LICENSE
252
+ ## Author
253
+ * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
61
254
 
62
- (The MIT License)
255
+ ## Contributors
256
+ * [Nicholas Humfrey](http://github.com/njh)
63
257
 
64
- Copyright (c) 2009-2010 Gregg Kellogg
258
+ ## Contributing
65
259
 
66
- Permission is hereby granted, free of charge, to any person obtaining
67
- a copy of this software and associated documentation files (the
68
- 'Software'), to deal in the Software without restriction, including
69
- without limitation the rights to use, copy, modify, merge, publish,
70
- distribute, sublicense, and/or sell copies of the Software, and to
71
- permit persons to whom the Software is furnished to do so, subject to
72
- the following conditions:
260
+ * Do your best to adhere to the existing coding conventions and idioms.
261
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
262
+ * Do document every method you add using [YARD][] annotations. Read the
263
+ [tutorial][YARD-GS] or just look at the existing code for examples.
264
+ * Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
265
+ change them, do so on your private branch only.
266
+ * Do feel free to add yourself to the `CREDITS` file and the corresponding
267
+ list in the the `README`. Alphabetical order applies.
268
+ * Do note that in order for us to merge any non-trivial changes (as a rule
269
+ of thumb, additions larger than about 15 lines of code), we need an
270
+ explicit [public domain dedication][PDD] on record from you.
73
271
 
74
- The above copyright notice and this permission notice shall be
75
- included in all copies or substantial portions of the Software.
272
+ ## License
76
273
 
77
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
78
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
80
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
81
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
82
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
83
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
274
+ This is free and unencumbered public domain software. For more information,
275
+ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
84
276
 
85
277
  ## FEEDBACK
86
278
 
87
279
  * gregg@kellogg-assoc.com
88
- * rubygems.org/rdf-rdfa
89
- * github.com/gkellogg/rdf-rdfa
90
- * gkellogg.lighthouseapp.com for bug reports
91
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
280
+ * <http://rubygems.org/rdf-rdfa>
281
+ * <http://github.com/gkellogg/rdf-rdfa>
282
+ * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
283
+
284
+ [RDF.rb]: http://rdf.rubyforge.org/
285
+ [YARD]: http://yardoc.org/
286
+ [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
287
+ [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
288
+ [RDFa 1.1 Core]: http://www.w3.org/TR/2010/WD-rdfa-core-20100422/ "RDFa 1.1 Core"
289
+ [XHTML+RDFa 1.1]: http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100422/ "XHTML+RDFa 1.1"
290
+ [RDFa-test-suite]: http://rdfa.digitalbazaar.com/test-suite/ "RDFa test suite"
291
+ [Haml]: http://haml-lang.com/