lib/rdf/rdfxml/writer.rb
# Make sure a CURIE is defined
Make sure a CURIE is defined
Make sure a CURIE is defined
def ensure_curie(resource)
      if get_curie(resource) == resource.to_s || get_curie(resource).split(':', 2).last =~ /[\.#]/
        uri = resource.to_s
        separation = uri.rindex(%r{[^a-zA-Z_0-9-][a-zA-Z_][a-z0-9A-Z_-]*$})
        return @uri_to_prefix[uri] = nil unless separation
        base_uri = uri.to_s[0..separation]
        suffix = uri.to_s[separation+1..-1]
        @gen_prefix = @gen_prefix ? @gen_prefix.succ : "ns0"
        log_debug {"ensure_curie: generated prefix #{@gen_prefix} for #{base_uri}"}
        @uri_to_prefix[base_uri] = @gen_prefix
        @uri_to_term_or_curie[uri] = "#{@gen_prefix}:#{suffix}"
        prefix(@gen_prefix, base_uri)
        get_curie(resource)
      end
    end
def ensure_curie ( resource ) if get_curie ( resource ) == resource . to_s || get_curie ( resource ) . split ( ':' , 2 ) . last =~ / [ \. #] / uri = resource . to_s separation = uri . rindex ( %r{ [^a-zA-Z_0-9-][a-zA-Z_][a-z0-9A-Z_-]*$ } ) return @uri_to_prefix [ uri ] = nil unless separation base_uri = uri . to_s [ 0 .. separation ] suffix = uri . to_s [ separation + 1 .. - 1 ] @gen_prefix = @gen_prefix ? @gen_prefix . succ : "ns0" log_debug { "ensure_curie: generated prefix #{@gen_prefix} for #{base_uri}" } @uri_to_prefix [ base_uri ] = @gen_prefix @uri_to_term_or_curie [ uri ] = "#{@gen_prefix}:#{suffix}" prefix ( @gen_prefix , base_uri ) get_curie ( resource ) end end
Make sure a CURIE is defined
Make sure a CURIE is defined
# No vocabulary found, invent one # Add bindings for predicates not already having bindings # From RDF/XML Syntax and Processing: #   An XML namespace-qualified name (QName) has restrictions on the legal characters such that not all property URIs can be expressed as these names. It is recommended that implementors of RDF serializers, in order to break a URI into a namespace name and a local name, split it after the last XML non-NCName character, ensuring that the first character of the name is a Letter or '_'. If the URI ends in a non-NCName character then throw a "this graph cannot be serialized in RDF/XML" exception or error.
resource
<not_specific>