File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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)
337337 # Determine the content type of this property element
338338 log_fatal "child must be a proxy not a #{ child . class } " unless child . is_a? ( @implementation ::NodeProxy )
339339
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?)
342342 add_debug ( child ) { "#{ text_nodes . to_a . length } text nodes, #{ element_nodes . to_a . length } element nodes" }
343343
344344 text_nodes . each do |node |
Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ def display_path
8181 end
8282 end
8383
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+
8492 ##
8593 # Return true of all child elements are text
8694 #
@@ -104,7 +112,7 @@ def namespaces
104112 def children
105113 @children ||= NodeSetProxy . new ( @node . children , self )
106114 end
107-
115+
108116 # Ancestors of this element, in order
109117 def ancestors
110118 @ancestors ||= parent ? parent . ancestors + [ parent ] : [ ]
Original file line number Diff line number Diff line change 202202 expect ( graph ) . to be_equivalent_graph ( expected , logger : logger )
203203 end
204204
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+
205223 context :exceptions do
206224 it "should raise an error if rdf:aboutEach is used, as per the negative parser test rdfms-abouteach-error001 (rdf:aboutEach attribute)" do
207225 sampledoc = %q(<?xml version="1.0" ?>
You can’t perform that action at this time.
0 commit comments