# File lib/openurl/context_object.rb, line 47
    def xml      
      doc = REXML::Document.new()
      coContainer = doc.add_element "ctx:context-objects"
      coContainer.add_namespace("ctx","info:ofi/fmt:xml:xsd:ctx")
      coContainer.add_namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
      coContainer.add_attribute("xsi:schemaLocation", "info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx")
      co = coContainer.add_element "ctx:context-object"
      @admin.each_key do |k|
        co.add_attribute(@admin[k]["label"], @admin[k]["value"])
      end

      [@referent, @referringEntity, @requestor, @referrer].each do | ent |
        ent.xml(co) unless ent.empty?
      end
      
      [@serviceType, @resolver, @custom].each do |entCont|
        entCont.each do |ent|
          ent.xml(co) unless ent.empty?                      
        end
      end

      return doc.to_s
    end