@@ -64,10 +64,11 @@ def extract_from_ancestors(el, &cb)
6464
6565 # Extract Evaluation Context from an element
6666 def extract_from_element ( el , &cb )
67- b = el . base
68- lang = el . language
69- self . base = self . base . join ( b ) if b
70- self . language = lang if lang
67+ self . language = el . language if el . language
68+ if b = el . base
69+ b = RDF ::URI ( b )
70+ self . base = b . absolute? ? b : self . base . join ( b )
71+ end
7172 self . uri_mappings . merge! ( extract_mappings ( el , &cb ) )
7273 end
7374
@@ -302,7 +303,7 @@ def nodeElement(el, ec)
302303 # If there is an attribute a in propertyAttr with a.URI == rdf:type
303304 # then u:=uri(identifier:=resolve(a.string-value))
304305 # and the following triple is added to the graph:
305- u = ec . base . join ( attr . value )
306+ u = uri ( ec . base , attr . value )
306307 add_triple ( attr , subject , RDF . type , u )
307308 elsif is_propertyAttr? ( attr )
308309 # Attributes not RDF.type
@@ -530,12 +531,12 @@ def nodeElement(el, ec)
530531 # Reification
531532 reify ( id , child , subject , predicate , literal , child_ec ) if id
532533 else
533- if resourceAttr
534- resource = ec . base . join ( resourceAttr )
534+ resource = if resourceAttr
535+ uri ( ec . base , resourceAttr )
535536 elsif nodeID
536- resource = bnode ( nodeID )
537+ bnode ( nodeID )
537538 else
538- resource = RDF ::Node . new
539+ RDF ::Node . new
539540 end
540541
541542 # produce triples for attributes
@@ -605,7 +606,7 @@ def parse_subject(el, ec)
605606 when about
606607 about = RDF ::NTriples . unescape ( about . value )
607608 add_debug ( el ) { "parse_subject, about: #{ about . inspect } " }
608- ec . base . join ( about )
609+ uri ( ec . base , about )
609610 else
610611 add_debug ( el , "parse_subject, BNode" )
611612 RDF ::Node . new
@@ -687,8 +688,15 @@ def old_property_check(el)
687688 end
688689
689690 def uri ( value , append = nil )
690- value = RDF ::URI . new ( value )
691- value = value . join ( append ) if append
691+ append = RDF ::URI ( append )
692+ value = RDF ::URI ( value )
693+ value = if append . absolute?
694+ value = append
695+ elsif append
696+ value = value . join ( append )
697+ else
698+ value
699+ end
692700 value . validate! if validate?
693701 value . canonicalize! if canonicalize?
694702 value = RDF ::URI . intern ( value ) if intern?
0 commit comments