@@ -31,15 +31,15 @@ class EvaluationContext
3131 attr_accessor :graph
3232 attr_accessor :li_counter
3333 attr_accessor :direction
34- attr_accessor :version # RDF Version, mirrored here
34+ attr_accessor :version
3535
36- def initialize ( base , element , graph , version : nil , &cb )
36+ def initialize ( base , element , graph , &cb )
3737 # Initialize the evaluation context, [5.1]
3838 self . base = RDF ::URI ( base )
3939 @uri_mappings = { }
4040 @language = nil
4141 @direction = nil
42- @version = version
42+ @version = nil
4343 @graph = graph
4444 @li_counter = 0
4545
@@ -74,6 +74,7 @@ def extract_from_ancestors(el, &cb)
7474 # Extract Evaluation Context from an element
7575 def extract_from_element ( el , &cb )
7676 self . language = el . language if el . language
77+ self . version = el . version if el . version
7778 # Direction only used in RDF 1.2 or greater
7879 self . direction = el . direction if el . direction && self . version . to_s >= "1.2"
7980 # Direction requires the appropriate ITS version
@@ -112,7 +113,7 @@ def base=(b)
112113 end
113114
114115 def inspect
115- v = %w( base subject language direction ) . map { |a | "#{ a } ='#{ self . send ( a ) . nil? ? 'nil' : self . send ( a ) } '" }
116+ v = %w( base subject language direction version ) . map { |a | "#{ a } ='#{ self . send ( a ) . nil? ? 'nil' : self . send ( a ) } '" }
116117 v << "uri_mappings[#{ uri_mappings . keys . length } ]"
117118 v . join ( "," )
118119 end
@@ -213,11 +214,7 @@ def each_statement(&block)
213214 if rdf_nodes . size == 0
214215 # If none found, root element may be processed as an RDF Node
215216
216- # Extract RDF version from root
217- @version = root . version
218- add_debug ( root , "version: #{ @version . inspect } " )
219-
220- ec = EvaluationContext . new ( base_uri , root , @graph , version : @version ) do |prefix , value |
217+ ec = EvaluationContext . new ( base_uri , root , @graph ) do |prefix , value |
221218 prefix ( prefix , value )
222219 end
223220
@@ -227,13 +224,8 @@ def each_statement(&block)
227224 log_fatal "node must be a proxy not a #{ node . class } " unless node . is_a? ( @implementation ::NodeProxy )
228225 # XXX Skip this element if it's contained within another rdf:RDF element
229226
230- # Extract RDF version from node
231- # XXX potentially, one node is processed with version "1.2" and others are parsed without a version.
232- @version = node . version
233- add_debug ( root , "version: #{ @version . inspect } " )
234-
235227 # Extract base, lang, direction, version and namespaces from parents to create proper evaluation context
236- ec = EvaluationContext . new ( base_uri , nil , @graph , version : @version )
228+ ec = EvaluationContext . new ( base_uri , nil , @graph )
237229 ec . extract_from_ancestors ( node ) do |prefix , value |
238230 prefix ( prefix , value )
239231 end
@@ -419,6 +411,7 @@ def nodeElement(el, ec)
419411 when "parseType" then parseType = attr . value
420412 when "resource" then resourceAttr = attr . value
421413 when "nodeID" then nodeID = attr . value
414+ when "version" then nil # version already extracted
422415 else attrs [ attr ] = attr . value
423416 end
424417 elsif attr . namespace . href == RDF ::ITS . to_s
0 commit comments