rdf_context 0.5.8.2 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/VERSION +1 -1
- data/bin/rdf_context +9 -1
- data/lib/rdf_context.rb +1 -0
- data/lib/rdf_context/literal.rb +51 -1
- data/lib/rdf_context/parser.rb +10 -6
- data/lib/rdf_context/rdfaparser.rb +51 -22
- data/script/tc +15 -3
- data/spec/rdfa_helper.rb +1 -1
- data/spec/rdfa_parser_spec.rb +1 -1
- metadata +4 -6
data/History.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.5.9
|
2
|
+
* Update to 2010-10-26 LC version of RDFa Core 1.1
|
3
|
+
* Deep processing of XMLLiterals
|
4
|
+
* Case sensitive Terms
|
5
|
+
* Updated processor graph vocabulary
|
6
|
+
|
1
7
|
=== 0.5.8.2
|
2
8
|
* Don't create unnecessary namespaces when serializing RDF/XML.
|
3
9
|
* Don't use regexp to substitute base URI in URI serialization.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
data/bin/rdf_context
CHANGED
@@ -8,10 +8,15 @@ class Parse
|
|
8
8
|
puts "Parse: #{file.is_a?(StringIO) ? base_uri : file}" if $quiet
|
9
9
|
graph_opts = {:identifier => base_uri}
|
10
10
|
graph_opts[:store] = store if store
|
11
|
-
|
11
|
+
pg = RdfContext::Graph.new if $pg_format
|
12
|
+
parser = Parser.new(:graph => Graph.new(graph_opts), :processor_graph => pg)
|
12
13
|
parser.parse(file.respond_to?(:read) ? file : File.open(file), base_uri, :strict => true)
|
13
14
|
puts parser.graph.serialize(:format => $format.to_sym, :base => base_uri) unless $quiet
|
14
15
|
puts parser.debug.to_a.join("\n\t") if $verbose
|
16
|
+
if pg
|
17
|
+
puts "\nProcessor Graph:\n"
|
18
|
+
puts pg.serialize(:format => $pg_format.to_sym) unless $quiet
|
19
|
+
end
|
15
20
|
rescue RdfException => e
|
16
21
|
puts "Parse failure: #{e.message}"
|
17
22
|
puts parser.debug if $verbose && parser
|
@@ -29,12 +34,14 @@ raise "Mode must be one of 'parse'" unless mode == "parse"
|
|
29
34
|
$verbose = false
|
30
35
|
$quiet = false
|
31
36
|
$format = "ttl"
|
37
|
+
$pg_format = nil
|
32
38
|
base_uri = "http://example.com"
|
33
39
|
store = :list_store
|
34
40
|
opts = GetoptLong.new(
|
35
41
|
["--verbose", GetoptLong::NO_ARGUMENT],
|
36
42
|
["--quiet", GetoptLong::NO_ARGUMENT],
|
37
43
|
["--debug", GetoptLong::NO_ARGUMENT],
|
44
|
+
["--pg-format", GetoptLong::REQUIRED_ARGUMENT],
|
38
45
|
["--format", GetoptLong::REQUIRED_ARGUMENT],
|
39
46
|
["--store", GetoptLong::REQUIRED_ARGUMENT],
|
40
47
|
["--uri", GetoptLong::REQUIRED_ARGUMENT]
|
@@ -45,6 +52,7 @@ opts.each do |opt, arg|
|
|
45
52
|
when '--quiet' then $quiet = true
|
46
53
|
when '--debug' then ::RdfContext::debug = true
|
47
54
|
when '--format' then $format = arg
|
55
|
+
when '--pg-format' then $pg_format = arg
|
48
56
|
when '--uri' then base_uri = arg
|
49
57
|
when '--store'
|
50
58
|
case arg
|
data/lib/rdf_context.rb
CHANGED
@@ -64,6 +64,7 @@ module RdfContext
|
|
64
64
|
DC_NS = Namespace.new("http://purl.org/dc/terms/", "dc")
|
65
65
|
OWL_NS = Namespace.new("http://www.w3.org/2002/07/owl#", "owl")
|
66
66
|
LOG_NS = Namespace.new("http://www.w3.org/2000/10/swap/log#", "log")
|
67
|
+
PTR_NS = Namespace.new("http://www.w3.org/2009/pointers#", "ptr")
|
67
68
|
RDF_NS = Namespace.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf")
|
68
69
|
RDFA_NS = Namespace.new("http://www.w3.org/ns/rdfa#", "rdfa")
|
69
70
|
RDFS_NS = Namespace.new("http://www.w3.org/2000/01/rdf-schema#", "rdfs")
|
data/lib/rdf_context/literal.rb
CHANGED
@@ -240,6 +240,13 @@ module RdfContext
|
|
240
240
|
end
|
241
241
|
|
242
242
|
# Map namespaces from context to each top-level element found within node-set
|
243
|
+
#
|
244
|
+
# @param [Object] contents
|
245
|
+
# @option options [Hash] :namespaces ({}) Use :__default__ or "" to declare default namespace
|
246
|
+
# @option options [String] :language (nil)
|
247
|
+
# @option options [Array<URIRef>] :profiles ([]) Profiles to add to elements
|
248
|
+
# @option options [Hash] :prefixes (nil) Prefixes to add to elements
|
249
|
+
# @option options [String] :default_vocabulary (nil) Default vocabulary to add to elements
|
243
250
|
def encode_contents(contents, options)
|
244
251
|
#puts "encode_contents: '#{contents}'"
|
245
252
|
|
@@ -260,14 +267,57 @@ module RdfContext
|
|
260
267
|
if c.is_a?(Nokogiri::XML::Element)
|
261
268
|
c = Nokogiri::XML.parse(c.dup.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)).root
|
262
269
|
# Gather namespaces from self and decendant nodes
|
270
|
+
#
|
271
|
+
# prefix mappings
|
272
|
+
# Look for @xmlns and @prefix mappings. Add any other mappings from options[:prefixes]
|
273
|
+
# that aren't already defined on this node
|
274
|
+
defined_mappings = {}
|
275
|
+
prefix_mappings = {}
|
276
|
+
|
263
277
|
c.traverse do |n|
|
264
278
|
ns = n.namespace
|
265
279
|
next unless ns
|
266
280
|
prefix = ns.prefix ? "xmlns:#{ns.prefix}" : "xmlns"
|
281
|
+
defined_mappings[ns.prefix.to_s] = ns.href.to_s
|
267
282
|
c[prefix] = ns.href unless c.namespaces[prefix]
|
268
283
|
end
|
269
284
|
|
270
|
-
|
285
|
+
mappings = c["prefix"].to_s.split(/\s+/)
|
286
|
+
while mappings.length > 0 do
|
287
|
+
prefix, uri = mappings.shift.downcase, mappings.shift
|
288
|
+
#puts "uri_mappings prefix #{prefix} <#{uri}>"
|
289
|
+
next unless prefix.match(/:$/)
|
290
|
+
prefix.chop!
|
291
|
+
|
292
|
+
# A Conforming RDFa Processor must ignore any definition of a mapping for the '_' prefix.
|
293
|
+
next if prefix == "_"
|
294
|
+
|
295
|
+
defined_mappings[prefix] = uri
|
296
|
+
prefix_mappings[prefix] = uri
|
297
|
+
end
|
298
|
+
|
299
|
+
# Add prefixes, being careful to honor mappings defined on the element
|
300
|
+
if options[:prefixes]
|
301
|
+
options[:prefixes].each_pair do |p, ns|
|
302
|
+
prefix_mappings[p] = ns.uri unless defined_mappings.has_key?(p)
|
303
|
+
end
|
304
|
+
if prefix_mappings.length
|
305
|
+
c["prefix"] = prefix_mappings.keys.sort.map {|p| "#{p}: #{prefix_mappings[p]}"}.join(" ")
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
# Add profiles, being careful to honor profiles defined on the element
|
310
|
+
if options[:profiles].is_a?(Array) && options[:profiles].length > 0
|
311
|
+
profiles = c["profile"].to_s.split(" ")
|
312
|
+
profiles += options[:profiles]
|
313
|
+
c["profile"] = profiles.join(" ")
|
314
|
+
end
|
315
|
+
|
316
|
+
# Add default vocabulary, being careful to honor any defined on the element
|
317
|
+
if options[:default_vocabulary] && !c["vocab"]
|
318
|
+
c["vocab"] = options[:default_vocabulary].to_s
|
319
|
+
end
|
320
|
+
|
271
321
|
if options[:language] && c["lang"].to_s.empty?
|
272
322
|
c["xml:lang"] = options[:language]
|
273
323
|
end
|
data/lib/rdf_context/parser.rb
CHANGED
@@ -161,18 +161,18 @@ module RdfContext
|
|
161
161
|
# @param [XML Node, any] node:: XML Node or string for showing context
|
162
162
|
# @param [String] message::
|
163
163
|
def add_debug(node, message)
|
164
|
-
add_processor_message(node, message, RDFA_NS.
|
164
|
+
add_processor_message(node, message, RDFA_NS.Info)
|
165
165
|
end
|
166
166
|
|
167
|
-
def add_info(node, message, process_class = RDFA_NS.
|
167
|
+
def add_info(node, message, process_class = RDFA_NS.Info)
|
168
168
|
add_processor_message(node, message, process_class)
|
169
169
|
end
|
170
170
|
|
171
|
-
def add_warning(node, message, process_class = RDFA_NS.
|
171
|
+
def add_warning(node, message, process_class = RDFA_NS.Warning)
|
172
172
|
add_processor_message(node, message, process_class)
|
173
173
|
end
|
174
174
|
|
175
|
-
def add_error(node, message, process_class = RDFA_NS.
|
175
|
+
def add_error(node, message, process_class = RDFA_NS.Error)
|
176
176
|
add_processor_message(node, message, process_class)
|
177
177
|
raise ParserException, message if @strict
|
178
178
|
end
|
@@ -185,9 +185,13 @@ module RdfContext
|
|
185
185
|
n = BNode.new
|
186
186
|
@processor_graph << Triple.new(n, RDF_TYPE, process_class)
|
187
187
|
@processor_graph << Triple.new(n, DC_NS.description, message)
|
188
|
-
@processor_graph << Triple.new(n, DC_NS.date, Literal.build_from(DateTime.now
|
188
|
+
@processor_graph << Triple.new(n, DC_NS.date, Literal.build_from(DateTime.now))
|
189
189
|
@processor_graph << Triple.new(n, RDFA_NS.sequence, Literal.build_from(@processor_sequence += 1))
|
190
|
-
@processor_graph << Triple.new(n, RDFA_NS.
|
190
|
+
@processor_graph << Triple.new(n, RDFA_NS.context, uri)
|
191
|
+
nc = BNode.new
|
192
|
+
@processor_graph << Triple.new(nc, RDF_TYPE, PTR_NS.XPathPointer)
|
193
|
+
@processor_graph << Triple.new(nc, PTR_NS.expression, node.path)
|
194
|
+
@processor_graph << Triple.new(n, RDFA_NS.context, nc)
|
191
195
|
end
|
192
196
|
end
|
193
197
|
|
@@ -7,7 +7,7 @@ module RdfContext
|
|
7
7
|
#
|
8
8
|
# Based on processing rules described here:
|
9
9
|
# @see http://www.w3.org/TR/rdfa-syntax/#s_model RDFa 1.0
|
10
|
-
# @see http://www.w3.org/2010/02/rdfa/drafts/2010/WD-rdfa-core-
|
10
|
+
# @see http://www.w3.org/2010/02/rdfa/drafts/2010/WD-rdfa-core-20101026/ RDFa 1.1
|
11
11
|
#
|
12
12
|
# @author Ben Adida
|
13
13
|
# @author Gregg Kellogg
|
@@ -67,6 +67,10 @@ module RdfContext
|
|
67
67
|
#
|
68
68
|
# @return URIRef
|
69
69
|
attr :parent_object, true
|
70
|
+
# A list of current, in-scope profiles.
|
71
|
+
#
|
72
|
+
# @return [Array<URIRef>]
|
73
|
+
attr :profiles, true
|
70
74
|
# A list of current, in-scope URI mappings.
|
71
75
|
#
|
72
76
|
# @return [Hash{String => Namespace}]
|
@@ -110,6 +114,7 @@ module RdfContext
|
|
110
114
|
@base = base
|
111
115
|
@parent_subject = @base
|
112
116
|
@parent_object = nil
|
117
|
+
@profiles = []
|
113
118
|
@uri_mappings = host_defaults.fetch(:uri_mappings, {})
|
114
119
|
@incomplete_triples = []
|
115
120
|
@language = nil
|
@@ -124,6 +129,7 @@ module RdfContext
|
|
124
129
|
# clone the evaluation context correctly
|
125
130
|
@uri_mappings = from.uri_mappings.clone
|
126
131
|
@incomplete_triples = from.incomplete_triples.clone
|
132
|
+
@profiles = from.profiles.clone
|
127
133
|
end
|
128
134
|
|
129
135
|
def inspect
|
@@ -131,6 +137,7 @@ module RdfContext
|
|
131
137
|
v << "uri_mappings[#{uri_mappings.keys.length}]"
|
132
138
|
v << "incomplete_triples[#{incomplete_triples.length}]"
|
133
139
|
v << "term_mappings[#{term_mappings.keys.length}]"
|
140
|
+
v << "profiles[#{profiles.length}]"
|
134
141
|
v.join(",")
|
135
142
|
end
|
136
143
|
end
|
@@ -180,8 +187,8 @@ module RdfContext
|
|
180
187
|
else Nokogiri::XML.parse(stream, uri.to_s)
|
181
188
|
end
|
182
189
|
|
183
|
-
add_error(nil, "Empty document", RDFA_NS.
|
184
|
-
add_warning(nil, "Synax errors:\n#{@doc.errors}", RDFA_NS.
|
190
|
+
add_error(nil, "Empty document", RDFA_NS.DocumentError) if @doc.nil?
|
191
|
+
add_warning(nil, "Synax errors:\n#{@doc.errors}", RDFA_NS.DocumentError) unless @doc.errors.empty?
|
185
192
|
|
186
193
|
@callback = block
|
187
194
|
|
@@ -243,8 +250,8 @@ module RdfContext
|
|
243
250
|
# Parse and process URI mappings, Term mappings and a default vocabulary from @profile
|
244
251
|
#
|
245
252
|
# Yields each mapping
|
246
|
-
def process_profile(element)
|
247
|
-
|
253
|
+
def process_profile(element, profiles)
|
254
|
+
profiles.reverse.each do |profile|
|
248
255
|
# Don't try to open ourselves!
|
249
256
|
if @uri == profile
|
250
257
|
add_debug(element, "process_profile: skip recursive profile <#{profile}>")
|
@@ -321,7 +328,7 @@ module RdfContext
|
|
321
328
|
# triple that is the common subject of an rdfa:term and an rdfa:uri predicate, create a
|
322
329
|
# mapping from the object literal of the rdfa:term predicate to the object literal of the
|
323
330
|
# rdfa:uri predicate. Add or update this mapping in the local term mappings.
|
324
|
-
tm[term.to_s
|
331
|
+
tm[term.to_s] = URIRef.intern(uri.to_s, :normalize => false) if term
|
325
332
|
end
|
326
333
|
rescue Exception => e
|
327
334
|
add_error(element, e.message, RDFA_NS.ProfileReferenceError)
|
@@ -363,7 +370,6 @@ module RdfContext
|
|
363
370
|
# Set mappings from @prefix
|
364
371
|
# prefix is a whitespace separated list of prefix-name URI pairs of the form
|
365
372
|
# NCName ':' ' '+ xs:anyURI
|
366
|
-
# SPEC Confusion: prefix is forced to lower-case in @profile, but not specified here.
|
367
373
|
mappings = element.attributes["prefix"].to_s.split(/\s+/)
|
368
374
|
while mappings.length > 0 do
|
369
375
|
prefix, uri = mappings.shift.downcase, mappings.shift
|
@@ -418,13 +424,14 @@ module RdfContext
|
|
418
424
|
content = attrs['content'].to_s if attrs['content']
|
419
425
|
rel = attrs['rel'].to_s.strip if attrs['rel']
|
420
426
|
rev = attrs['rev'].to_s.strip if attrs['rev']
|
427
|
+
profiles = attrs['profile'].to_s.split(/\s/) # In-scope profiles in order for passing to XMLLiteral
|
421
428
|
|
422
429
|
# Local term mappings [7.5 Steps 2]
|
423
430
|
# Next the current element is parsed for any updates to the local term mappings and local list of URI mappings via @profile.
|
424
431
|
# If @profile is present, its value is processed as defined in RDFa Profiles.
|
425
432
|
unless @version == :rdfa_1_0
|
426
433
|
begin
|
427
|
-
process_profile(element) do |which, value|
|
434
|
+
process_profile(element, profiles) do |which, value|
|
428
435
|
add_debug(element, "[Step 2] traverse, #{which}: #{value.inspect}")
|
429
436
|
case which
|
430
437
|
when :uri_mappings then uri_mappings.merge!(value)
|
@@ -440,7 +447,10 @@ module RdfContext
|
|
440
447
|
return
|
441
448
|
end
|
442
449
|
end
|
443
|
-
|
450
|
+
|
451
|
+
# Add on proviles from parent contexts to update new context
|
452
|
+
profiles += evaluation_context.profiles.clone
|
453
|
+
|
444
454
|
# Default vocabulary [7.5 Step 3]
|
445
455
|
# Next the current element is examined for any change to the default vocabulary via @vocab.
|
446
456
|
# If @vocab is present and contains a value, its value updates the local default vocabulary.
|
@@ -639,8 +649,20 @@ module RdfContext
|
|
639
649
|
if datatype.to_s == XML_LITERAL.to_s
|
640
650
|
# XML Literal
|
641
651
|
add_debug(element, "[Step 11(1.1)] XML Literal: #{element.inner_html}")
|
642
|
-
|
643
|
-
|
652
|
+
|
653
|
+
# In order to maintain maximum portability of this literal, any children of the current node that are
|
654
|
+
# elements must have the current in scope profiles, default vocabulary, prefix mappings, and XML
|
655
|
+
# namespace declarations (if any) declared on the serialized element using their respective attributes.
|
656
|
+
# Since the child element node could also declare new prefix mappings or XML namespaces, the RDFa
|
657
|
+
# Processor must be careful to merge these together when generating the serialized element definition.
|
658
|
+
# For avoidance of doubt, any re-declarations on the child node must take precedence over declarations
|
659
|
+
# that were active on the current node.
|
660
|
+
Literal.typed(element.children, XML_LITERAL,
|
661
|
+
:language => language,
|
662
|
+
:namespaces => uri_mappings,
|
663
|
+
:profiles => profiles,
|
664
|
+
:prefixes => uri_mappings,
|
665
|
+
:default_vocabulary => default_vocabulary)
|
644
666
|
else
|
645
667
|
# plain literal
|
646
668
|
add_debug(element, "[Step 11(1.1)] plain literal")
|
@@ -663,8 +685,6 @@ module RdfContext
|
|
663
685
|
properties.each do |p|
|
664
686
|
add_triple(element, new_subject, p, current_object_literal)
|
665
687
|
end
|
666
|
-
# SPEC CONFUSION: "the triple has been created" ==> there may be more than one
|
667
|
-
# set the recurse flag above in the IF about xmlliteral, as it is the only place that can happen
|
668
688
|
end
|
669
689
|
|
670
690
|
if not skip and new_subject && !evaluation_context.incomplete_triples.empty?
|
@@ -686,6 +706,7 @@ module RdfContext
|
|
686
706
|
uri_mappings == evaluation_context.uri_mappings &&
|
687
707
|
term_mappings == evaluation_context.term_mappings &&
|
688
708
|
default_vocabulary == evaluation_context.default_vocabulary &&
|
709
|
+
profiles == evaluation_context.profiles
|
689
710
|
new_ec = evaluation_context
|
690
711
|
add_debug(element, "[Step 13] skip: reused ec")
|
691
712
|
else
|
@@ -694,6 +715,7 @@ module RdfContext
|
|
694
715
|
new_ec.uri_mappings = uri_mappings
|
695
716
|
new_ec.term_mappings = term_mappings
|
696
717
|
new_ec.default_vocabulary = default_vocabulary
|
718
|
+
new_ec.profiles = profiles
|
697
719
|
add_debug(element, "[Step 13] skip: cloned ec")
|
698
720
|
end
|
699
721
|
else
|
@@ -706,6 +728,7 @@ module RdfContext
|
|
706
728
|
new_ec.language = language
|
707
729
|
new_ec.term_mappings = term_mappings
|
708
730
|
new_ec.default_vocabulary = default_vocabulary
|
731
|
+
new_ec.profiles = profiles
|
709
732
|
add_debug(element, "[Step 13] new ec")
|
710
733
|
end
|
711
734
|
|
@@ -758,11 +781,11 @@ module RdfContext
|
|
758
781
|
# AbsURI does not use xml:base
|
759
782
|
uri = URIRef.intern(value, restrictions.include?(:absuri) ? nil : evaluation_context.base, :normalize => false)
|
760
783
|
rescue Addressable::URI::InvalidURIError => e
|
761
|
-
add_warning(element, "Malformed prefix #{value}", RDFA_NS.
|
784
|
+
add_warning(element, "Malformed prefix #{value}", RDFA_NS.UnresolvedCURIE)
|
762
785
|
rescue ParserException => e
|
763
786
|
add_debug(element, e.message)
|
764
787
|
if value.to_s =~ /^\(^\w\):/
|
765
|
-
add_warning(element, "Undefined prefix #{$1}", RDFA_NS.
|
788
|
+
add_warning(element, "Undefined prefix #{$1}", RDFA_NS.UnresolvedCURIE)
|
766
789
|
else
|
767
790
|
add_warning(element, "Relative URI #{value}")
|
768
791
|
end
|
@@ -780,16 +803,22 @@ module RdfContext
|
|
780
803
|
# <em>options[:term_mappings]</em>:: Term mappings
|
781
804
|
# <em>options[:vocab]</em>:: Default vocabulary
|
782
805
|
def process_term(element, value, options)
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
806
|
+
if options[:term_mappings].is_a?(Hash)
|
807
|
+
# If the term is in the local term mappings, use the associated URI (case sensitive).
|
808
|
+
return options[:term_mappings][value.to_s] if options[:term_mappings].has_key?(value.to_s)
|
809
|
+
|
810
|
+
# Otherwise, check for case-insensitive match
|
811
|
+
options[:term_mappings].each_pair do |term, uri|
|
812
|
+
return uri if term.downcase == value.to_s.downcase
|
813
|
+
end
|
814
|
+
end
|
815
|
+
|
816
|
+
if options[:vocab]
|
788
817
|
# Otherwise, if there is a local default vocabulary the URI is obtained by concatenating that value and the term.
|
789
818
|
URIRef.intern(options[:vocab].to_s + value)
|
790
819
|
else
|
791
820
|
# Finally, if there is no local default vocabulary, the term has no associated URI and must be ignored.
|
792
|
-
add_warning(element, "Term #{value} is not defined", RDFA_NS.
|
821
|
+
add_warning(element, "Term #{value} is not defined", RDFA_NS.UnresolvedTerm)
|
793
822
|
nil
|
794
823
|
end
|
795
824
|
end
|
@@ -812,7 +841,7 @@ module RdfContext
|
|
812
841
|
elsif @host_defaults[:prefix]
|
813
842
|
@host_defaults[:prefix].send("#{reference}_")
|
814
843
|
else
|
815
|
-
#add_warning(element, "Default namespace prefix is not defined", RDFA_NS.
|
844
|
+
#add_warning(element, "Default namespace prefix is not defined", RDFA_NS.UnresolvedCURIE)
|
816
845
|
nil
|
817
846
|
end
|
818
847
|
elsif !curie.to_s.match(/:/)
|
data/script/tc
CHANGED
@@ -7,13 +7,21 @@ require 'getoptlong'
|
|
7
7
|
|
8
8
|
def run_tc(tc)
|
9
9
|
puts "run #{tc.name}"
|
10
|
-
|
10
|
+
puts tc.input if $verbose
|
11
|
+
pg = RdfContext::Graph.new if $pg_format
|
12
|
+
graph = RdfContext::RdfaParser.parse(tc.input, tc.informationResourceInput, :strict => $strict, :version => tc.version, :processor_graph => pg)
|
11
13
|
puts graph.serialize(:format => $format.to_sym, :base => tc.informationResourceInput) unless $quiet
|
14
|
+
if pg
|
15
|
+
puts "\nProcessor Graph:\n"
|
16
|
+
puts pg.serialize(:format => $pg_format.to_sym) unless $quiet
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
20
|
$verbose = false
|
15
21
|
$format = :ntriples
|
22
|
+
$pg_format = nil
|
16
23
|
$strict = false
|
24
|
+
debug = false
|
17
25
|
suite = "xhtml"
|
18
26
|
opts = GetoptLong.new(
|
19
27
|
["--debug", GetoptLong::NO_ARGUMENT],
|
@@ -21,14 +29,16 @@ opts = GetoptLong.new(
|
|
21
29
|
["--quiet", GetoptLong::NO_ARGUMENT],
|
22
30
|
["--suite", GetoptLong::OPTIONAL_ARGUMENT],
|
23
31
|
["--strict", GetoptLong::NO_ARGUMENT],
|
24
|
-
["--format", GetoptLong::REQUIRED_ARGUMENT]
|
32
|
+
["--format", GetoptLong::REQUIRED_ARGUMENT],
|
33
|
+
["--pg-format", GetoptLong::REQUIRED_ARGUMENT]
|
25
34
|
)
|
26
35
|
opts.each do |opt, arg|
|
27
36
|
case opt
|
28
37
|
when '--verbose' then $verbose = true
|
29
38
|
when '--quiet' then $quiet = true
|
30
|
-
when '--debug' then
|
39
|
+
when '--debug' then debug = true
|
31
40
|
when '--format' then $format = arg
|
41
|
+
when '--pg-format' then $pg_format = arg
|
32
42
|
when '--suite' then suite = arg
|
33
43
|
when '--strict' then $strict = true
|
34
44
|
end
|
@@ -36,6 +46,8 @@ end
|
|
36
46
|
|
37
47
|
test_cases = RdfaHelper::TestCase.test_cases(suite)
|
38
48
|
|
49
|
+
::RdfContext::debug = debug
|
50
|
+
|
39
51
|
puts test_cases.length
|
40
52
|
|
41
53
|
test_cases = test_cases.detect do |tc|
|
data/spec/rdfa_helper.rb
CHANGED
@@ -237,7 +237,7 @@ module OpenURI
|
|
237
237
|
when %r(http://rdfa.digitalbazaar.com/test-suite/test-cases/\w+)
|
238
238
|
file = uri.to_s.sub(%r(http://rdfa.digitalbazaar.com/test-suite/test-cases/\w+),
|
239
239
|
File.join(File.expand_path(File.dirname(__FILE__)), 'rdfa-test-suite', 'tests'))
|
240
|
-
puts "file: #{file}"
|
240
|
+
#puts "file: #{file}"
|
241
241
|
File.open(file)
|
242
242
|
when "http://www.w3.org/1999/xhtml/vocab"
|
243
243
|
file = File.join(File.expand_path(File.dirname(__FILE__)), 'rdfa-test-suite', 'profile', "xhv")
|
data/spec/rdfa_parser_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe "RDFa parser" do
|
|
74
74
|
xml = @parser.graph.to_rdfxml
|
75
75
|
|
76
76
|
# Ensure that enclosed literal is also valid
|
77
|
-
xml.should include("E = mc
|
77
|
+
xml.should include("E = mc")
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should parse BNodes" do
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.5.8.2
|
9
|
+
- 9
|
10
|
+
version: 0.5.9
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Gregg Kellogg
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-
|
18
|
+
date: 2010-10-23 00:00:00 -07:00
|
20
19
|
default_executable: rdf_context
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -138,7 +137,6 @@ extra_rdoc_files:
|
|
138
137
|
files:
|
139
138
|
- .autotest
|
140
139
|
- .gitignore
|
141
|
-
- .yardoc
|
142
140
|
- .yardopts
|
143
141
|
- History.rdoc
|
144
142
|
- README.rdoc
|