W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > April 2016

How to define the prefix for a created vocabulary?

From: Ian Dickinson <i.j.dickinson@gmail.com>
Date: Wed, 20 Apr 2016 10:15:06 +0100
Message-ID: <CAHvAVxZVN3v2gpTsBV5mk9Lf5LMGEzE4ieaWdUsgKHFN7NSkRw@mail.gmail.com>
To: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
The .qname() method on URI is quite handy, but it relies on knowing
the __prefix__ for a vocabulary. For vocabs that I define in my code,
the constructor takes the base URI of the vocabulary, but I can't see
any way to define the __prefix__. Am I missing something?

For reference, my use case is that I'm creating constants in my code
to interact with a remote RDF store (i.e. I'm not loading files of
triples into my Ruby code, which is how I think the prefix usually
gets set on a vocabulary):

COMMON = RDF::Vocabulary.new( "http://foo.bar.com/common/" )
MAN = COMMON.man
FANFARE = COMMON.fanfare

This all works very nicely. Later, I'd like to create a slug for the
resources I'm using, which basically comes down to the local name of
the resource:

def slug( uri_resource )
  uri_resource.qname.second
end

Only at the moment, FANFARE.qname returns nil because the common vocab
doesn't have a __prefix__

Thanks,
Ian
Received on Wednesday, 20 April 2016 09:15:34 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:18 UTC