File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change
1
+ platform :
2
+ Rubygems :
3
+ rdf-isomorphic :
4
+ tests :
5
+ unmaintained : skip
Original file line number Diff line number Diff line change @@ -337,8 +337,8 @@ def nodeElement(el, ec)
337
337
# Determine the content type of this property element
338
338
log_fatal "child must be a proxy not a #{ child . class } " unless child . is_a? ( @implementation ::NodeProxy )
339
339
340
- text_nodes = child . children . select { | e | e . text? && ! e . blank? }
341
- element_nodes = child . children . select { | c | c . element? }
340
+ text_nodes = child . children . select ( & : text?)
341
+ element_nodes = child . children . select ( & : element?)
342
342
add_debug ( child ) { "#{ text_nodes . to_a . length } text nodes, #{ element_nodes . to_a . length } element nodes" }
343
343
344
344
text_nodes . each do |node |
Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ def display_path
81
81
end
82
82
end
83
83
84
+ ##
85
+ # Return true of this is a text node
86
+ #
87
+ # @return [Array<:text, :element, :attribute>]
88
+ def text?
89
+ ( @node . text? || @node . cdata? ) && !@node . blank?
90
+ end
91
+
84
92
##
85
93
# Return true of all child elements are text
86
94
#
@@ -104,7 +112,7 @@ def namespaces
104
112
def children
105
113
@children ||= NodeSetProxy . new ( @node . children , self )
106
114
end
107
-
115
+
108
116
# Ancestors of this element, in order
109
117
def ancestors
110
118
@ancestors ||= parent ? parent . ancestors + [ parent ] : [ ]
Original file line number Diff line number Diff line change 202
202
expect ( graph ) . to be_equivalent_graph ( expected , logger : logger )
203
203
end
204
204
205
+ it "reads text from CDATA" do
206
+ sampledoc = %(<?xml version="1.0" encoding="utf-8"?>
207
+ <rdf:RDF
208
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
209
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
210
+ >
211
+ <rdf:Property rdf:about="http://www.w3.org/ns/oa#annotationService">
212
+ <rdfs:comment><![CDATA[Text]]></rdfs:comment>
213
+ </rdf:Property>
214
+ </rdf:RDF>)
215
+ expected = %(
216
+ <http://www.w3.org/ns/oa#annotationService> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
217
+ <http://www.w3.org/ns/oa#annotationService> <http://www.w3.org/2000/01/rdf-schema#comment> "Text" .
218
+ )
219
+ graph = parse ( sampledoc , validate : true )
220
+ expect ( graph ) . to be_equivalent_graph ( expected , logger : logger )
221
+ end
222
+
205
223
context :exceptions do
206
224
it "should raise an error if rdf:aboutEach is used, as per the negative parser test rdfms-abouteach-error001 (rdf:aboutEach attribute)" do
207
225
sampledoc = %q(<?xml version="1.0" ?>
You can’t perform that action at this time.
0 commit comments