rdf-rdfa 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README +16 -8
- data/VERSION +1 -1
- data/lib/rdf/rdfa.rb +5 -6
- data/lib/rdf/rdfa/{profile.rb → context.rb} +42 -42
- data/lib/rdf/rdfa/context/html.rb +20 -0
- data/lib/rdf/rdfa/{profile → context}/xhtml.rb +9 -9
- data/lib/rdf/rdfa/context/xml.rb +55 -0
- data/lib/rdf/rdfa/expansion.rb +4 -4
- data/lib/rdf/rdfa/expansion/doap.rb +8 -8
- data/lib/rdf/rdfa/expansion/gr.rb +33 -21
- data/lib/rdf/rdfa/expansion/schema.rb +2 -0
- data/lib/rdf/rdfa/expansion/skosxl.rb +1 -1
- data/lib/rdf/rdfa/format.rb +4 -2
- data/lib/rdf/rdfa/reader.rb +135 -103
- data/lib/rdf/rdfa/reader/nokogiri.rb +1 -1
- data/lib/rdf/rdfa/reader/rexml.rb +1 -1
- data/lib/rdf/rdfa/writer.rb +5 -5
- metadata +130 -238
- data/lib/rdf/rdfa/profile/html.rb +0 -20
- data/lib/rdf/rdfa/profile/xml.rb +0 -53
data/README
CHANGED
@@ -36,7 +36,7 @@ specifically rules prp-eqp1, prp-eqp2, cax-sco, cax-eqc1, and
|
|
36
36
|
cax-eqc2. This causes sub-classes and sub-properties of type and property IRIs to be added
|
37
37
|
to the output graph.
|
38
38
|
|
39
|
-
{RDF::RDFa::Reader} implements this using the `#expand` method, which looks for `rdfa:
|
39
|
+
{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.
|
40
40
|
|
41
41
|
#### RDF Collections (lists)
|
42
42
|
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:
|
@@ -169,12 +169,20 @@ This is related to [RDFa ISSUE-113](http://www.w3.org/2010/02/rdfa/track/issues/
|
|
169
169
|
|
170
170
|
### Reading RDF data with vocabulary expansion
|
171
171
|
|
172
|
-
graph = RDF::Graph.load("etc/doap.html", :format => :rdfa, :
|
172
|
+
graph = RDF::Graph.load("etc/doap.html", :format => :rdfa, :vocab_expansion => true)
|
173
173
|
|
174
174
|
or
|
175
175
|
|
176
176
|
graph = RDF::RDFa::Reader.open("etc/doap.html").expand
|
177
177
|
|
178
|
+
### Reading Processor Graph
|
179
|
+
|
180
|
+
graph = RDF::Graph.load("etc/doap.html", :format => :rdfa, :rdfagraph => :processor)
|
181
|
+
|
182
|
+
### Reading Both Processor and Output Graphs
|
183
|
+
|
184
|
+
graph = RDF::Graph.load("etc/doap.html", :format => :rdfa, :rdfagraph => [:output, :processor])
|
185
|
+
|
178
186
|
### Writing RDF data using the XHTML+RDFa format
|
179
187
|
|
180
188
|
require 'rdf/rdfa'
|
@@ -187,7 +195,7 @@ Note that prefixes may be chained between Reader and Writer, so that the Writer
|
|
187
195
|
use the same prefix definitions found during parsing:
|
188
196
|
|
189
197
|
prefixes = {}
|
190
|
-
graph = RDF::Graph.load("etc/
|
198
|
+
graph = RDF::Graph.load("etc/doap.html", :prefixes => prefixes)
|
191
199
|
puts graph.dump(:rdfa, :prefixes => prefixes)
|
192
200
|
|
193
201
|
### Template-based Writer
|
@@ -351,7 +359,7 @@ Full documentation available on [Rubydoc.info][RDFa doc]
|
|
351
359
|
* [History]{file:History.markdown}
|
352
360
|
* [RDFa 1.1 Core][RDFa 1.1 Core]
|
353
361
|
* [XHTML+RDFa 1.1][XHTML+RDFa 1.1]
|
354
|
-
* [RDFa-test-suite](http://rdfa.
|
362
|
+
* [RDFa-test-suite](http://rdfa.info/test-suite/ "RDFa test suite")
|
355
363
|
|
356
364
|
## Author
|
357
365
|
* [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
|
@@ -389,11 +397,11 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
|
389
397
|
[YARD]: http://yardoc.org/
|
390
398
|
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
391
399
|
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
392
|
-
[RDFa 1.1 Core]: http://www.w3.org/TR/2011/WD-rdfa-core-20110331/
|
400
|
+
[RDFa 1.1 Core]: http://www.w3.org/TR/2011/WD-rdfa-core-20110331/ "RDFa 1.1 Core"
|
393
401
|
[RDFa Lite 1.1]: http://www.w3.org/2010/02/rdfa/drafts/2011/ED-rdfa-lite-20111030/ "RDFa Lite 1.1"
|
394
|
-
[XHTML+RDFa 1.1]: http://www.w3.org/TR/2011/WD-xhtml-rdfa-20110331/
|
395
|
-
[HTML+RDFa 1.1]: http://www.w3.org/TR/2011/WD-rdfa-in-html-20110525/
|
396
|
-
[RDFa-test-suite]: http://rdfa.
|
402
|
+
[XHTML+RDFa 1.1]: http://www.w3.org/TR/2011/WD-xhtml-rdfa-20110331/ "XHTML+RDFa 1.1"
|
403
|
+
[HTML+RDFa 1.1]: http://www.w3.org/TR/2011/WD-rdfa-in-html-20110525/ "HTML+RDFa 1.1"
|
404
|
+
[RDFa-test-suite]: http://rdfa.info/test-suite/ "RDFa test suite"
|
397
405
|
[RDFa doc]: http://rubydoc.info/github/gkellogg/rdf-rdfa/frames
|
398
406
|
[Haml]: http://haml-lang.com/
|
399
407
|
[Turtle]: http://www.w3.org/TR/2011/WD-turtle-20110809/
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.10
|
data/lib/rdf/rdfa.rb
CHANGED
@@ -9,17 +9,16 @@ module RDF
|
|
9
9
|
# require 'rdf/rdfa'
|
10
10
|
#
|
11
11
|
# @example Parsing RDF statements from an XHTML+RDFa file
|
12
|
-
# RDF::RDFa::Reader.open("etc/
|
12
|
+
# RDF::RDFa::Reader.open("etc/doap.html") do |reader|
|
13
13
|
# reader.each_statement do |statement|
|
14
14
|
# puts statement.inspect
|
15
15
|
# end
|
16
16
|
# end
|
17
17
|
#
|
18
18
|
# @see http://rdf.rubyforge.org/
|
19
|
-
# @see http://www.w3.org/TR/
|
20
|
-
# @see http://www.w3.org/
|
21
|
-
# @see http://www.w3.org/TR/
|
22
|
-
# @see http://www.w3.org/TR/2011/WD-rdfa-in-html-20110525/
|
19
|
+
# @see http://www.w3.org/TR/rdfa-syntax/#s_model RDFa 1.0
|
20
|
+
# @see http://www.w3.org/TR/2012/CR-rdfa-core-20120313/
|
21
|
+
# @see http://www.w3.org/TR/2012/CR-xhtml-rdfa-20120313/
|
23
22
|
# @see http://dev.w3.org/html5/rdfa/
|
24
23
|
#
|
25
24
|
# @author [Gregg Kellogg](http://kellogg-assoc.com/)
|
@@ -28,7 +27,7 @@ module RDF
|
|
28
27
|
require 'rdf/rdfa/vocab'
|
29
28
|
require 'rdf/rdfa/patches/string_hacks'
|
30
29
|
autoload :Expansion, 'rdf/rdfa/expansion'
|
31
|
-
autoload :
|
30
|
+
autoload :Context, 'rdf/rdfa/context'
|
32
31
|
autoload :Reader, 'rdf/rdfa/reader'
|
33
32
|
autoload :Writer, 'rdf/rdfa/writer'
|
34
33
|
autoload :VERSION, 'rdf/rdfa/version'
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module RDF::RDFa
|
2
2
|
##
|
3
|
-
#
|
3
|
+
# Context representation existing of a hash of terms, prefixes, a default vocabulary and a URI.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
# by serializing a
|
5
|
+
# Contexts are used for storing RDFa context representations. A representation is created
|
6
|
+
# by serializing a context graph (typically also in RDFa, but may be in other representations).
|
7
7
|
#
|
8
|
-
# The class may be backed by an RDF::Repository, which will be used to retrieve a
|
8
|
+
# The class may be backed by an RDF::Repository, which will be used to retrieve a context graph
|
9
9
|
# or to load into, if no such graph exists
|
10
|
-
class
|
11
|
-
# Prefix mappings defined in this
|
10
|
+
class Context
|
11
|
+
# Prefix mappings defined in this context
|
12
12
|
# @return [Hash{Symbol => RDF::URI}]
|
13
13
|
attr_reader :prefixes
|
14
14
|
|
15
|
-
# Term mappings defined in this
|
15
|
+
# Term mappings defined in this context
|
16
16
|
# @return [Hash{Symbol => RDF::URI}]
|
17
17
|
attr_reader :terms
|
18
18
|
|
@@ -20,20 +20,20 @@ module RDF::RDFa
|
|
20
20
|
# @return [RDF::URI]
|
21
21
|
attr_reader :vocabulary
|
22
22
|
|
23
|
-
# URI defining this
|
23
|
+
# URI defining this context
|
24
24
|
# @return [RDF::URI]
|
25
25
|
attr_reader :uri
|
26
26
|
|
27
27
|
##
|
28
|
-
# Initialize a new
|
28
|
+
# Initialize a new context from the given URI.
|
29
29
|
#
|
30
|
-
# Parses the
|
30
|
+
# Parses the context and places it in the repository and cache
|
31
31
|
#
|
32
|
-
# @param [RDF::URI, #to_s] uri URI of
|
33
|
-
# @yield [
|
34
|
-
# @yieldparam [RDF::RDFa::
|
32
|
+
# @param [RDF::URI, #to_s] uri URI of context to be represented
|
33
|
+
# @yield [context]
|
34
|
+
# @yieldparam [RDF::RDFa::Context] context
|
35
35
|
# @yieldreturn [void] ignored
|
36
|
-
# @return [RDF::RDFa::
|
36
|
+
# @return [RDF::RDFa::Context]
|
37
37
|
def initialize(uri, options = {}, &block)
|
38
38
|
@uri = RDF::URI.intern(uri)
|
39
39
|
@prefixes = options.fetch(:prefixes, {})
|
@@ -55,24 +55,24 @@ module RDF::RDFa
|
|
55
55
|
end
|
56
56
|
|
57
57
|
##
|
58
|
-
# Repository used for saving
|
58
|
+
# Repository used for saving contexts
|
59
59
|
# @return [RDF::Repository]
|
60
|
-
# @raise [RDF::RDFa::
|
60
|
+
# @raise [RDF::RDFa::ContextError] if context does not support contexts
|
61
61
|
def self.repository
|
62
|
-
@repository ||= RDF::Repository.new(:title => "RDFa
|
62
|
+
@repository ||= RDF::Repository.new(:title => "RDFa Contexts")
|
63
63
|
end
|
64
64
|
|
65
65
|
##
|
66
|
-
# Set repository used for saving
|
66
|
+
# Set repository used for saving contexts
|
67
67
|
# @param [RDF::Repository] repo
|
68
68
|
# @return [RDF::Repository]
|
69
69
|
def self.repository=(repo)
|
70
|
-
raise
|
70
|
+
raise ContextError, "Context Repository must support context" unless repo.supports?(:context)
|
71
71
|
@repository = repo
|
72
72
|
end
|
73
73
|
|
74
|
-
# Return a
|
75
|
-
# @return [RDF::RDFa::
|
74
|
+
# Return a context faulting through the cache
|
75
|
+
# @return [RDF::RDFa::Context]
|
76
76
|
def self.find(uri)
|
77
77
|
uri = RDF::URI.intern(uri)
|
78
78
|
|
@@ -82,16 +82,16 @@ module RDF::RDFa
|
|
82
82
|
# Return something to make the caller happy if we're re-entered
|
83
83
|
cache[uri] = Struct.new(:prefixes, :terms, :vocabulary).new({}, {}, nil)
|
84
84
|
# Now do the actual load
|
85
|
-
cache[uri] = new(uri) do |
|
86
|
-
STDERR.puts("
|
87
|
-
|
88
|
-
|
85
|
+
cache[uri] = new(uri) do |context|
|
86
|
+
STDERR.puts("process_context: retrieve context <#{uri}>") if RDF::RDFa.debug?
|
87
|
+
Context.load(uri)
|
88
|
+
context.parse(repository.query(:context => uri))
|
89
89
|
end
|
90
90
|
rescue Exception => e
|
91
|
-
raise
|
91
|
+
raise ContextError, "Context #{uri}: #{e.message}"
|
92
92
|
end
|
93
93
|
|
94
|
-
# Load
|
94
|
+
# Load context into repository
|
95
95
|
def self.load(uri)
|
96
96
|
uri = RDF::URI.intern(uri)
|
97
97
|
repository.load(uri.to_s, :base_uri => uri, :context => uri) unless repository.has_context?(uri)
|
@@ -99,17 +99,17 @@ module RDF::RDFa
|
|
99
99
|
|
100
100
|
# @return [RDF::Repository]
|
101
101
|
def repository
|
102
|
-
|
102
|
+
Context.repository
|
103
103
|
end
|
104
104
|
|
105
105
|
##
|
106
|
-
# Defines the given named URI prefix for this
|
106
|
+
# Defines the given named URI prefix for this context.
|
107
107
|
#
|
108
108
|
# @example Defining a URI prefix
|
109
|
-
#
|
109
|
+
# context.prefix :dc, RDF::URI('http://purl.org/dc/terms/')
|
110
110
|
#
|
111
111
|
# @example Returning a URI prefix
|
112
|
-
#
|
112
|
+
# context.prefix(:dc) #=> RDF::URI('http://purl.org/dc/terms/')
|
113
113
|
#
|
114
114
|
# @overload prefix(name, uri)
|
115
115
|
# @param [Symbol, #to_s] name
|
@@ -125,13 +125,13 @@ module RDF::RDFa
|
|
125
125
|
end
|
126
126
|
|
127
127
|
##
|
128
|
-
# Defines the given named URI term for this
|
128
|
+
# Defines the given named URI term for this context.
|
129
129
|
#
|
130
130
|
# @example Defining a URI term
|
131
|
-
#
|
131
|
+
# context.term :title, RDF::URI('http://purl.org/dc/terms/title')
|
132
132
|
#
|
133
|
-
# @example Returning a URI
|
134
|
-
#
|
133
|
+
# @example Returning a URI context
|
134
|
+
# context.term(:title) #=> RDF::URI('http://purl.org/dc/terms/TITLE')
|
135
135
|
#
|
136
136
|
# @overload term(name, uri)
|
137
137
|
# @param [Symbol, #to_s] name
|
@@ -152,12 +152,12 @@ module RDF::RDFa
|
|
152
152
|
# @param [RDF::Enumerable, Enumerator] queryable
|
153
153
|
# @return [void] ignored
|
154
154
|
def parse(enumerable)
|
155
|
-
STDERR.puts("
|
155
|
+
STDERR.puts("process_context: parse context <#{uri}>") if RDF::RDFa.debug?
|
156
156
|
resource_info = {}
|
157
157
|
enumerable.each do |statement|
|
158
158
|
res = resource_info[statement.subject] ||= {}
|
159
159
|
next unless statement.object.is_a?(RDF::Literal)
|
160
|
-
STDERR.puts("
|
160
|
+
STDERR.puts("process_context: statement=#{statement.inspect}") if RDF::RDFa.debug?
|
161
161
|
%w(uri term prefix vocabulary).each do |term|
|
162
162
|
res[term] ||= statement.object.value if statement.predicate == RDF::RDFA[term]
|
163
163
|
end
|
@@ -170,7 +170,7 @@ module RDF::RDFa
|
|
170
170
|
term = res["term"]
|
171
171
|
prefix = res["prefix"]
|
172
172
|
vocab = res["vocabulary"]
|
173
|
-
STDERR.puts("
|
173
|
+
STDERR.puts("process_context: uri=#{uri.inspect}, term=#{term.inspect}, prefix=#{prefix.inspect}, vocabulary=#{vocab.inspect}") if RDF::RDFa.debug?
|
174
174
|
|
175
175
|
@vocabulary = vocab if vocab
|
176
176
|
|
@@ -190,9 +190,9 @@ module RDF::RDFa
|
|
190
190
|
end
|
191
191
|
|
192
192
|
##
|
193
|
-
# The base class for RDF
|
194
|
-
class
|
193
|
+
# The base class for RDF context errors.
|
194
|
+
class ContextError < IOError; end
|
195
195
|
end
|
196
196
|
|
197
|
-
# Load cooked
|
198
|
-
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), '
|
197
|
+
# Load cooked contexts
|
198
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'context', '*')).each {|f| load f}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is automatically generated by ./script/intern_context
|
2
|
+
# RDFa context for http://www.w3.org/2011/rdfa-context/html-rdfa-1.1
|
3
|
+
|
4
|
+
class RDF::RDFa::Context
|
5
|
+
def self.find_with_html_rdfa_1_1(uri)
|
6
|
+
if uri.to_s == "http://www.w3.org/2011/rdfa-context/html-rdfa-1.1"
|
7
|
+
@_html_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/html-rdfa-1.1"), {
|
8
|
+
})
|
9
|
+
else
|
10
|
+
find_without_html_rdfa_1_1(uri)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
##
|
16
|
+
# Override find to return this context, if matched
|
17
|
+
alias_method :find_without_html_rdfa_1_1, :find
|
18
|
+
alias_method :find, :find_with_html_rdfa_1_1
|
19
|
+
end
|
20
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# This file is automatically generated by ./script/
|
2
|
-
# RDFa
|
1
|
+
# This file is automatically generated by ./script/intern_context
|
2
|
+
# RDFa context for http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
|
3
3
|
|
4
|
-
class RDF::RDFa::
|
5
|
-
def self.
|
4
|
+
class RDF::RDFa::Context
|
5
|
+
def self.find_with_xhtml_rdfa_1_1(uri)
|
6
6
|
if uri.to_s == "http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1"
|
7
|
-
@
|
7
|
+
@_xhtml_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1"), {
|
8
8
|
:terms => {
|
9
9
|
:alternate => "http://www.w3.org/1999/xhtml/vocab#alternate",
|
10
10
|
:appendix => "http://www.w3.org/1999/xhtml/vocab#appendix",
|
@@ -34,14 +34,14 @@ class RDF::RDFa::Profile
|
|
34
34
|
},
|
35
35
|
})
|
36
36
|
else
|
37
|
-
|
37
|
+
find_without_xhtml_rdfa_1_1(uri)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
class << self
|
42
42
|
##
|
43
|
-
# Override find to return this
|
44
|
-
alias_method :
|
45
|
-
alias_method :find, :
|
43
|
+
# Override find to return this context, if matched
|
44
|
+
alias_method :find_without_xhtml_rdfa_1_1, :find
|
45
|
+
alias_method :find, :find_with_xhtml_rdfa_1_1
|
46
46
|
end
|
47
47
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# This file is automatically generated by ./script/intern_context
|
2
|
+
# RDFa context for http://www.w3.org/2011/rdfa-context/rdfa-1.1
|
3
|
+
|
4
|
+
class RDF::RDFa::Context
|
5
|
+
def self.find_with_rdfa_1_1(uri)
|
6
|
+
if uri.to_s == "http://www.w3.org/2011/rdfa-context/rdfa-1.1"
|
7
|
+
@_rdfa_1_1_prof ||= RDF::RDFa::Context.new(RDF::URI("http://www.w3.org/2011/rdfa-context/rdfa-1.1"), {
|
8
|
+
:prefixes => {
|
9
|
+
:cc => "http://creativecommons.org/ns#",
|
10
|
+
:ctag => "http://commontag.org/ns#",
|
11
|
+
:dc => "http://purl.org/dc/terms/",
|
12
|
+
:dcterms => "http://purl.org/dc/terms/",
|
13
|
+
:foaf => "http://xmlns.com/foaf/0.1/",
|
14
|
+
:gr => "http://purl.org/goodrelations/v1#",
|
15
|
+
:grddl => "http://www.w3.org/2003/g/data-view#",
|
16
|
+
:ical => "http://www.w3.org/2002/12/cal/icaltzd#",
|
17
|
+
:ma => "http://www.w3.org/ns/ma-ont#",
|
18
|
+
:og => "http://ogp.me/ns#",
|
19
|
+
:owl => "http://www.w3.org/2002/07/owl#",
|
20
|
+
:rdf => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
21
|
+
:rdfa => "http://www.w3.org/ns/rdfa#",
|
22
|
+
:rdfs => "http://www.w3.org/2000/01/rdf-schema#",
|
23
|
+
:rev => "http://purl.org/stuff/rev#",
|
24
|
+
:rif => "http://www.w3.org/2007/rif#",
|
25
|
+
:schema => "http://schema.org/",
|
26
|
+
:sioc => "http://rdfs.org/sioc/ns#",
|
27
|
+
:skos => "http://www.w3.org/2004/02/skos/core#",
|
28
|
+
:skosxl => "http://www.w3.org/2008/05/skos-xl#",
|
29
|
+
:v => "http://rdf.data-vocabulary.org/#",
|
30
|
+
:vcard => "http://www.w3.org/2006/vcard/ns#",
|
31
|
+
:void => "http://rdfs.org/ns/void#",
|
32
|
+
:wdr => "http://www.w3.org/2007/05/powder#",
|
33
|
+
:wdrs => "http://www.w3.org/2007/05/powder-s#",
|
34
|
+
:xhv => "http://www.w3.org/1999/xhtml/vocab#",
|
35
|
+
:xml => "http://www.w3.org/XML/1998/namespace",
|
36
|
+
:xsd => "http://www.w3.org/2001/XMLSchema#",
|
37
|
+
},
|
38
|
+
:terms => {
|
39
|
+
:describedby => "http://www.w3.org/2007/05/powder-s#describedby",
|
40
|
+
:license => "http://www.w3.org/1999/xhtml/vocab#license",
|
41
|
+
:role => "http://www.w3.org/1999/xhtml/vocab#role",
|
42
|
+
},
|
43
|
+
})
|
44
|
+
else
|
45
|
+
find_without_rdfa_1_1(uri)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
##
|
51
|
+
# Override find to return this context, if matched
|
52
|
+
alias_method :find_without_rdfa_1_1, :find
|
53
|
+
alias_method :find, :find_with_rdfa_1_1
|
54
|
+
end
|
55
|
+
end
|
data/lib/rdf/rdfa/expansion.rb
CHANGED
@@ -14,7 +14,7 @@ module RDF::RDFa
|
|
14
14
|
# triples to the default graph based on rules and property/class relationships
|
15
15
|
# described in referenced vocabularies.
|
16
16
|
#
|
17
|
-
# For all objects that are the target of an rdfa:
|
17
|
+
# For all objects that are the target of an rdfa:usesVocabulary property, load the IRI into
|
18
18
|
# a repository.
|
19
19
|
#
|
20
20
|
# Subsequently, perform OWL expansion using rules prp-spo1, prp-eqp1,
|
@@ -48,14 +48,14 @@ module RDF::RDFa
|
|
48
48
|
@@vocab_repo = @options[:vocab_repository] if @options.has_key?(:vocab_repository)
|
49
49
|
@@vocab_repo ||= RDF::Repository.new.insert(*COOKED_VOCAB_STATEMENTS)
|
50
50
|
|
51
|
-
vocabs = repo.query(:predicate => RDF::RDFA.
|
51
|
+
vocabs = repo.query(:predicate => RDF::RDFA.usesVocabulary).to_a.map(&:object)
|
52
52
|
vocabs.each do |vocab|
|
53
53
|
begin
|
54
54
|
unless @@vocab_repo.has_context?(vocab)
|
55
55
|
add_debug("expand", "Load #{vocab}")
|
56
56
|
@@vocab_repo.load(vocab, :context => vocab)
|
57
57
|
end
|
58
|
-
rescue
|
58
|
+
rescue Exception => e
|
59
59
|
# XXX: update spec to indicate the error if the vocabulary fails to laod
|
60
60
|
add_warning("expand", "Error loading vocabulary #{vocab}: #{e.message}", RDF::RDFA.UnresovedVocabulary)
|
61
61
|
end
|
@@ -215,5 +215,5 @@ module RDF::RDFa
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
# Load cooked
|
218
|
+
# Load cooked vocabularies
|
219
219
|
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'expansion', '*')).each {|f| load f}
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# This file is automatically generated by script/intern_vocabulary
|
1
|
+
# This file is automatically generated by ./script/intern_vocabulary
|
2
2
|
# RDFa vocabulary for http://usefulinc.com/ns/doap# loaded from http://usefulinc.com/ns/doap#
|
3
3
|
require 'rdf/rdfa/expansion'
|
4
4
|
|
5
5
|
module RDF::RDFa::Expansion
|
6
6
|
[
|
7
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#BKRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
8
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#BazaarBranch'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
9
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#HgRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
10
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#DarcsRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
11
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#old-homepage'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://xmlns.com/foaf/0.1/homepage'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
12
7
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#Project'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://xmlns.com/wordnet/1.6/Project'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
13
8
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#Project'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://xmlns.com/foaf/0.1/Project'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
14
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#homepage'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://xmlns.com/foaf/0.1/homepage'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
15
9
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#Specification'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#Resource'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
16
10
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#SVNRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
11
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#BKRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
17
12
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#CVSRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
18
13
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#ArchRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
19
|
-
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#
|
14
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#BazaarBranch'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
20
15
|
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#GitRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
16
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#HgRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
17
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#DarcsRepository'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://usefulinc.com/ns/doap#Repository'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
18
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#name'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#label'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
19
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#homepage'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://xmlns.com/foaf/0.1/homepage'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
20
|
+
RDF::Statement.new(RDF::URI('http://usefulinc.com/ns/doap#old-homepage'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://xmlns.com/foaf/0.1/homepage'), :context => RDF::URI('http://usefulinc.com/ns/doap#')),
|
21
21
|
].each {|st| COOKED_VOCAB_STATEMENTS << st }
|
22
22
|
end
|