lib/active_rdf/lib/active_rdf/objectmanager/resource.rb
# adding accessor to the class uri:
# the uri of the rdf resource being represented by this class
adding accessor to the class uri:
the uri of the rdf resource being represented by this class
adding accessor to the class uri : the uri of the rdf resource being represented by this class
def to_xml
      base = Namespace.expand(Namespace.prefix(self),'').chop
      xml = "<?xml version=\"1.0\"?>\n"
      xml += "<rdf:RDF xmlns=\"#{base}\#\"\n"
      Namespace.abbreviations.each { |p| uri = Namespace.expand(p,''); xml += "  xmlns:#{p.to_s}=\"#{uri}\"\n" if uri != base + '#' }
      xml += "  xml:base=\"#{base}\">\n"
      xml += "<rdf:Description rdf:about=\"\##{localname}\">\n"
      direct_predicates.each do |p|
        objects = Query.new.distinct(:o).where(self, p, :o).execute
        objects.each do |obj|
          prefix, localname = Namespace.prefix(p), Namespace.localname(p)
          pred_xml = if prefix
                       "%s:%s" % [prefix, localname]
          else
            p.uri
          end
          case obj
            when RDFS::Resource
            xml += "  <#{pred_xml} rdf:resource=\"#{obj.uri}\"/>\n"
            when LocalizedString
            xml += "  <#{pred_xml} xml:lang=\"#{obj.lang}\">#{obj}</#{pred_xml}>\n"
          else
            xml += "  <#{pred_xml} rdf:datatype=\"#{obj.xsd_type.uri}\">#{obj}</#{pred_xml}>\n"
          end
        end
      end
      xml += "</rdf:Description>\n"
      xml += "</rdf:RDF>"
    end
def to_xml base = Namespace . expand ( Namespace . prefix ( self ) , '' ) . chop xml = "<?xml version=\"1.0\"?>\n" xml += "<rdf:RDF xmlns=\"#{base}\#\"\n" Namespace . abbreviations . each { | p | uri = Namespace . expand ( p , '' ) ; xml += "  xmlns:#{p.to_s}=\"#{uri}\"\n" if uri != base + '#' } xml += "  xml:base=\"#{base}\">\n" xml += "<rdf:Description rdf:about=\"\##{localname}\">\n" direct_predicates . each do | p | objects = Query . new . distinct ( :o ) . where ( self , p , :o ) . execute objects . each do | obj | prefix , localname = Namespace . prefix ( p ) , Namespace . localname ( p ) pred_xml = if prefix "%s:%s" % [ prefix , localname ] else p . uri end case obj when RDFS :: Resource xml += "  <#{pred_xml} rdf:resource=\"#{obj.uri}\"/>\n" when LocalizedString xml += "  <#{pred_xml} xml:lang=\"#{obj.lang}\">#{obj}</#{pred_xml}>\n" else xml += "  <#{pred_xml} rdf:datatype=\"#{obj.xsd_type.uri}\">#{obj}</#{pred_xml}>\n" end end end xml += "</rdf:Description>\n" xml += "</rdf:RDF>" end
adding accessor to the class uri:
the uri of the rdf resource being represented by this class
adding accessor to the class uri : the uri of the rdf resource being represented by this class