rdf-rdfxml 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +1 -2
- data/History.rdoc +5 -0
- data/README.md +75 -0
- data/Rakefile +8 -8
- data/UNLICENSE +24 -0
- data/VERSION +1 -1
- data/lib/rdf/rdfxml/writer.rb +68 -78
- data/rdf-rdfxml.gemspec +426 -427
- data/script/parse +1 -1
- data/script/yard-to-rubyforge +2 -0
- data/spec/writer_spec.rb +33 -13
- metadata +16 -50
- data/.gitignore +0 -5
- data/README.rdoc +0 -77
data/script/parse
CHANGED
@@ -11,7 +11,7 @@ def parse(input, base)
|
|
11
11
|
writer_class = RDF::Writer.for($output_format.to_sym)
|
12
12
|
raise "Reader not found for #{$input_format}" unless reader_class
|
13
13
|
raise "Writer not found for #{$output_format}" unless writer_class
|
14
|
-
puts writer_class.buffer { |writer|
|
14
|
+
puts writer_class.buffer(:standard_prefixes => true) { |writer|
|
15
15
|
reader_class.new(input, :base_uri => base, :validate => true).each do |statement|
|
16
16
|
writer << statement
|
17
17
|
end
|
data/spec/writer_spec.rb
CHANGED
@@ -113,7 +113,7 @@ describe "RDF::RDFXML::Writer" do
|
|
113
113
|
@graph << [RDF::URI.new("http://example/seq"), RDF._1, RDF::URI.new("http://example/first")]
|
114
114
|
@graph << [RDF::URI.new("http://example/seq"), RDF._2, RDF::URI.new("http://example/second")]
|
115
115
|
check_xpaths(
|
116
|
-
serialize(:max_depth => 1, :attributes => :
|
116
|
+
serialize(:max_depth => 1, :attributes => :none),
|
117
117
|
"/rdf:RDF/rdf:Seq/@rdf:about" => "http://example/seq",
|
118
118
|
%(/rdf:RDF/rdf:Seq/rdf:_1[@rdf:resource="http://example/first"]) => true,
|
119
119
|
%(/rdf:RDF/rdf:Seq/rdf:_2[@rdf:resource="http://example/second"]) => true
|
@@ -125,7 +125,7 @@ describe "RDF::RDFXML::Writer" do
|
|
125
125
|
@graph << [RDF::URI.new("http://example/seq"), RDF._2, RDF::URI.new("http://example/second")]
|
126
126
|
@graph << [RDF::URI.new("http://example/seq"), RDF._1, RDF::URI.new("http://example/first")]
|
127
127
|
check_xpaths(
|
128
|
-
serialize(:max_depth => 1, :attributes => :
|
128
|
+
serialize(:max_depth => 1, :attributes => :none),
|
129
129
|
"/rdf:RDF/rdf:Seq/@rdf:about" => "http://example/seq",
|
130
130
|
%(/rdf:RDF/rdf:Seq/rdf:_1[@rdf:resource="http://example/first"]) => true,
|
131
131
|
%(/rdf:RDF/rdf:Seq/rdf:_2[@rdf:resource="http://example/second"]) => true
|
@@ -137,19 +137,19 @@ describe "RDF::RDFXML::Writer" do
|
|
137
137
|
@graph << [RDF::URI.new("http://example/seq"), RDF._2, RDF::URI.new("http://example/second")]
|
138
138
|
@graph << [RDF::URI.new("http://example/seq"), RDF._1, RDF::URI.new("http://example/first")]
|
139
139
|
check_xpaths(
|
140
|
-
serialize(:max_depth => 1, :attributes => :
|
140
|
+
serialize(:max_depth => 1, :attributes => :none),
|
141
141
|
"/rdf:RDF/rdf:Bag/@rdf:about" => "http://example/seq",
|
142
142
|
%(/rdf:RDF/rdf:Bag/rdf:_1[@rdf:resource="http://example/first"]) => true,
|
143
143
|
%(/rdf:RDF/rdf:Bag/rdf:_2[@rdf:resource="http://example/second"]) => true
|
144
144
|
)
|
145
145
|
end
|
146
146
|
|
147
|
-
it "should serialize rdf:Alt with
|
147
|
+
it "should serialize rdf:Alt with rdf:_n" do
|
148
148
|
@graph << [RDF::URI.new("http://example/seq"), RDF.type, RDF.Alt]
|
149
149
|
@graph << [RDF::URI.new("http://example/seq"), RDF._2, RDF::URI.new("http://example/second")]
|
150
150
|
@graph << [RDF::URI.new("http://example/seq"), RDF._1, RDF::URI.new("http://example/first")]
|
151
151
|
check_xpaths(
|
152
|
-
serialize(:max_depth => 1, :attributes => :
|
152
|
+
serialize(:max_depth => 1, :attributes => :none),
|
153
153
|
"/rdf:RDF/rdf:Alt/@rdf:about" => "http://example/seq",
|
154
154
|
%(/rdf:RDF/rdf:Alt/rdf:_1[@rdf:resource="http://example/first"]) => true,
|
155
155
|
%(/rdf:RDF/rdf:Alt/rdf:_2[@rdf:resource="http://example/second"]) => true
|
@@ -178,7 +178,7 @@ describe "RDF::RDFXML::Writer" do
|
|
178
178
|
@graph << [RDF::URI.new("http://example/seq"), RDF._2, RDF::URI.new("http://example/second")]
|
179
179
|
@graph << [RDF::URI.new("http://example/seq"), RDF._1, RDF::URI.new("http://example/first")]
|
180
180
|
check_xpaths(
|
181
|
-
serialize(:max_depth => 1, :attributes => :
|
181
|
+
serialize(:max_depth => 1, :attributes => :none),
|
182
182
|
"/rdf:RDF/rdf:Seq/@rdf:about" => "http://example/seq",
|
183
183
|
%(/rdf:RDF/rdf:Seq/rdf:_1[@rdf:resource="http://example/first"]) => true,
|
184
184
|
%(/rdf:RDF/rdf:Seq/rdf:_2[@rdf:resource="http://example/second"]) => true
|
@@ -283,7 +283,8 @@ describe "RDF::RDFXML::Writer" do
|
|
283
283
|
check_xpaths(
|
284
284
|
serialize(:attributes => :typed),
|
285
285
|
"/rdf:RDF/rdf:Description/@rdf:about" => "http://release/",
|
286
|
-
"/rdf:RDF/rdf:Description/@dc:title" => "foo"
|
286
|
+
"/rdf:RDF/rdf:Description/@dc:title" => "foo",
|
287
|
+
:reparse => false
|
287
288
|
)
|
288
289
|
end
|
289
290
|
|
@@ -305,7 +306,7 @@ describe "RDF::RDFXML::Writer" do
|
|
305
306
|
@graph << [RDF::URI.new("http://release/"), RDF::DC.title, "foo"]
|
306
307
|
@graph << [RDF::URI.new("http://release/"), FOO.pred, FOO.obj]
|
307
308
|
|
308
|
-
xml = serialize(:max_depth => 1, :attributes => :
|
309
|
+
xml = serialize(:max_depth => 1, :attributes => :none,
|
309
310
|
:default_namespace => FOO.to_s,
|
310
311
|
:prefixes => {:foo => FOO.to_s})
|
311
312
|
xml.should =~ /<Release/
|
@@ -319,7 +320,7 @@ describe "RDF::RDFXML::Writer" do
|
|
319
320
|
@graph << [RDF::URI.new("http://release/"), RDF::DC.title, "foo"]
|
320
321
|
@graph << [RDF::URI.new("http://release/"), FOO.pred, FOO.obj]
|
321
322
|
|
322
|
-
xml = serialize(:max_depth => 1, :attributes => :
|
323
|
+
xml = serialize(:max_depth => 1, :attributes => :none,
|
323
324
|
:prefixes => {nil => FOO.to_s, :foo => FOO.to_s})
|
324
325
|
xml.should =~ /<Release/
|
325
326
|
xml.should =~ /<pred/
|
@@ -362,11 +363,27 @@ describe "RDF::RDFXML::Writer" do
|
|
362
363
|
end
|
363
364
|
|
364
365
|
it "should replicate rdfcore/rdfms-seq-representation" do
|
365
|
-
|
366
|
+
@graph = parse(%(
|
366
367
|
<http://example.org/eg#eric> a [ <http://example.org/eg#intersectionOf> (<http://example.org/eg#Person> <http://example.org/eg#Male>)] .
|
367
368
|
), :reader => RDF::N3::Reader)
|
368
369
|
graph_check = parse(serialize(:format => :rdfxml)).should be_equivalent_graph(@graph, :trace => @debug.join("\n"))
|
369
370
|
end
|
371
|
+
|
372
|
+
it "should not generate extraneous BNode" do
|
373
|
+
@graph = parse(%(
|
374
|
+
<part_of> a <http://www.w3.org/2002/07/owl#ObjectProperty> .
|
375
|
+
<a> a <http://www.w3.org/2002/07/owl#Class> .
|
376
|
+
<b> a <http://www.w3.org/2002/07/owl#Class> .
|
377
|
+
[ a <http://www.w3.org/2002/07/owl#Class>;
|
378
|
+
<http://www.w3.org/2002/07/owl#intersectionOf> (<b> [ a <http://www.w3.org/2002/07/owl#Class>,
|
379
|
+
<http://www.w3.org/2002/07/owl#Restriction>;
|
380
|
+
<http://www.w3.org/2002/07/owl#onProperty> <part_of>;
|
381
|
+
<http://www.w3.org/2002/07/owl#someValuesFrom> <a>])] .
|
382
|
+
[ a <http://www.w3.org/2002/07/owl#Class>;
|
383
|
+
<http://www.w3.org/2002/07/owl#intersectionOf> (<a> <b>)] .
|
384
|
+
), :reader => RDF::N3::Reader)
|
385
|
+
graph_check = parse(serialize(:format => :rdfxml)).should be_equivalent_graph(@graph, :trace => @debug.join("\n"))
|
386
|
+
end
|
370
387
|
end
|
371
388
|
|
372
389
|
describe "w3c rdfcore tests" do
|
@@ -394,6 +411,7 @@ describe "RDF::RDFXML::Writer" do
|
|
394
411
|
doc.should be_a(Nokogiri::XML::Document)
|
395
412
|
doc.root.should be_a(Nokogiri::XML::Element)
|
396
413
|
paths.each_pair do |path, value|
|
414
|
+
next if path.is_a?(Symbol)
|
397
415
|
@debug << doc.root.at_xpath(path, doc.namespaces).to_s if ::RDF::RDFXML::debug?
|
398
416
|
case value
|
399
417
|
when false
|
@@ -410,9 +428,11 @@ describe "RDF::RDFXML::Writer" do
|
|
410
428
|
end
|
411
429
|
|
412
430
|
# Parse generated graph and compare to source
|
413
|
-
|
414
|
-
|
415
|
-
|
431
|
+
if paths[:reparse]
|
432
|
+
graph = RDF::Graph.new
|
433
|
+
RDF::RDFXML::Reader.new(doc, :base_uri => "http://release/", :format => :rdfxml).each {|st| graph << st}
|
434
|
+
graph.should be_equivalent_graph(@graph, :about => "http://release/", :trace => @debug.join("\n"))
|
435
|
+
end
|
416
436
|
end
|
417
437
|
|
418
438
|
require 'rdf/n3'
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-rdfxml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Gregg Kellogg
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-02-12 00:00:00 -08:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +21,7 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 3
|
33
|
-
- 0
|
34
|
-
version: 0.3.0
|
24
|
+
version: 0.3.1
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
37
27
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +32,7 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ">="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 3
|
49
|
-
- 3
|
50
|
-
version: 1.3.3
|
35
|
+
version: 1.4.4
|
51
36
|
type: :runtime
|
52
37
|
version_requirements: *id002
|
53
38
|
- !ruby/object:Gem::Dependency
|
@@ -58,12 +43,7 @@ dependencies:
|
|
58
43
|
requirements:
|
59
44
|
- - ">="
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 2
|
64
|
-
- 1
|
65
|
-
- 0
|
66
|
-
version: 2.1.0
|
46
|
+
version: 2.5.0
|
67
47
|
type: :development
|
68
48
|
version_requirements: *id003
|
69
49
|
- !ruby/object:Gem::Dependency
|
@@ -74,10 +54,7 @@ dependencies:
|
|
74
54
|
requirements:
|
75
55
|
- - ">="
|
76
56
|
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
version: "0"
|
57
|
+
version: 0.3.1
|
81
58
|
type: :development
|
82
59
|
version_requirements: *id004
|
83
60
|
- !ruby/object:Gem::Dependency
|
@@ -88,10 +65,7 @@ dependencies:
|
|
88
65
|
requirements:
|
89
66
|
- - ">="
|
90
67
|
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
version: "0"
|
68
|
+
version: 0.3.4
|
95
69
|
type: :development
|
96
70
|
version_requirements: *id005
|
97
71
|
- !ruby/object:Gem::Dependency
|
@@ -102,10 +76,7 @@ dependencies:
|
|
102
76
|
requirements:
|
103
77
|
- - ">="
|
104
78
|
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
107
|
-
- 0
|
108
|
-
version: "0"
|
79
|
+
version: 0.6.4
|
109
80
|
type: :development
|
110
81
|
version_requirements: *id006
|
111
82
|
description: RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.
|
@@ -118,15 +89,15 @@ extra_rdoc_files:
|
|
118
89
|
- AUTHORS
|
119
90
|
- CONTRIBUTORS
|
120
91
|
- History.rdoc
|
121
|
-
- README.
|
92
|
+
- README.md
|
122
93
|
files:
|
123
|
-
- .gitignore
|
124
94
|
- .yardopts
|
125
95
|
- AUTHORS
|
126
96
|
- CONTRIBUTORS
|
127
97
|
- History.rdoc
|
128
|
-
- README.
|
98
|
+
- README.md
|
129
99
|
- Rakefile
|
100
|
+
- UNLICENSE
|
130
101
|
- VERSION
|
131
102
|
- etc/doap.nt
|
132
103
|
- etc/doap.xml
|
@@ -145,6 +116,7 @@ files:
|
|
145
116
|
- script/console
|
146
117
|
- script/parse
|
147
118
|
- script/tc
|
119
|
+
- script/yard-to-rubyforge
|
148
120
|
- spec/format_spec.rb
|
149
121
|
- spec/graph_spec.rb
|
150
122
|
- spec/literal_spec.rb
|
@@ -518,8 +490,8 @@ homepage: http://github.com/gkellogg/rdf-rdfxml
|
|
518
490
|
licenses: []
|
519
491
|
|
520
492
|
post_install_message:
|
521
|
-
rdoc_options:
|
522
|
-
|
493
|
+
rdoc_options: []
|
494
|
+
|
523
495
|
require_paths:
|
524
496
|
- lib
|
525
497
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -527,23 +499,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
527
499
|
requirements:
|
528
500
|
- - ">="
|
529
501
|
- !ruby/object:Gem::Version
|
530
|
-
hash: 3
|
531
|
-
segments:
|
532
|
-
- 0
|
533
502
|
version: "0"
|
534
503
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
535
504
|
none: false
|
536
505
|
requirements:
|
537
506
|
- - ">="
|
538
507
|
- !ruby/object:Gem::Version
|
539
|
-
hash: 3
|
540
|
-
segments:
|
541
|
-
- 0
|
542
508
|
version: "0"
|
543
509
|
requirements: []
|
544
510
|
|
545
511
|
rubyforge_project:
|
546
|
-
rubygems_version: 1.
|
512
|
+
rubygems_version: 1.5.0
|
547
513
|
signing_key:
|
548
514
|
specification_version: 3
|
549
515
|
summary: RDF/XML reader/writer for RDF.rb.
|
data/.gitignore
DELETED
data/README.rdoc
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
= RDF::RDFXML reader/writer
|
2
|
-
|
3
|
-
RDF/XML parser for RDF.rb.
|
4
|
-
|
5
|
-
== DESCRIPTION
|
6
|
-
|
7
|
-
RDF::RDFXML is an RDF/XML reader/writer for Ruby using the RDF.rb library suite.
|
8
|
-
|
9
|
-
== FEATURES
|
10
|
-
RDF::RDFXML parses RDF/XML into statements or triples and serializes triples, statements or graphs.
|
11
|
-
|
12
|
-
* Fully compliant RDF/XML parser and serializer.
|
13
|
-
|
14
|
-
Install with 'gem install rdf-rdfxml'
|
15
|
-
|
16
|
-
== Usage:
|
17
|
-
Instantiate a parser and parse source, specifying type and base-URL
|
18
|
-
|
19
|
-
RDF::RDFXML::Reader.open("etc/foaf.xml") do |reader|
|
20
|
-
reader.each_statement do |statement|
|
21
|
-
puts statement.inspect
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
== Dependencies
|
26
|
-
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.0)
|
27
|
-
* [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.3.3)
|
28
|
-
|
29
|
-
== TODO
|
30
|
-
* Add support for LibXML and REXML bindings, and use the best available
|
31
|
-
* Consider a SAX-based parser for improved performance
|
32
|
-
* Add generic RDF/XML Writer
|
33
|
-
|
34
|
-
== Resources
|
35
|
-
* Distiller[http://kellogg-assoc/distiller]
|
36
|
-
* RDoc[http://rdoc.info/projects/gkellogg/rdf-rdfxml]
|
37
|
-
* History[http://github.com/gkellogg/rdf-rdfxml/blob/master/History.txt]
|
38
|
-
* "XHTML+RDFXML 1.1 Core"[http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100422/]
|
39
|
-
* "RDF Tests"[http://www.w3.org/2000/10/rdf-tests/rdfcore/allTestCases.html]
|
40
|
-
|
41
|
-
== AUTHOR
|
42
|
-
* Gregg Kellogg <gregg@kellogg-assoc.com>
|
43
|
-
|
44
|
-
== CONTRIBUTORS
|
45
|
-
* Nicholas Humfrey <nicholas.humfrey@bbc.co.uk>
|
46
|
-
|
47
|
-
== LICENSE
|
48
|
-
|
49
|
-
(The MIT License)
|
50
|
-
|
51
|
-
Copyright (c) 2009-2010 Gregg Kellogg
|
52
|
-
|
53
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
54
|
-
a copy of this software and associated documentation files (the
|
55
|
-
'Software'), to deal in the Software without restriction, including
|
56
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
57
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
58
|
-
permit persons to whom the Software is furnished to do so, subject to
|
59
|
-
the following conditions:
|
60
|
-
|
61
|
-
The above copyright notice and this permission notice shall be
|
62
|
-
included in all copies or substantial portions of the Software.
|
63
|
-
|
64
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
65
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
66
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
67
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
68
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
69
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
70
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
71
|
-
|
72
|
-
== FEEDBACK
|
73
|
-
|
74
|
-
* gregg@kellogg-assoc.com
|
75
|
-
* http://rubygems.org/rdf-rdfxml
|
76
|
-
* http://github.com/gkellogg/rdf-rdfxml
|
77
|
-
* public-rdf-ruby mailing list on w3.org
|