lib/rdf/rdfxml/reader.rb
##
# Iterates the given block for each RDF statement in the input.
#
# @yield  [statement]
# @yieldparam [RDF::Statement] statement
# @return [void]
Iterates the given block for each RDF statement in the input.
Iterates the given block for each RDF statement in the input .
def each_statement(&block)
      if block_given?
        @callback = block
        return unless root
        log_fatal "root must be a proxy not a #{root.class}" unless root.is_a?(@implementation::NodeProxy)
        add_debug(root, "base_uri: #{base_uri.inspect}")
        rdf_nodes = root.xpath("//rdf:RDF", "rdf" => RDF.to_uri.to_s)
        if rdf_nodes.size == 0
          ec = EvaluationContext.new(base_uri, root, @graph) do |prefix, value|
            prefix(prefix, value)
          end
          nodeElement(root, ec)
        else
          rdf_nodes.each do |node|
            log_fatal "node must be a proxy not a #{node.class}" unless node.is_a?(@implementation::NodeProxy)
            ec = EvaluationContext.new(base_uri, nil, @graph)
            ec.extract_from_ancestors(node) do |prefix, value|
              prefix(prefix, value)
            end
            node.children.each {|el|
              next unless el.element?
              log_fatal "el must be a proxy not a #{el.class}" unless el.is_a?(@implementation::NodeProxy)
              new_ec = ec.clone(el) do |prefix, value|
                prefix(prefix, value)
              end
              nodeElement(el, new_ec)
            }
          end
        end
        if validate? && log_statistics[:error]
          raise RDF::ReaderError, "Errors found during processing"
        end
      end
      enum_for(:each_statement)
    end
def each_statement ( & block ) if block_given? @callback = block return unless root log_fatal "root must be a proxy not a #{root.class}" unless root . is_a? ( @implementation :: NodeProxy ) add_debug ( root , "base_uri: #{base_uri.inspect}" ) rdf_nodes = root . xpath ( "//rdf:RDF" , "rdf" => RDF . to_uri . to_s ) if rdf_nodes . size == 0 ec = EvaluationContext . new ( base_uri , root , @graph ) do | prefix , value | prefix ( prefix , value ) end nodeElement ( root , ec ) else rdf_nodes . each do | node | log_fatal "node must be a proxy not a #{node.class}" unless node . is_a? ( @implementation :: NodeProxy ) ec = EvaluationContext . new ( base_uri , nil , @graph ) ec . extract_from_ancestors ( node ) do | prefix , value | prefix ( prefix , value ) end node . children . each { | el | next unless el . element? log_fatal "el must be a proxy not a #{el.class}" unless el . is_a? ( @implementation :: NodeProxy ) new_ec = ec . clone ( el ) do | prefix , value | prefix ( prefix , value ) end nodeElement ( el , new_ec ) } end end if validate? && log_statistics [ :error ] raise RDF :: ReaderError , "Errors found during processing" end end enum_for ( :each_statement ) end
Iterates the given block for each RDF statement in the input.
Iterates the given block for each RDF statement in the input .
# Block called from add_statement # If none found, root element may be processed as an RDF Node # XXX Skip this element if it's contained within another rdf:RDF element # Extract base, lang and namespaces from parents to create proper evaluation context
None
void
block
<not_specific>
]
<not_specific>
None
<not_specific>
None