rdf-rdfxml 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.markdown +4 -0
- data/README.markdown +2 -2
- data/VERSION +1 -1
- data/lib/rdf/rdfxml/reader/nokogiri.rb +15 -3
- data/lib/rdf/rdfxml/reader/rexml.rb +14 -2
- data/lib/rdf/rdfxml/reader.rb +15 -15
- data/lib/rdf/rdfxml.rb +1 -1
- metadata +24 -24
data/History.markdown
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### 0.3.8
|
2
|
+
* If rdf:RDF is found in a deaper element, look to ancestors for xml:base and xml:lang.
|
3
|
+
### 0.3.7
|
4
|
+
* Added :stylesheet option to RDF::RDFXML::Writer to allow writing of an XSL stylesheet processing instruction.
|
1
5
|
### 0.3.6
|
2
6
|
* Attempt at JRuby and REXML support; not quite there yet.
|
3
7
|
* Element content uses `#inner_text`, rather than `#inner_html`; this performs entity decoding.
|
data/README.markdown
CHANGED
@@ -51,7 +51,7 @@ Full documentation available on [RubyForge](http://rubydoc.info/github/ruby-rdf/
|
|
51
51
|
* [RDF.rb][RDF.rb]
|
52
52
|
* [RDF/XML][RDF/XML]
|
53
53
|
* [Distiller](http://distiller.kellogg-assoc)
|
54
|
-
* [Documentation](http://
|
54
|
+
* [Documentation](http://rubygems.org/gems/rdf-rdfxml)
|
55
55
|
* [History](file:file.History.html)
|
56
56
|
* [RDF Tests](http://www.w3.org/2000/10/rdf-tests/rdfcore/allTestCases.html)
|
57
57
|
|
@@ -87,7 +87,7 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
|
87
87
|
* <http://github.com/ruby-rdf/rdf-rdfxml>
|
88
88
|
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
89
89
|
|
90
|
-
[RDF.rb]: http://
|
90
|
+
[RDF.rb]: http://rubygems.org/gems/rdf
|
91
91
|
[RDF/XML]: http://www.w3.org/TR/REC-rdf-syntax/ "RDF/XML Syntax Specification"
|
92
92
|
[YARD]: http://yardoc.org/
|
93
93
|
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.8
|
@@ -38,11 +38,17 @@ module RDF::RDFXML
|
|
38
38
|
end
|
39
39
|
|
40
40
|
##
|
41
|
-
#
|
41
|
+
# Get any xml:base in effect for this element
|
42
42
|
#
|
43
43
|
# @return [String]
|
44
44
|
def base
|
45
|
-
|
45
|
+
if @base.nil?
|
46
|
+
@base = attribute_with_ns("base", RDF::XML.to_s) ||
|
47
|
+
(parent && parent.element? && parent.base) ||
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
@base == false ? nil : @base
|
46
52
|
end
|
47
53
|
|
48
54
|
##
|
@@ -115,7 +121,13 @@ module RDF::RDFXML
|
|
115
121
|
end
|
116
122
|
|
117
123
|
def xpath(*args)
|
118
|
-
@node.xpath(*args).map
|
124
|
+
@node.xpath(*args).map do |n|
|
125
|
+
# Get node ancestors
|
126
|
+
parent = n.ancestors.reverse.inject(nil) do |p,node|
|
127
|
+
NodeProxy.new(node, p)
|
128
|
+
end
|
129
|
+
NodeProxy.new(n, parent)
|
130
|
+
end
|
119
131
|
end
|
120
132
|
|
121
133
|
# For jRuby, there is a bug that prevents the namespace from being set on an element
|
@@ -42,7 +42,13 @@ module RDF::RDFXML
|
|
42
42
|
#
|
43
43
|
# @return [String]
|
44
44
|
def base
|
45
|
-
@
|
45
|
+
if @base.nil?
|
46
|
+
@base = attributes['xml:base'] ||
|
47
|
+
(parent && parent.element? && parent.base) ||
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
@base == false ? nil : @base
|
46
52
|
end
|
47
53
|
|
48
54
|
def attribute_with_ns(name, namespace)
|
@@ -129,7 +135,13 @@ module RDF::RDFXML
|
|
129
135
|
|
130
136
|
def xpath(*args)
|
131
137
|
#NodeSetProxy.new(::REXML::XPath.match(@node, path, namespaces), self)
|
132
|
-
::REXML::XPath.match(@node, *args).map
|
138
|
+
::REXML::XPath.match(@node, *args).map do |n|
|
139
|
+
# Get node ancestors
|
140
|
+
parent = n.ancestors.reverse.inject(nil) do |p,node|
|
141
|
+
NodeProxy.new(node, p)
|
142
|
+
end
|
143
|
+
NodeProxy.new(n, parent)
|
144
|
+
end
|
133
145
|
end
|
134
146
|
|
135
147
|
def elem?
|
data/lib/rdf/rdfxml/reader.rb
CHANGED
@@ -29,7 +29,7 @@ module RDF::RDFXML
|
|
29
29
|
|
30
30
|
def initialize(base, element, graph, &cb)
|
31
31
|
# Initialize the evaluation context, [5.1]
|
32
|
-
self.base = RDF::URI
|
32
|
+
self.base = RDF::URI(base)
|
33
33
|
@uri_mappings = {}
|
34
34
|
@language = nil
|
35
35
|
@graph = graph
|
@@ -138,7 +138,7 @@ module RDF::RDFXML
|
|
138
138
|
# @yield [reader] `self`
|
139
139
|
# @yieldparam [RDF::Reader] reader
|
140
140
|
# @yieldreturn [void] ignored
|
141
|
-
# @raise [Error]
|
141
|
+
# @raise [Error] Raises RDF::ReaderError if _validate_
|
142
142
|
def initialize(input = $stdin, options = {}, &block)
|
143
143
|
super do
|
144
144
|
@debug = options[:debug]
|
@@ -188,7 +188,7 @@ module RDF::RDFXML
|
|
188
188
|
|
189
189
|
raise "root must be a proxy not a #{root.class}" unless root.is_a?(@implementation::NodeProxy)
|
190
190
|
|
191
|
-
add_debug(root, "base_uri: #{@base_uri
|
191
|
+
add_debug(root, "base_uri: #{@base_uri.inspect}")
|
192
192
|
|
193
193
|
rdf_nodes = root.xpath("//rdf:RDF", "rdf" => RDF.to_uri.to_s)
|
194
194
|
if rdf_nodes.length == 0
|
@@ -250,8 +250,8 @@ module RDF::RDFXML
|
|
250
250
|
|
251
251
|
# Add debug event to debug array, if specified
|
252
252
|
#
|
253
|
-
# @param [Nokogiri::XML::Node, #to_s] node
|
254
|
-
# @param [String] message
|
253
|
+
# @param [Nokogiri::XML::Node, #to_s] node XML Node or string for showing context
|
254
|
+
# @param [String] message
|
255
255
|
# @yieldreturn [String] appended to message, to allow for lazy-evaulation of message
|
256
256
|
def add_debug(node, message = "")
|
257
257
|
return unless ::RDF::RDFXML.debug? || @debug
|
@@ -262,12 +262,12 @@ module RDF::RDFXML
|
|
262
262
|
|
263
263
|
# add a statement, object can be literal or URI or bnode
|
264
264
|
#
|
265
|
-
# @param [Nokogiri::XML::Node, any] node
|
266
|
-
# @param [URI, BNode] subject
|
267
|
-
# @param [URI] predicate
|
268
|
-
# @param [URI, BNode, Literal] object
|
269
|
-
# @return [Statement]
|
270
|
-
# @raise [RDF::ReaderError]
|
265
|
+
# @param [Nokogiri::XML::Node, any] node XML Node or string for showing context
|
266
|
+
# @param [URI, BNode] subject the subject of the statement
|
267
|
+
# @param [URI] predicate the predicate of the statement
|
268
|
+
# @param [URI, BNode, Literal] object the object of the statement
|
269
|
+
# @return [Statement] Added statement
|
270
|
+
# @raise [RDF::ReaderError] Checks parameter types and raises if they are incorrect if validating.
|
271
271
|
def add_triple(node, subject, predicate, object)
|
272
272
|
statement = RDF::Statement.new(subject, predicate, object)
|
273
273
|
add_debug(node) {"statement: #{statement}"}
|
@@ -276,10 +276,10 @@ module RDF::RDFXML
|
|
276
276
|
|
277
277
|
# XML nodeElement production
|
278
278
|
#
|
279
|
-
# @param [XML Element] el
|
280
|
-
# @param [EvaluationContext] ec
|
281
|
-
# @return [RDF::URI] subject
|
282
|
-
# @raise [RDF::ReaderError]
|
279
|
+
# @param [XML Element] el XMl Element to parse
|
280
|
+
# @param [EvaluationContext] ec Evaluation context
|
281
|
+
# @return [RDF::URI] subject The subject found for the node
|
282
|
+
# @raise [RDF::ReaderError] Raises Exception if validating
|
283
283
|
def nodeElement(el, ec)
|
284
284
|
raise "el must be a proxy not a #{el.class}" unless el.is_a?(@implementation::NodeProxy)
|
285
285
|
# subject
|
data/lib/rdf/rdfxml.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-rdfxml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-17 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdf
|
17
|
-
requirement: &
|
17
|
+
requirement: &70095897830720 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.3.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70095897830720
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rdf-xsd
|
28
|
-
requirement: &
|
28
|
+
requirement: &70095897829980 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.3.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70095897829980
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: nokogiri
|
39
|
-
requirement: &
|
39
|
+
requirement: &70095897829280 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.5.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70095897829280
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: equivalent-xml
|
50
|
-
requirement: &
|
50
|
+
requirement: &70095897828540 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 0.2.8
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70095897828540
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: open-uri-cached
|
61
|
-
requirement: &
|
61
|
+
requirement: &70095897827820 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.0.4
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70095897827820
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: spira
|
72
|
-
requirement: &
|
72
|
+
requirement: &70095897827060 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.0.12
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70095897827060
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rspec
|
83
|
-
requirement: &
|
83
|
+
requirement: &70095897826340 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 2.8.0
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70095897826340
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rdf-isomorphic
|
94
|
-
requirement: &
|
94
|
+
requirement: &70095897825560 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: 0.3.4
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70095897825560
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rdf-n3
|
105
|
-
requirement: &
|
105
|
+
requirement: &70095897824800 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: 0.3.4
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70095897824800
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: rdf-spec
|
116
|
-
requirement: &
|
116
|
+
requirement: &70095897824060 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: 0.3.4
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *70095897824060
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: yard
|
127
|
-
requirement: &
|
127
|
+
requirement: &70095897823420 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
version: 0.6.0
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *70095897823420
|
136
136
|
description: RDF::RDFXML is an RDF/XML reader and writer for the RDF.rb library suite.
|
137
137
|
email: public-rdf-ruby@w3.org
|
138
138
|
executables: []
|