Comments (8)
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.
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.
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.
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.
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.
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.
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.
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)
- RDF::NTriples::Reader does not `require 'strscan'` HOT 3
- Ruby 2.7.1, URI.decode is obsolete
- bad behaviour in RDF::List HOT 7
- blank nodes reuse memory addresses, causing problems for persistent stores HOT 3
- Is there a "prettier" HOT 1
- Is there a more 'elegant' way to do this? HOT 3
- Strange "file missing" error with 3.1.14 release HOT 6
- Comparing two repositories HOT 2
- Verbose warnings on 2.7+ Ruby HOT 2
- 3.2.1 removes `RDF::Repository::Implementation::SerializedTransaction` HOT 5
- Is it possible to change the standard prefixes? HOT 7
- docmentation: how to create new vocabs, and langage-tagged strings in vocabs HOT 3
- Weird `require 'enumerator'` issue caused by this gem HOT 5
- change from DateTime < Literal to DateTime < Temporal breaks downstream customization HOT 5
- Invalid argument @ rb_sysopen - (Errno:EINVAL) when using local files on Windows HOT 10
- RDF::Vocabulary.find on RDF vocab returns RDF class HOT 5
- Ruby regexp warning: character class has duplicated range HOT 10
- Errno::EINVAL using `each_statement` with a LARGE, local NTriples file HOT 1
- RDF::Query#graph_name does not behave has documented HOT 3
- Error when using local files on Windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rdf.