lib/rdf/microdata/reader.rb in rdf-microdata-0.1.2 vs lib/rdf/microdata/reader.rb in rdf-microdata-0.1.3
- old
+ new
@@ -145,15 +145,17 @@
statement = RDF::Statement.new(subject, predicate, object)
add_debug(node, "statement: #{RDF::NTriples.serialize(statement)}")
@callback.call(statement)
end
- # Parsing an RDFa document (this is *not* the recursive method)
+ # Parsing a Microdata document (this is *not* the recursive method)
def parse_whole_document(doc, base)
base_el = doc.at_css('html>head>base')
base = base_el.attribute('href').to_s.split('#').first if base_el
+ add_debug(doc, "parse_whole_doc: options=#{@options.inspect}")
+
if (base)
# Strip any fragment from base
base = base.to_s.split('#').first
base = @base_uri = uri(base)
add_debug(base_el, "parse_whole_doc: base='#{base}'")
@@ -337,10 +339,10 @@
predicate = if name_uri.absolute?
name_uri
elsif @options[:rdf_terms]
# Use the URI of the type to create URIs for @itemprop terms
add_debug(element, "gentrips: rdf_type=#{rdf_type}")
- predicate = RDF::URI(rdf_type.to_s.sub(/(?<=[\/\#])[^\/\#]*$/, name))
+ predicate = RDF::URI(rdf_type.to_s.sub(/([\/\#])[^\/\#]*$/, '\1' + name))
elsif !name.include?(':')
s = type.to_s
s += '%20' unless s[-1,1] == ':'
s += name
RDF::MD[s.gsub('#', '%23')]
\ No newline at end of file