rdf-rdfxml 0.2.1 → 0.2.2
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/History.txt +13 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/etc/doap.nt +47 -0
- data/etc/doap.xml +73 -0
- data/lib/rdf/rdfxml.rb +0 -1
- data/lib/rdf/rdfxml/patches/literal_hacks.rb +19 -8
- data/lib/rdf/rdfxml/patches/seq.rb +1 -1
- data/lib/rdf/rdfxml/patches/uri_hacks.rb +6 -0
- data/lib/rdf/rdfxml/reader.rb +14 -8
- data/lib/rdf/rdfxml/version.rb +1 -1
- data/lib/rdf/rdfxml/writer.rb +13 -18
- data/rdf-rdfxml.gemspec +14 -13
- data/script/console +2 -2
- data/script/parse +49 -0
- data/spec/literal_spec.rb +176 -3
- data/spec/rdf-iso-falure.rb +35 -0
- data/spec/reader_spec.rb +16 -9
- data/spec/uri_spec.rb +47 -34
- data/spec/writer_spec.rb +5 -2
- metadata +30 -11
- data/lib/rdf/rdfxml/patches/rdf_escape.rb +0 -131
- data/spec/rdf_escape_spec.rb +0 -36
data/History.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
=== 0.2.2
|
2
|
+
* Fix bug creating datatyped literal where datatype is a string, not an RDF::URI
|
3
|
+
* Added more XMLLiteral tests (fail, until full canonicalization working)
|
4
|
+
* Added RDF_Reader and RDF_Writer behavior expectations
|
5
|
+
* Use RDF::Writer#prefix and #prefixes implementation instead of internal version.
|
6
|
+
* Added RDF::Reader#rewind and #close, which override default behavior as stream is closed on initialization and rewinding isn't required.
|
7
|
+
* In console, load RDF.rb from parent directory, if it exists.
|
8
|
+
* Dependencies on RDF 0.2.2
|
9
|
+
* Replace String#rdf_escape with RDF::NTriples.escape
|
10
|
+
* Fixed bug in Writer where a qname was expected for sorting, but property has no qname
|
11
|
+
* Handle XMLLiteral when value is a Nokogiri node set.
|
12
|
+
* Ensure URIs are properly RDF Escaped (patch to RDF::NTriples::Writer#format_uri)
|
13
|
+
|
1
14
|
=== 0.2.1
|
2
15
|
* Update for RDF 0.2.1
|
3
16
|
* Writer bug fixes:
|
data/Rakefile
CHANGED
@@ -13,10 +13,10 @@ begin
|
|
13
13
|
gemspec.email = "gregg@kellogg-assoc.com"
|
14
14
|
gemspec.homepage = "http://github.com/gkellogg/rdf-rdfxml"
|
15
15
|
gemspec.authors = ["Gregg Kellogg"]
|
16
|
-
gemspec.add_dependency('rdf', '>= 0.2.
|
16
|
+
gemspec.add_dependency('rdf', '>= 0.2.2')
|
17
17
|
gemspec.add_dependency('nokogiri', '>= 1.3.3')
|
18
18
|
gemspec.add_development_dependency('rspec')
|
19
|
-
gemspec.add_development_dependency('rdf-spec', '>= 0.2.
|
19
|
+
gemspec.add_development_dependency('rdf-spec', '>= 0.2.2')
|
20
20
|
gemspec.add_development_dependency('rdf-isomorphic')
|
21
21
|
gemspec.add_development_dependency('yard')
|
22
22
|
gemspec.extra_rdoc_files = %w(README.rdoc History.txt AUTHORS CONTRIBUTORS)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/etc/doap.nt
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
2
|
+
<http://ar.to/#self> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bendiken/foaf> .
|
3
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <http://ar.to/> .
|
4
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <http://rubygems.org/gems/rdf> .
|
5
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto.bendiken@gmail.com> .
|
6
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
|
7
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" .
|
8
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
|
9
|
+
<http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
10
|
+
<http://bhuga.net/#ben> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bhuga/foaf> .
|
11
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <http://bhuga.net/> .
|
12
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
|
13
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
|
14
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
|
15
|
+
<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
|
16
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
|
17
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
|
18
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/bendiken/rdf/issues> .
|
19
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
|
20
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
|
21
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
|
22
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
|
23
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
|
24
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
|
25
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
|
26
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
|
27
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
28
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
29
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
|
30
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
|
31
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
32
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
33
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
|
34
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
|
35
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
|
36
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#vendor> <http://datagraph.org/> .
|
37
|
+
<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
|
38
|
+
<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
|
39
|
+
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
40
|
+
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
|
41
|
+
_:genid1 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
|
42
|
+
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
43
|
+
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
|
44
|
+
_:genid2 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
|
45
|
+
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
46
|
+
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
|
47
|
+
_:genid3 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
|
data/etc/doap.xml
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<rdf:RDF xmlns="http://usefulinc.com/ns/doap#"
|
3
|
+
xmlns:log="http://www.w3.org/2000/10/swap/log#"
|
4
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
5
|
+
|
6
|
+
<Person xmlns="http://xmlns.com/foaf/0.1/"
|
7
|
+
rdf:about="#_ggenid1">
|
8
|
+
<mbox_sha1sum>c69f3255ff0639543cc5edfd8116eac8df16fab8</mbox_sha1sum>
|
9
|
+
<name>Hellekin O. Wolf</name>
|
10
|
+
</Person>
|
11
|
+
|
12
|
+
<Person xmlns="http://xmlns.com/foaf/0.1/"
|
13
|
+
rdf:about="#_ggenid3">
|
14
|
+
<mbox_sha1sum>bedbbf2451e5beb38d59687c0460032aff92cd3c</mbox_sha1sum>
|
15
|
+
<name>Pius Uzamere</name>
|
16
|
+
</Person>
|
17
|
+
|
18
|
+
<Person xmlns="http://xmlns.com/foaf/0.1/"
|
19
|
+
rdf:about="#_ggenid2">
|
20
|
+
<mbox_sha1sum>f7653fc1ac0e82ebb32f092389bd5fc728eaae12</mbox_sha1sum>
|
21
|
+
<name>John Fieber</name>
|
22
|
+
</Person>
|
23
|
+
|
24
|
+
<Person xmlns="http://xmlns.com/foaf/0.1/"
|
25
|
+
rdf:about="http://ar.to/#self">
|
26
|
+
<isDefinedBy xmlns="http://www.w3.org/2000/01/rdf-schema#"
|
27
|
+
rdf:resource="http://datagraph.org/bendiken/foaf"/>
|
28
|
+
<homepage rdf:resource="http://ar.to/"/>
|
29
|
+
<made rdf:resource="http://rubygems.org/gems/rdf"/>
|
30
|
+
<mbox rdf:resource="mailto:arto.bendiken@gmail.com"/>
|
31
|
+
<mbox_sha1sum>a033f652c84a4d73b8c26d318c2395699dd2bdfb</mbox_sha1sum>
|
32
|
+
<mbox_sha1sum>d0737cceb55eb7d740578d2db1bc0727e3ed49ce</mbox_sha1sum>
|
33
|
+
<name>Arto Bendiken</name>
|
34
|
+
</Person>
|
35
|
+
|
36
|
+
<Person xmlns="http://xmlns.com/foaf/0.1/"
|
37
|
+
rdf:about="http://bhuga.net/#ben">
|
38
|
+
<isDefinedBy xmlns="http://www.w3.org/2000/01/rdf-schema#"
|
39
|
+
rdf:resource="http://datagraph.org/bhuga/foaf"/>
|
40
|
+
<homepage rdf:resource="http://bhuga.net/"/>
|
41
|
+
<mbox rdf:resource="mailto:blavender@gmail.com"/>
|
42
|
+
<mbox_sha1sum>dbf45f4ffbd27b67aa84f02a6a31c144727d10af</mbox_sha1sum>
|
43
|
+
<name>Ben Lavender</name>
|
44
|
+
</Person>
|
45
|
+
|
46
|
+
<Project rdf:about="http://rubygems.org/gems/rdf">
|
47
|
+
<creator xmlns="http://purl.org/dc/terms/"
|
48
|
+
rdf:resource="http://ar.to/#self"/>
|
49
|
+
<blog rdf:resource="http://ar.to/"/>
|
50
|
+
<blog rdf:resource="http://blog.datagraph.org/"/>
|
51
|
+
<bug-database rdf:resource="http://github.com/bendiken/rdf/issues"/>
|
52
|
+
<category rdf:resource="http://dbpedia.org/resource/Resource_Description_Framework"/>
|
53
|
+
<category rdf:resource="http://dbpedia.org/resource/Ruby_(programming_language)"/>
|
54
|
+
<created>2007-10-23</created>
|
55
|
+
<description xml:lang="en">RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data.</description>
|
56
|
+
<developer rdf:resource="http://ar.to/#self"/>
|
57
|
+
<developer rdf:resource="http://bhuga.net/#ben"/>
|
58
|
+
<documenter rdf:resource="http://ar.to/#self"/>
|
59
|
+
<download-page rdf:resource="http://rubyforge.org/projects/rdf/"/>
|
60
|
+
<helper rdf:resource="#_ggenid1"/>
|
61
|
+
<helper rdf:resource="#_ggenid2"/>
|
62
|
+
<helper rdf:resource="#_ggenid3"/>
|
63
|
+
<homepage rdf:resource="http://rdf.rubyforge.org/"/>
|
64
|
+
<license rdf:resource="http://creativecommons.org/licenses/publicdomain/"/>
|
65
|
+
<maintainer rdf:resource="http://ar.to/#self"/>
|
66
|
+
<name>RDF.rb</name>
|
67
|
+
<platform>Ruby</platform>
|
68
|
+
<shortdesc xml:lang="en">A Ruby library for working with Resource Description Framework (RDF) data.</shortdesc>
|
69
|
+
<vendor rdf:resource="http://datagraph.org/"/>
|
70
|
+
<maker xmlns="http://xmlns.com/foaf/0.1/"
|
71
|
+
rdf:resource="http://ar.to/#self"/>
|
72
|
+
</Project>
|
73
|
+
</rdf:RDF>
|
data/lib/rdf/rdfxml.rb
CHANGED
@@ -26,7 +26,6 @@ module RDF
|
|
26
26
|
require 'rdf/rdfxml/patches/literal_hacks'
|
27
27
|
require 'rdf/rdfxml/patches/nokogiri_hacks'
|
28
28
|
require 'rdf/rdfxml/patches/qname_hacks'
|
29
|
-
require 'rdf/rdfxml/patches/rdf_escape'
|
30
29
|
require 'rdf/rdfxml/patches/uri_hacks'
|
31
30
|
autoload :Reader, 'rdf/rdfxml/reader'
|
32
31
|
autoload :Writer, 'rdf/rdfxml/writer'
|
@@ -20,8 +20,7 @@ module RDF; class Literal
|
|
20
20
|
##
|
21
21
|
# @param [Object] value
|
22
22
|
# @option options [String] :lexical (nil)
|
23
|
-
# @option options [Hash] :namespaces (
|
24
|
-
# @option options [Hash] :namespaces ({})
|
23
|
+
# @option options [Hash] :namespaces ({}) Use :__default__ or "" to declare default namespace
|
25
24
|
# @option options [Symbol] :language (nil)
|
26
25
|
# @option options [Symbol] :library (:nokogiri, :libxml, or :rexml)
|
27
26
|
def initialize(value, options = {})
|
@@ -69,7 +68,8 @@ module RDF; class Literal
|
|
69
68
|
def parse_value(value, options)
|
70
69
|
ns_hash = {}
|
71
70
|
options[:namespaces].each_pair do |prefix, uri|
|
72
|
-
|
71
|
+
prefix = prefix == :__default__ ? "" : prefix.to_s
|
72
|
+
attr = prefix.empty? ? "xmlns" : "xmlns:#{prefix}"
|
73
73
|
ns_hash[attr] = uri.to_s
|
74
74
|
end
|
75
75
|
ns_strs = []
|
@@ -94,10 +94,18 @@ module RDF; class Literal
|
|
94
94
|
|
95
95
|
# Nokogiri implementations
|
96
96
|
if defined?(::Nokogiri)
|
97
|
+
# A somewhat half-hearted attempt at C14N.
|
98
|
+
# Main problem is that it promotes all namespaces to top element, instead of demoting them
|
99
|
+
# to the required element, and does not properly order either namespaces or attributes.
|
100
|
+
#
|
101
|
+
# An open-issue in Nokogiri is to add support for C14N from the underlying libxml2 libraries.
|
97
102
|
def parse_value_nokogiri(value, ns_strs, language)
|
98
|
-
|
99
|
-
|
100
|
-
|
103
|
+
elements = if value.is_a?(Nokogiri::XML::NodeSet)
|
104
|
+
value
|
105
|
+
else
|
106
|
+
# Add inherited namespaces to created root element so that they're inherited to sub-elements
|
107
|
+
Nokogiri::XML::Document.parse("<foo #{ns_strs.join(" ")}>#{value.to_s}</foo>").root.children
|
108
|
+
end
|
101
109
|
|
102
110
|
elements.map do |c|
|
103
111
|
if c.is_a?(Nokogiri::XML::Element)
|
@@ -110,9 +118,9 @@ module RDF; class Literal
|
|
110
118
|
c[prefix] = ns.href.to_s unless c.namespaces[prefix]
|
111
119
|
end
|
112
120
|
|
113
|
-
# Add
|
121
|
+
# Add language
|
114
122
|
if language && c["lang"].to_s.empty?
|
115
|
-
c["xml:lang"] = language
|
123
|
+
c["xml:lang"] = language.to_s
|
116
124
|
end
|
117
125
|
end
|
118
126
|
c
|
@@ -125,6 +133,7 @@ module RDF; class Literal
|
|
125
133
|
end # Nokogiri
|
126
134
|
|
127
135
|
if defined?(::LibXML)
|
136
|
+
# This should use Document#canonicalize if as and when it is available in libxml-ruby
|
128
137
|
def parse_value_libxml(value, ns_strs, language)
|
129
138
|
# Fixme
|
130
139
|
end
|
@@ -135,6 +144,8 @@ module RDF; class Literal
|
|
135
144
|
end # LibXML
|
136
145
|
|
137
146
|
# REXML
|
147
|
+
# This could make use of the XMLCanonicalizer gem (http://rubygems.org/gems/XMLCanonicalizer)
|
148
|
+
# But, it hasn't been touched since 2007 and relies on log4r.
|
138
149
|
def parse_value_rexml(value, ns_strs, language)
|
139
150
|
# Fixme
|
140
151
|
end
|
@@ -8,7 +8,7 @@ module RDF
|
|
8
8
|
|
9
9
|
#puts "seq; #{rdf_type} #{rdf_type - [RDF.Seq, RDF.Bag, RDF.Alt]}"
|
10
10
|
if !(rdf_type - [RDF.Seq, RDF.Bag, RDF.Alt]).empty?
|
11
|
-
props.keys.select {|k| k.match(/#{RDF.
|
11
|
+
props.keys.select {|k| k.match(/#{RDF._}(\d)$/)}.
|
12
12
|
sort_by {|i| i.sub(RDF._.to_s, "").to_i}.
|
13
13
|
map {|key| props[key]}.
|
14
14
|
flatten
|
data/lib/rdf/rdfxml/reader.rb
CHANGED
@@ -141,6 +141,12 @@ module RDF::RDFXML
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
# No need to rewind, as parsing is done in initialize
|
145
|
+
def rewind; end
|
146
|
+
|
147
|
+
# Document closed when read in initialize
|
148
|
+
def close; end
|
149
|
+
|
144
150
|
##
|
145
151
|
# Iterates the given block for each RDF statement in the input.
|
146
152
|
#
|
@@ -329,9 +335,9 @@ module RDF::RDFXML
|
|
329
335
|
end
|
330
336
|
|
331
337
|
# Apply character transformations
|
332
|
-
id = id_check(el, id
|
333
|
-
resourceAttr = resourceAttr
|
334
|
-
nodeID = nodeID_check(el, nodeID
|
338
|
+
id = id_check(el, RDF::NTriples.escape(id), nil) if id
|
339
|
+
resourceAttr = RDF::NTriples.escape(resourceAttr) if resourceAttr
|
340
|
+
nodeID = nodeID_check(el, RDF::NTriples.escape(nodeID)) if nodeID
|
335
341
|
|
336
342
|
add_debug(child, "attrs: #{attrs.inspect}")
|
337
343
|
add_debug(child, "datatype: #{datatype}") if datatype
|
@@ -354,7 +360,7 @@ module RDF::RDFXML
|
|
354
360
|
|
355
361
|
literal_opts = {}
|
356
362
|
if datatype
|
357
|
-
literal_opts[:datatype] = datatype
|
363
|
+
literal_opts[:datatype] = RDF::URI.intern(datatype)
|
358
364
|
else
|
359
365
|
literal_opts[:language] = child_ec.language
|
360
366
|
end
|
@@ -515,15 +521,15 @@ module RDF::RDFXML
|
|
515
521
|
|
516
522
|
case
|
517
523
|
when id
|
518
|
-
add_debug(el, "parse_subject, id: '#{id.value
|
519
|
-
id_check(el, id.value
|
524
|
+
add_debug(el, "parse_subject, id: '#{RDF::NTriples.escape(id.value)}'")
|
525
|
+
id_check(el, RDF::NTriples.escape(id.value), ec.base) # Returns URI
|
520
526
|
when nodeID
|
521
527
|
# The value of rdf:nodeID must match the XML Name production
|
522
|
-
nodeID = nodeID_check(el, nodeID.value
|
528
|
+
nodeID = nodeID_check(el, RDF::NTriples.escape(nodeID.value))
|
523
529
|
add_debug(el, "parse_subject, nodeID: '#{nodeID}")
|
524
530
|
bnode(nodeID)
|
525
531
|
when about
|
526
|
-
about = about.value
|
532
|
+
about = RDF::NTriples.escape(about.value)
|
527
533
|
add_debug(el, "parse_subject, about: '#{about}'")
|
528
534
|
ec.base.join(about)
|
529
535
|
else
|
data/lib/rdf/rdfxml/version.rb
CHANGED
data/lib/rdf/rdfxml/writer.rb
CHANGED
@@ -119,20 +119,20 @@ module RDF::RDFXML
|
|
119
119
|
# Get QNames and necessary namespaces from predicates and objects
|
120
120
|
@graph.predicates.each {|pred| add_debug("serialize pred: #{pred.inspect}"); get_qname(pred)}
|
121
121
|
@graph.objects.each {|obj| add_debug("serialize obj: #{obj.inspect}"); get_qname(obj)}
|
122
|
-
|
123
|
-
|
122
|
+
prefix(:rdf, RDF.to_uri)
|
123
|
+
prefix(:xml, RDF::XML) if @base_uri || @lang
|
124
124
|
|
125
125
|
if @default_namespace
|
126
|
-
|
127
|
-
@default_namespace_prefix =
|
126
|
+
prefix(:__default__, @default_namespace)
|
127
|
+
@default_namespace_prefix = prefixes.invert[@default_namespace]
|
128
128
|
add_debug("def_namespace: #{@default_namespace}, prefix: #{@default_namespace_prefix}")
|
129
129
|
end
|
130
130
|
|
131
|
-
add_debug "\nserialize: graph namespaces: #{
|
131
|
+
add_debug "\nserialize: graph namespaces: #{prefixes.inspect}"
|
132
132
|
|
133
133
|
doc.root = Nokogiri::XML::Element.new("rdf:RDF", doc)
|
134
|
-
|
135
|
-
if p
|
134
|
+
prefixes.each_pair do |p, uri|
|
135
|
+
if p == :__default__
|
136
136
|
doc.root.default_namespace = uri.to_s
|
137
137
|
else
|
138
138
|
doc.root.add_namespace(p.to_s, uri.to_s)
|
@@ -376,13 +376,13 @@ module RDF::RDFXML
|
|
376
376
|
if uri.is_a?(RDF::URI)
|
377
377
|
# Duplicate logic from URI#qname to remember namespace assigned
|
378
378
|
if uri.qname
|
379
|
-
|
379
|
+
prefix(uri.qname.first, uri.vocab)
|
380
380
|
add_debug "get_qname(uri.qname): #{uri.qname.join(':')}"
|
381
381
|
return uri.qname.join(":")
|
382
382
|
end
|
383
383
|
|
384
384
|
# No vocabulary assigned, find one from cache of created namespace URIs
|
385
|
-
|
385
|
+
prefixes.each_pair do |prefix, vocab|
|
386
386
|
if uri.to_s.index(vocab.to_s) == 0
|
387
387
|
uri.vocab = vocab
|
388
388
|
local_name = uri.to_s[(vocab.to_s.length)..-1]
|
@@ -411,21 +411,16 @@ module RDF::RDFXML
|
|
411
411
|
@tmp_ns = @tmp_ns ? @tmp_ns.succ : "ns0"
|
412
412
|
add_debug "create namespace definition for #{uri}"
|
413
413
|
uri.vocab = RDF::Vocabulary(base_uri)
|
414
|
-
|
414
|
+
prefix(@tmp_ns.to_sym, uri.vocab)
|
415
415
|
add_debug "get_qname(tmp_ns): #{@tmp_ns}:#{local_name}"
|
416
416
|
return "#{@tmp_ns}:#{local_name}"
|
417
417
|
end
|
418
418
|
end
|
419
419
|
|
420
|
-
def add_namespace(prefix, ns)
|
421
|
-
add_debug "add_namespace: '#{prefix}', <#{ns}>"
|
422
|
-
@namespaces[prefix.to_s] = ns.to_s
|
423
|
-
end
|
424
|
-
|
425
420
|
def reset
|
426
421
|
@depth = 0
|
427
422
|
@lists = {}
|
428
|
-
|
423
|
+
prefixes = {}
|
429
424
|
@references = {}
|
430
425
|
@serialized = {}
|
431
426
|
@subjects = {}
|
@@ -437,8 +432,8 @@ module RDF::RDFXML
|
|
437
432
|
def sort_properties(properties)
|
438
433
|
properties.keys.each do |k|
|
439
434
|
properties[k] = properties[k].sort do |a, b|
|
440
|
-
a_li = a.is_a?(RDF::URI) && a.qname.last =~ /^_\d+$/ ? a.to_i : a.to_s
|
441
|
-
b_li = b.is_a?(RDF::URI) && b.qname.last =~ /^_\d+$/ ? b.to_i : b.to_s
|
435
|
+
a_li = a.is_a?(RDF::URI) && a.qname && a.qname.last =~ /^_\d+$/ ? a.to_i : a.to_s
|
436
|
+
b_li = b.is_a?(RDF::URI) && b.qname && b.qname.last =~ /^_\d+$/ ? b.to_i : b.to_s
|
442
437
|
|
443
438
|
a_li <=> b_li
|
444
439
|
end
|
data/rdf-rdfxml.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rdf-rdfxml}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gregg Kellogg"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-03}
|
13
13
|
s.description = %q{ RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.
|
14
14
|
}
|
15
15
|
s.email = %q{gregg@kellogg-assoc.com}
|
@@ -28,6 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
"README.rdoc",
|
29
29
|
"Rakefile",
|
30
30
|
"VERSION",
|
31
|
+
"etc/doap.nt",
|
32
|
+
"etc/doap.xml",
|
31
33
|
"example.rb",
|
32
34
|
"lib/rdf/rdfxml.rb",
|
33
35
|
"lib/rdf/rdfxml/format.rb",
|
@@ -36,7 +38,6 @@ Gem::Specification.new do |s|
|
|
36
38
|
"lib/rdf/rdfxml/patches/literal_hacks.rb",
|
37
39
|
"lib/rdf/rdfxml/patches/nokogiri_hacks.rb",
|
38
40
|
"lib/rdf/rdfxml/patches/qname_hacks.rb",
|
39
|
-
"lib/rdf/rdfxml/patches/rdf_escape.rb",
|
40
41
|
"lib/rdf/rdfxml/patches/seq.rb",
|
41
42
|
"lib/rdf/rdfxml/patches/uri_hacks.rb",
|
42
43
|
"lib/rdf/rdfxml/reader.rb",
|
@@ -45,11 +46,11 @@ Gem::Specification.new do |s|
|
|
45
46
|
"lib/rdf/rdfxml/writer.rb",
|
46
47
|
"rdf-rdfxml.gemspec",
|
47
48
|
"script/console",
|
49
|
+
"script/parse",
|
48
50
|
"spec/format_spec.rb",
|
49
51
|
"spec/graph_spec.rb",
|
50
52
|
"spec/literal_spec.rb",
|
51
53
|
"spec/matchers.rb",
|
52
|
-
"spec/rdf_escape_spec.rb",
|
53
54
|
"spec/rdf_helper.rb",
|
54
55
|
"spec/rdf_tests/cc197bad-dc9c-440d-a5b5-d52ba2e14234.nt",
|
55
56
|
"spec/rdf_tests/cc197bad-dc9c-440d-a5b5-d52ba2e14234.rdf",
|
@@ -419,14 +420,14 @@ Gem::Specification.new do |s|
|
|
419
420
|
s.homepage = %q{http://github.com/gkellogg/rdf-rdfxml}
|
420
421
|
s.rdoc_options = ["--charset=UTF-8"]
|
421
422
|
s.require_paths = ["lib"]
|
422
|
-
s.rubygems_version = %q{1.3.
|
423
|
+
s.rubygems_version = %q{1.3.7}
|
423
424
|
s.summary = %q{RDF/XML reader/writer for RDF.rb.}
|
424
425
|
s.test_files = [
|
425
426
|
"spec/format_spec.rb",
|
426
427
|
"spec/graph_spec.rb",
|
427
428
|
"spec/literal_spec.rb",
|
428
429
|
"spec/matchers.rb",
|
429
|
-
"spec/
|
430
|
+
"spec/rdf-iso-falure.rb",
|
430
431
|
"spec/rdf_helper.rb",
|
431
432
|
"spec/reader_spec.rb",
|
432
433
|
"spec/spec_helper.rb",
|
@@ -438,26 +439,26 @@ Gem::Specification.new do |s|
|
|
438
439
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
439
440
|
s.specification_version = 3
|
440
441
|
|
441
|
-
if Gem::Version.new(Gem::
|
442
|
-
s.add_runtime_dependency(%q<rdf>, [">= 0.2.
|
442
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
443
|
+
s.add_runtime_dependency(%q<rdf>, [">= 0.2.2"])
|
443
444
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.3.3"])
|
444
445
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
445
|
-
s.add_development_dependency(%q<rdf-spec>, [">= 0.2.
|
446
|
+
s.add_development_dependency(%q<rdf-spec>, [">= 0.2.2"])
|
446
447
|
s.add_development_dependency(%q<rdf-isomorphic>, [">= 0"])
|
447
448
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
448
449
|
else
|
449
|
-
s.add_dependency(%q<rdf>, [">= 0.2.
|
450
|
+
s.add_dependency(%q<rdf>, [">= 0.2.2"])
|
450
451
|
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
451
452
|
s.add_dependency(%q<rspec>, [">= 0"])
|
452
|
-
s.add_dependency(%q<rdf-spec>, [">= 0.2.
|
453
|
+
s.add_dependency(%q<rdf-spec>, [">= 0.2.2"])
|
453
454
|
s.add_dependency(%q<rdf-isomorphic>, [">= 0"])
|
454
455
|
s.add_dependency(%q<yard>, [">= 0"])
|
455
456
|
end
|
456
457
|
else
|
457
|
-
s.add_dependency(%q<rdf>, [">= 0.2.
|
458
|
+
s.add_dependency(%q<rdf>, [">= 0.2.2"])
|
458
459
|
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
459
460
|
s.add_dependency(%q<rspec>, [">= 0"])
|
460
|
-
s.add_dependency(%q<rdf-spec>, [">= 0.2.
|
461
|
+
s.add_dependency(%q<rdf-spec>, [">= 0.2.2"])
|
461
462
|
s.add_dependency(%q<rdf-isomorphic>, [">= 0"])
|
462
463
|
s.add_dependency(%q<yard>, [">= 0"])
|
463
464
|
end
|