rdf-microdata 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -2
- data/VERSION +1 -1
- data/etc/registry.json +11 -0
- data/lib/rdf/microdata.rb +6 -3
- data/lib/rdf/microdata/expansion.rb +159 -0
- data/lib/rdf/microdata/reader.rb +75 -23
- data/lib/rdf/microdata/reader/nokogiri.rb +3 -3
- data/lib/rdf/microdata/reader/rexml.rb +5 -5
- metadata +35 -2
data/README
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# RDF::Microdata reader/writer
|
2
|
+
[![Build Status](https://secure.travis-ci.org/ruby-rdf/rdf-microdata.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-microdata)
|
2
3
|
|
3
4
|
[Microdata][] parser for RDF.rb.
|
4
5
|
|
@@ -28,7 +29,9 @@ The parser uses a build-in version of the [Microdata RDF][] registry.
|
|
28
29
|
|
29
30
|
## Note
|
30
31
|
This spec is based on the W3C HTML Data Task Force specification and does not support
|
31
|
-
GRDDL-type triple generation, such as for html>head>title
|
32
|
+
GRDDL-type triple generation, such as for html>head>title anchor tags.
|
33
|
+
|
34
|
+
If the `RDFa` parser is available, {RDF::Microdata::Format} will not assert content type `text/html` or file extension `.html`, as this is also asserted by RDFa. Instead, the RDFa reader will invoke the microdata reader if an `@itemscope` attribute is detected.
|
32
35
|
|
33
36
|
## Dependencies
|
34
37
|
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.4)
|
@@ -93,5 +96,5 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
|
93
96
|
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
94
97
|
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
95
98
|
[Microdata]: http://dev.w3.org/html5/md/Overview.html "HTML Microdata"
|
96
|
-
[Microdata RDF]:
|
99
|
+
[Microdata RDF]: http://dvcs.w3.org/hg/htmldata/raw-file/default/microdata-rdf/index.html "Microdata to RDF"
|
97
100
|
[Microdata doc]: http://rubydoc.info/github/ruby-rdf/rdf-microdata/frames
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/etc/registry.json
CHANGED
@@ -3,21 +3,32 @@
|
|
3
3
|
"propertyURI": "vocabulary",
|
4
4
|
"multipleValues": "unordered",
|
5
5
|
"properties": {
|
6
|
+
"additionalType": {"subPropertyOf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"},
|
7
|
+
"blogPosts": {"multipleValues": "list"},
|
6
8
|
"blogPosts": {"multipleValues": "list"},
|
7
9
|
"breadcrumb": {"multipleValues": "list"},
|
8
10
|
"byArtist": {"multipleValues": "list"},
|
9
11
|
"creator": {"multipleValues": "list"},
|
12
|
+
"episode": {"multipleValues": "list"},
|
10
13
|
"episodes": {"multipleValues": "list"},
|
14
|
+
"event": {"multipleValues": "list"},
|
11
15
|
"events": {"multipleValues": "list"},
|
16
|
+
"founder": {"multipleValues": "list"},
|
12
17
|
"founders": {"multipleValues": "list"},
|
13
18
|
"itemListElement": {"multipleValues": "list"},
|
14
19
|
"musicGroupMember": {"multipleValues": "list"},
|
15
20
|
"performerIn": {"multipleValues": "list"},
|
21
|
+
"actor": {"multipleValues": "list"},
|
22
|
+
"actors": {"multipleValues": "list"},
|
23
|
+
"performer": {"multipleValues": "list"},
|
16
24
|
"performers": {"multipleValues": "list"},
|
17
25
|
"producer": {"multipleValues": "list"},
|
18
26
|
"recipeInstructions": {"multipleValues": "list"},
|
27
|
+
"season": {"multipleValues": "list"},
|
19
28
|
"seasons": {"multipleValues": "list"},
|
29
|
+
"subEvent": {"multipleValues": "list"},
|
20
30
|
"subEvents": {"multipleValues": "list"},
|
31
|
+
"track": {"multipleValues": "list"},
|
21
32
|
"tracks": {"multipleValues": "list"}
|
22
33
|
}
|
23
34
|
},
|
data/lib/rdf/microdata.rb
CHANGED
@@ -20,11 +20,14 @@ module RDF
|
|
20
20
|
#
|
21
21
|
# @author [Gregg Kellogg](http://greggkellogg.net/)
|
22
22
|
module Microdata
|
23
|
+
USES_VOCAB = RDF::URI("http://www.w3.org/ns/rdfa#usesVocabulary")
|
24
|
+
|
23
25
|
require 'rdf/microdata/format'
|
24
26
|
require 'rdf/microdata/vocab'
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :
|
27
|
+
autoload :Expansion, 'rdf/microdata/expansion'
|
28
|
+
autoload :Profile, 'rdf/microdata/profile'
|
29
|
+
autoload :Reader, 'rdf/microdata/reader'
|
30
|
+
autoload :VERSION, 'rdf/microdata/version'
|
28
31
|
|
29
32
|
def self.debug?; @debug; end
|
30
33
|
def self.debug=(value); @debug = value; end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
module RDF::Microdata
|
2
|
+
##
|
3
|
+
# The Expansion module performs a subset of OWL entailment rules on the base class,
|
4
|
+
# which implementes RDF::Readable.
|
5
|
+
module Expansion
|
6
|
+
##
|
7
|
+
# Perform vocabulary expansion on the resulting default graph.
|
8
|
+
#
|
9
|
+
# Vocabulary expansion relies on a sub-set of OWL [OWL2-PROFILES](http://www.w3.org/TR/2009/REC-owl2-profiles-20091027/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules) entailment to add triples to the default graph based on rules and property/class relationships described in referenced vocabularies.
|
10
|
+
#
|
11
|
+
# For all objects that are the target of an rdfa:usesVocabulary property, load the IRI into a repository.
|
12
|
+
#
|
13
|
+
# Subsequently, perform OWL expansion using rules prp-spo1, prp-eqp1, and prp-eqp2 placing resulting triples into the default graph. Iterate on this step until no more triples are added.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# scm-spo
|
17
|
+
# {pq rdfs:subPropertyOf pw . pw rdfs:subPropertyOf p3}
|
18
|
+
# => {p1 rdfs:subPropertyOf p3}
|
19
|
+
#
|
20
|
+
# rdprp-spo1fs7
|
21
|
+
# {p1 rdfs:subPropertyOf p2 . x p1 y} => {x p2 y}
|
22
|
+
#
|
23
|
+
# @return [RDF::Graph]
|
24
|
+
# @see [OWL2 PROFILES][]
|
25
|
+
def expand
|
26
|
+
repo = RDF::Repository.new
|
27
|
+
repo << self # Add default graph
|
28
|
+
|
29
|
+
count = repo.count
|
30
|
+
add_debug("expand") {"Loaded #{repo.size} triples into default graph"}
|
31
|
+
|
32
|
+
repo = owl_entailment(repo)
|
33
|
+
|
34
|
+
# Return graph with default context
|
35
|
+
graph = RDF::Graph.new
|
36
|
+
repo.statements.each {|st| graph << st if st.context.nil?}
|
37
|
+
graph
|
38
|
+
end
|
39
|
+
|
40
|
+
def rule(name, &block)
|
41
|
+
Rule.new(name, block)
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# An entailment rule
|
46
|
+
#
|
47
|
+
# Takes a list of antecedent patterns used to find solutions against a queryable
|
48
|
+
# object. Yields each consequent with bindings from the solution
|
49
|
+
class Rule
|
50
|
+
# @attr [Array<RDF::Query::Pattern>]
|
51
|
+
attr_reader :antecedents
|
52
|
+
|
53
|
+
# @attr [Array<RDF::Query::Pattern>]
|
54
|
+
attr_reader :consequents
|
55
|
+
|
56
|
+
# @attr [String] name
|
57
|
+
attr_reader :name
|
58
|
+
|
59
|
+
##
|
60
|
+
# @example
|
61
|
+
# r = Rule.new("scm-spo") do
|
62
|
+
# antecedent :p1, RDF::RDFS.subPropertyOf, :p2
|
63
|
+
# antecedent :p2, RDF::RDFS.subPropertyOf, :p3
|
64
|
+
# consequent :p1, RDF::RDFS.subPropertyOf, :p3, "t-box"
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# r.execute(queryable) {|statement| puts statement.inspect}
|
68
|
+
#
|
69
|
+
# @param [String] name
|
70
|
+
def initialize(name, &block)
|
71
|
+
@antecedents = []
|
72
|
+
@consequents = []
|
73
|
+
@name = name
|
74
|
+
|
75
|
+
if block_given?
|
76
|
+
case block.arity
|
77
|
+
when 1 then block.call(self)
|
78
|
+
else instance_eval(&block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def antecedent(subject, prediate, object, context = nil)
|
84
|
+
antecedents << RDF::Query::Pattern.new(subject, prediate, object, :context => context)
|
85
|
+
end
|
86
|
+
|
87
|
+
def consequent(subject, prediate, object, context = nil)
|
88
|
+
consequents << RDF::Query::Pattern.new(subject, prediate, object, :context => context)
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Execute the rule against queryable, yielding each consequent with bindings
|
93
|
+
#
|
94
|
+
# @param [RDF::Queryable] queryable
|
95
|
+
# @yield [statement]
|
96
|
+
# @yieldparam [RDF::Statement] statement
|
97
|
+
def execute(queryable)
|
98
|
+
RDF::Query.new(antecedents).execute(queryable).each do |solution|
|
99
|
+
nodes = {}
|
100
|
+
consequents.each do |consequent|
|
101
|
+
terms = {}
|
102
|
+
[:subject, :predicate, :object, :context].each do |r|
|
103
|
+
terms[r] = case o = consequent.send(r)
|
104
|
+
when RDF::Node then nodes[o] ||= RDF::Node.new
|
105
|
+
when RDF::Query::Variable then solution[o]
|
106
|
+
else o
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
yield RDF::Statement.from(terms)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
RULES = [
|
119
|
+
Rule.new("prp-spo1") do
|
120
|
+
antecedent :p1, RDF::RDFS.subPropertyOf, :p2
|
121
|
+
antecedent :x, :p1, :y
|
122
|
+
consequent :x, :p2, :y
|
123
|
+
end,
|
124
|
+
Rule.new("prp-eqp1") do
|
125
|
+
antecedent :p1, RDF::OWL.equivalentProperty, :p2
|
126
|
+
antecedent :x, :p1, :y
|
127
|
+
consequent :x, :p2, :y
|
128
|
+
end,
|
129
|
+
Rule.new("prp-eqp2") do
|
130
|
+
antecedent :p1, RDF::OWL.equivalentProperty, :p2
|
131
|
+
antecedent :x, :p2, :y
|
132
|
+
consequent :x, :p1, :y
|
133
|
+
end,
|
134
|
+
]
|
135
|
+
|
136
|
+
##
|
137
|
+
# Perform OWL entailment rules on enumerable
|
138
|
+
# @param [RDF::Enumerable] repo
|
139
|
+
# @return [RDF::Enumerable]
|
140
|
+
def owl_entailment(repo)
|
141
|
+
old_count = 0
|
142
|
+
|
143
|
+
while old_count < (count = repo.count)
|
144
|
+
add_debug("entailment", "old: #{old_count} count: #{count}")
|
145
|
+
old_count = count
|
146
|
+
|
147
|
+
RULES.each do |rule|
|
148
|
+
rule.execute(repo) do |statement|
|
149
|
+
add_debug("entailment(#{rule.name})") {statement.inspect}
|
150
|
+
repo << statement
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
add_debug("entailment", "final count: #{count}")
|
156
|
+
repo
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
data/lib/rdf/microdata/reader.rb
CHANGED
@@ -13,15 +13,16 @@ module RDF::Microdata
|
|
13
13
|
#
|
14
14
|
# Based on processing rules, amended with the following:
|
15
15
|
#
|
16
|
-
# @see
|
16
|
+
# @see http://dvcs.w3.org/hg/htmldata/raw-file/0d6b89f5befb/microdata-rdf/index.html
|
17
17
|
# @author [Gregg Kellogg](http://greggkellogg.net/)
|
18
18
|
class Reader < RDF::Reader
|
19
19
|
format Format
|
20
|
+
include Expansion
|
20
21
|
URL_PROPERTY_ELEMENTS = %w(a area audio embed iframe img link object source track video)
|
21
22
|
DEFAULT_REGISTRY = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "etc", "registry.json"))
|
22
|
-
|
23
|
-
|
24
|
-
end
|
23
|
+
|
24
|
+
# @private
|
25
|
+
class CrawlFailure < StandardError; end
|
25
26
|
|
26
27
|
# Returns the HTML implementation module for this reader instance.
|
27
28
|
#
|
@@ -42,6 +43,9 @@ module RDF::Microdata
|
|
42
43
|
|
43
44
|
# Interface to registry
|
44
45
|
class Registry
|
46
|
+
# @attr_reader [RDF::URI] uri Prefix of vocabulary
|
47
|
+
attr_reader :uri
|
48
|
+
|
45
49
|
##
|
46
50
|
# Initialize the registry from a URI or file path
|
47
51
|
#
|
@@ -50,7 +54,7 @@ module RDF::Microdata
|
|
50
54
|
return if @registry_uri == registry_uri
|
51
55
|
|
52
56
|
json = RDF::Util::File.open_file(registry_uri) { |f| JSON.load(f) }
|
53
|
-
|
57
|
+
|
54
58
|
@prefixes = {}
|
55
59
|
json.each do |prefix, elements|
|
56
60
|
next unless elements.is_a?(Hash)
|
@@ -76,6 +80,7 @@ module RDF::Microdata
|
|
76
80
|
# @param [#to_sym] multipleValues (:unordered)
|
77
81
|
# @param [Hash] properties ({})
|
78
82
|
def initialize(prefixURI, propertyURI = :vocabulary, multipleValues = :unordered, properties = {})
|
83
|
+
@uri = prefixURI
|
79
84
|
@scheme = propertyURI.to_sym
|
80
85
|
@multipleValues = multipleValues.to_sym
|
81
86
|
@properties = properties
|
@@ -112,29 +117,26 @@ module RDF::Microdata
|
|
112
117
|
n = frag_escape(name)
|
113
118
|
if ec[:current_type].nil?
|
114
119
|
# 2) If current type from context is null, there can be no current vocabulary.
|
115
|
-
# Return the URI reference that is the document base with its fragment set to
|
116
|
-
# the fragment-escaped value of name
|
120
|
+
# Return the URI reference that is the document base with its fragment set to the fragment-escaped value of name
|
117
121
|
u = RDF::URI(ec[:document_base].to_s)
|
118
122
|
u.fragment = frag_escape(name)
|
119
123
|
u
|
120
124
|
elsif @scheme == :vocabulary
|
121
|
-
# 4) If scheme is vocabulary return the URI reference constructed by appending the fragment escaped value of name
|
122
|
-
# to current vocabulary, separated by a U+0023 NUMBER SIGN character (#) unless the current vocabulary ends
|
123
|
-
# with either a U+0023 NUMBER SIGN character (#) or SOLIDUS U+002F (/).
|
125
|
+
# 4) If scheme is vocabulary return the URI reference constructed by appending the fragment escaped value of name to current vocabulary, separated by a U+0023 NUMBER SIGN character (#) unless the current vocabulary ends with either a U+0023 NUMBER SIGN character (#) or SOLIDUS U+002F (/).
|
124
126
|
RDF::URI(@property_base + n)
|
125
127
|
else # @scheme == :contextual
|
126
128
|
if ec[:current_name].to_s.index(@property_base) == 0
|
127
129
|
# 5.2) return the concatenation of s, a U+002E FULL STOP character (.) and the fragment-escaped value of name.
|
128
130
|
RDF::URI(ec[:current_name] + '.' + n)
|
129
131
|
else
|
130
|
-
# 5.3) return the concatenation of http://www.w3.org/ns/md?type=, the fragment-escaped value of current type,
|
131
|
-
|
132
|
-
|
132
|
+
# 5.3) return the concatenation of http://www.w3.org/ns/md?type=, the fragment-escaped value of current type, the string &prop=, and the fragment-escaped value of name
|
133
|
+
RDF::URI(@property_base +
|
134
|
+
frag_escape(ec[:current_type]) +
|
135
|
+
'&prop=' + n)
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
136
|
-
|
137
|
-
|
139
|
+
|
138
140
|
##
|
139
141
|
# Turn a predicateURI into a simple token
|
140
142
|
# @param [RDF::URI] predicateURI
|
@@ -154,13 +156,40 @@ module RDF::Microdata
|
|
154
156
|
# @return [Boolean]
|
155
157
|
def as_list(predicateURI)
|
156
158
|
tok = tokenize(predicateURI)
|
157
|
-
if @properties[tok].is_a?(Hash)
|
159
|
+
if @properties[tok].is_a?(Hash) &&
|
160
|
+
@properties[tok].has_key?("multipleValues")
|
158
161
|
@properties[tok]["multipleValues"].to_sym == :list
|
159
162
|
else
|
160
163
|
@multipleValues == :list
|
161
164
|
end
|
162
165
|
end
|
163
166
|
|
167
|
+
##
|
168
|
+
# Yield a equivalentProperty or subPropertyOf if appropriate
|
169
|
+
# @param [RDF::URI] predicateURI
|
170
|
+
# @yield statement
|
171
|
+
# @yieldparam [RDF::Statement] statement
|
172
|
+
# @return [Boolean]
|
173
|
+
def expand(predicateURI)
|
174
|
+
tok = tokenize(predicateURI)
|
175
|
+
if @properties[tok].is_a?(Hash)
|
176
|
+
if value = @properties[tok]["equivalentProperty"]
|
177
|
+
[value].flatten.each do |v|
|
178
|
+
yield RDF::Statement.new(predicateURI,
|
179
|
+
RDF::OWL.equivalentProperty,
|
180
|
+
RDF::URI(v))
|
181
|
+
end
|
182
|
+
elsif value = @properties[tok]["subPropertyOf"]
|
183
|
+
[value].flatten.each do |v|
|
184
|
+
yield RDF::Statement.new(predicateURI,
|
185
|
+
RDF::RDFS.subPropertyOf,
|
186
|
+
RDF::URI(v))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
value = @properties[tok]
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
164
193
|
##
|
165
194
|
# Fragment escape a name
|
166
195
|
def frag_escape(name)
|
@@ -188,16 +217,19 @@ module RDF::Microdata
|
|
188
217
|
# @option options [#to_s] :base_uri (nil)
|
189
218
|
# the base URI to use when resolving relative URIs
|
190
219
|
# @option options [#to_s] :registry_uri (DEFAULT_REGISTRY)
|
220
|
+
# @option options [Boolean] :vocab_expansion (true)
|
221
|
+
# whether to perform OWL2 expansion on the resulting graph
|
191
222
|
# @option options [Array] :debug
|
192
223
|
# Array to place debug messages
|
193
224
|
# @return [reader]
|
194
225
|
# @yield [reader] `self`
|
195
226
|
# @yieldparam [RDF::Reader] reader
|
196
227
|
# @yieldreturn [void] ignored
|
197
|
-
# @raise [Error]
|
228
|
+
# @raise [Error] Raises `RDF::ReaderError` when validating
|
198
229
|
def initialize(input = $stdin, options = {}, &block)
|
199
230
|
super do
|
200
231
|
@debug = options[:debug]
|
232
|
+
@vocab_expansion = options.fetch(:vocab_expansion, true)
|
201
233
|
|
202
234
|
@library = case options[:library]
|
203
235
|
when nil
|
@@ -223,11 +255,12 @@ module RDF::Microdata
|
|
223
255
|
errors = doc_errors.reject {|e| e.to_s =~ /Tag (audio|source|track|video|time) invalid/}
|
224
256
|
raise RDF::ReaderError, "Syntax errors:\n#{errors}" if !errors.empty? && validate?
|
225
257
|
|
226
|
-
add_debug(@doc, "library = #{@library}")
|
258
|
+
add_debug(@doc, "library = #{@library}, expand = #{@vocab_expansion}")
|
227
259
|
|
228
260
|
# Load registry
|
229
261
|
begin
|
230
262
|
registry_uri = options[:registry_uri] || DEFAULT_REGISTRY
|
263
|
+
add_debug(@doc, "registry = #{registry_uri}")
|
231
264
|
Registry.load_registry(registry_uri)
|
232
265
|
rescue JSON::ParserError => e
|
233
266
|
raise RDF::ReaderError, "Failed to parse registry: #{e.message}"
|
@@ -245,14 +278,22 @@ module RDF::Microdata
|
|
245
278
|
##
|
246
279
|
# Iterates the given block for each RDF statement in the input.
|
247
280
|
#
|
281
|
+
# Reads to graph and performs expansion if required.
|
282
|
+
#
|
248
283
|
# @yield [statement]
|
249
284
|
# @yieldparam [RDF::Statement] statement
|
250
285
|
# @return [void]
|
251
286
|
def each_statement(&block)
|
252
|
-
@
|
287
|
+
if @vocab_expansion
|
288
|
+
@vocab_expansion = false
|
289
|
+
expand.each_statement(&block)
|
290
|
+
@vocab_expansion = true
|
291
|
+
else
|
292
|
+
@callback = block
|
253
293
|
|
254
|
-
|
255
|
-
|
294
|
+
# parse
|
295
|
+
parse_whole_document(@doc, base_uri)
|
296
|
+
end
|
256
297
|
end
|
257
298
|
|
258
299
|
##
|
@@ -396,9 +437,10 @@ module RDF::Microdata
|
|
396
437
|
type ||= ec[:current_type]
|
397
438
|
add_debug(item) {"gentrips(6): type=#{type.inspect}"}
|
398
439
|
|
399
|
-
# 7) If the registry contains a URI prefix that is a character for character match of type up to the length of the
|
400
|
-
# URI prefix, set vocab as that URI prefix
|
440
|
+
# 7) If the registry contains a URI prefix that is a character for character match of type up to the length of the URI prefix, set vocab as that URI prefix and generate the following triple (unless it has already been generated):
|
401
441
|
vocab = Registry.find(type)
|
442
|
+
add_debug(item) {"gentrips(7): vocab=#{vocab.inspect}"}
|
443
|
+
add_triple(item, base_uri, USES_VOCAB, RDF::URI(vocab.uri)) if vocab
|
402
444
|
|
403
445
|
# 8) Otherwise, if type is not empty, construct vocab by removing everything following the last
|
404
446
|
# SOLIDUS U+002F ("/") or NUMBER SIGN U+0023 ("#") from the path component of type.
|
@@ -427,6 +469,15 @@ module RDF::Microdata
|
|
427
469
|
|
428
470
|
# 11.1.2) Let predicate be the result of generate predicate URI using context and name. Update context by setting current name to predicate.
|
429
471
|
predicate = vocab.predicateURI(name, ec_new)
|
472
|
+
|
473
|
+
# (Generate Predicate URI steps 6 and 7)
|
474
|
+
vocab.expand(predicate) do |statement|
|
475
|
+
add_debug(item) {
|
476
|
+
"gentrips(11.1.2): expansion #{statement.inspect}"
|
477
|
+
}
|
478
|
+
@callback.call(statement)
|
479
|
+
end
|
480
|
+
|
430
481
|
ec_new[:current_name] = predicate
|
431
482
|
add_debug(item) {"gentrips(11.1.2): predicate=#{predicate}"}
|
432
483
|
|
@@ -459,6 +510,7 @@ module RDF::Microdata
|
|
459
510
|
# If the registry contains a URI prefix that is a character for character match of predicate up to the length
|
460
511
|
# of the URI prefix, set vocab as that URI prefix. Otherwise set vocab to null
|
461
512
|
registry = Registry.find(predicate)
|
513
|
+
add_debug("generatePropertyValues") { "list(#{predicate})? #{registry.as_list(predicate).inspect}"} if registry
|
462
514
|
if registry && registry.as_list(predicate)
|
463
515
|
value = generateRDFCollection(element, values)
|
464
516
|
add_triple(element, subject, predicate, value)
|
@@ -26,7 +26,7 @@ module RDF::Microdata
|
|
26
26
|
##
|
27
27
|
# Element language
|
28
28
|
#
|
29
|
-
# From HTML5
|
29
|
+
# From HTML5 3.2.3.3
|
30
30
|
# If both the lang attribute in no namespace and the lang attribute in the XML namespace are set
|
31
31
|
# on an element, user agents must use the lang attribute in the XML namespace, and the lang
|
32
32
|
# attribute in no namespace must be ignored for the purposes of determining the element's
|
@@ -124,8 +124,8 @@ module RDF::Microdata
|
|
124
124
|
##
|
125
125
|
# Return a proxy for each child
|
126
126
|
#
|
127
|
-
# @yield
|
128
|
-
# @yieldparam
|
127
|
+
# @yield child
|
128
|
+
# @yieldparam [NodeProxy] child
|
129
129
|
def each
|
130
130
|
@node_set.each do |c|
|
131
131
|
yield NodeProxy.new(c, parent)
|
@@ -28,7 +28,7 @@ module RDF::Microdata
|
|
28
28
|
##
|
29
29
|
# Element language
|
30
30
|
#
|
31
|
-
# From HTML5
|
31
|
+
# From HTML5 3.2.3.3
|
32
32
|
# If both the lang attribute in no namespace and the lang attribute in the XML namespace are set
|
33
33
|
# on an element, user agents must use the lang attribute in the XML namespace, and the lang
|
34
34
|
# attribute in no namespace must be ignored for the purposes of determining the element's
|
@@ -162,8 +162,8 @@ module RDF::Microdata
|
|
162
162
|
##
|
163
163
|
# Return a proxy for each child
|
164
164
|
#
|
165
|
-
# @yield
|
166
|
-
# @yieldparam
|
165
|
+
# @yield child
|
166
|
+
# @yieldparam [NodeProxy] child
|
167
167
|
def each
|
168
168
|
@node_set.each do |c|
|
169
169
|
yield NodeProxy.new(c, parent)
|
@@ -179,7 +179,7 @@ module RDF::Microdata
|
|
179
179
|
|
180
180
|
##
|
181
181
|
# Add NodeSetProxys
|
182
|
-
# @param [NodeSetProxy,
|
182
|
+
# @param [NodeSetProxy, REXML::Element] other
|
183
183
|
# @return [NodeSetProxy]
|
184
184
|
def +(other)
|
185
185
|
new_ns = node_set.clone
|
@@ -189,7 +189,7 @@ module RDF::Microdata
|
|
189
189
|
|
190
190
|
##
|
191
191
|
# Add a NodeProxy
|
192
|
-
# @param [NodeProxy,
|
192
|
+
# @param [NodeProxy, REXML::Element] elem
|
193
193
|
# @return [NodeSetProxy]
|
194
194
|
def <<(elem)
|
195
195
|
node_set << (elem.is_a?(NodeProxy) ? elem.node : elem)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-microdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdf
|
@@ -108,6 +108,22 @@ dependencies:
|
|
108
108
|
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.2.8
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: open-uri-cached
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.0.5
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 0.0.5
|
111
127
|
- !ruby/object:Gem::Dependency
|
112
128
|
name: yard
|
113
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +188,22 @@ dependencies:
|
|
172
188
|
- - ! '>='
|
173
189
|
- !ruby/object:Gem::Version
|
174
190
|
version: 0.3.4
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: rdf-rdfa
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: 0.3.15
|
199
|
+
type: :development
|
200
|
+
prerelease: false
|
201
|
+
version_requirements: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: 0.3.15
|
175
207
|
- !ruby/object:Gem::Dependency
|
176
208
|
name: rdf-turtle
|
177
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,6 +246,7 @@ files:
|
|
214
246
|
- README
|
215
247
|
- UNLICENSE
|
216
248
|
- VERSION
|
249
|
+
- lib/rdf/microdata/expansion.rb
|
217
250
|
- lib/rdf/microdata/format.rb
|
218
251
|
- lib/rdf/microdata/reader/nokogiri.rb
|
219
252
|
- lib/rdf/microdata/reader/rexml.rb
|