GithubHelp home page GithubHelp logo

Comments (8)

artob avatar artob commented on May 18, 2024

I'm not sure I follow...

The only requirement is that when the prefix value as attached to a suffix, that that be a URI.

Doesn't that mean that the prefix value is, by definition, also a URI? How would one get a URI out of a prefix value which isn't a URI, concatenated with a suffix?

from rdf.

gkellogg avatar gkellogg commented on May 18, 2024

If "dc:title" is considered to be a URI, then, following the logic described for RDF/XML, to create a prefix you find the first non-NCName character from the right, which is ':'. This becomes the terminator, so that you create a new prefix with a value "dc:", so that when you add the suffix "title", you're left with "dc:title". However, "dc:" is, itself, not a URI. Nothing actually requires that it be a URI, only a string value that is applied to values after substituting the prefix.

In this case, I'd have the following XML namespace definition, to allow me to express this:

<rdf:RDF xmlns:ns0="dc:">
  <rdf:Description rdf:about="">
    <ns0:title>Title</ns0:title>
  </rdf:Description>
</rdf:RDF>

This recreates the following triple:

<> <dc:title> "Title" .

Note that "dc:" is not a valid URI.

from rdf.

artob avatar artob commented on May 18, 2024

All right, thanks, that's clearer. So what it really comes down to is that dc: isn't a valid URI in and of itself. Which of course RDF.rb presently complains about even a little too loudly:

>> RDF::URI('dc:')
Addressable::URI::InvalidURIError: Absolute URI missing hierarchical segment: 'dc:'

I still need to change it to not validate URIs by default when constructed, so that we don't e.g. error out when parsing DBpedia datasets which contain invalid URIs.

Non-validating URI construction would solve the present issue as well as changing to strings does. So I guess the question is which one shall we go for in RDF.rb 0.3.0?

from rdf.

gkellogg avatar gkellogg commented on May 18, 2024

Your choice, if you want to continue to use URI, and just avoid the check, that's fine, but most discussion in RDFa WG is that it's just a string.

from rdf.

artob avatar artob commented on May 18, 2024

OK, I'll change it to be just a string... Wouldn't really want to make any large changes, such as messing about with the RDF::URI constructor, before 0.3.0 is out.

from rdf.

gkellogg avatar gkellogg commented on May 18, 2024

I wanted to be sure this critical element from a side-discussion wasn't lost:

In Ruby 1.8, "".to_sym is not defined, therefore trying to use an empty or default prefix using Reader/Writer#prefix(nil) fails. The following implementation takes care of the nil case, but using nil, rather than nil.to_sym, in this case:

def prefix(name, uri = nil)
  name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym)
  uri.nil? ? prefixes[name] : prefixes[name] = (uri.respond_to?(:to_sym) ? uri.to_sym : uri.to_s.to_sym)
end

from rdf.

artob avatar artob commented on May 18, 2024

Changed RDF::Writer#prefix and RDF::Reader#prefix to pass through any given prefix value without trying to convert it to a symbol or assuming that it is an RDF::URI (closed by 36b4aea).

from rdf.

artob avatar artob commented on May 18, 2024

I've merged your related pull request #66, with the change in 36b4aea.

Note that there is no advantage to having the prefix values be Ruby symbols, and that would arguably be misusing what Ruby symbols are intended for; they are not meant as a generic interned string cache, either syntactically or in terms of how they are implemented.

Making potentially one-off strings into symbols dynamically is a potential memory leak, since it cannot be assumed that symbols are ever deleted from Ruby's global symbol table once inserted into it. Thus for generic interned string use cases, a weak-reference cache (such as the implementation in RDF::Util::Cache) ought to be used instead.

In this case, however, there is just no need to intern the prefix values, only the prefix keys. With the change in 36b4aea, the prefix value you get back out is whatever you put in. You can thus define the convention of your choosing in the documentation for rdf-rdfxml and rdf-n3.

from rdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.