rdfobjects 0.3.2 → 0.3.3
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/lib/rdf_objects/parsers.rb +10 -4
- metadata +2 -2
data/lib/rdf_objects/parsers.rb
CHANGED
@@ -151,7 +151,7 @@ class XMLParser
|
|
151
151
|
resource = Resource.new(resource_node.attribute_with_ns('about', "http://www.w3.org/1999/02/22-rdf-syntax-ns#").value)
|
152
152
|
unless (resource_node.name == "Description" and resource_node.namespace.href == "http://www.w3.org/1999/02/22-rdf-syntax-ns#") or
|
153
153
|
(resource_node.name == "item" and resource_node.namespace.href == "http://purl.org/rss/1.0/")
|
154
|
-
resource.assert("[rdf:type]","#{resource_node.namespace.href}#{resource_node.name}")
|
154
|
+
resource.assert("[rdf:type]",Resource.new("#{resource_node.namespace.href}#{resource_node.name}"))
|
155
155
|
end
|
156
156
|
resource_node.children.each do | child |
|
157
157
|
next if child.text?
|
@@ -160,8 +160,7 @@ class XMLParser
|
|
160
160
|
obj_resource = Resource.new(object_uri.value)
|
161
161
|
resource.assert(predicate, obj_resource)
|
162
162
|
collection << obj_resource
|
163
|
-
elsif child
|
164
|
-
|
163
|
+
elsif all_text?(child)
|
165
164
|
opts = {}
|
166
165
|
if lang = child.attribute_with_ns("lang", "http://www.w3.org/XML/1998/namespace")
|
167
166
|
opts[:language] = lang.value
|
@@ -169,7 +168,7 @@ class XMLParser
|
|
169
168
|
if datatype = child.attribute_with_ns("datatype", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
170
169
|
opts[:data_type] = datatype.value
|
171
170
|
end
|
172
|
-
resource.assert(predicate, Literal.new(child.content,opts))
|
171
|
+
resource.assert(predicate, Literal.new(child.content.strip,opts))
|
173
172
|
end
|
174
173
|
child.xpath("./*[@rdf:about]").each do | grandchild |
|
175
174
|
gc_resource = Resource.new(grandchild.attribute_with_ns('about', "http://www.w3.org/1999/02/22-rdf-syntax-ns#").value)
|
@@ -181,6 +180,13 @@ class XMLParser
|
|
181
180
|
collection << resource
|
182
181
|
end
|
183
182
|
|
183
|
+
def self.all_text?(node)
|
184
|
+
node.children.each do | child |
|
185
|
+
return false unless child.text?
|
186
|
+
end
|
187
|
+
true
|
188
|
+
end
|
189
|
+
|
184
190
|
def self.parse_rdfxml(doc)
|
185
191
|
collection = []
|
186
192
|
doc.root.xpath("./*[@rdf:about]").each do | resource_node |
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdfobjects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Singer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-07 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|