Hi

I have just been watching the AllegroGraph + Amazon EC2 tutorial in which an example Ruby on Rails app is created.

Apparently Ruby has that shortcut way to handle namespaces slash vocabularies:

vocab = RDF::Vocabulary.new("http://example.com/some_domain#")
term = vocab['some_term']

The above produces a http://example.com/some_domain#some_term node. It seems useful if we want to work with full URIs.

Is there such a facility avaiable in dotNetRDF?

Thanks, Tom

asked 05 Nov '12, 09:48

Tomasz%20Pluskiewicz's gravatar image

Tomasz Plusk...
1.4k19
accept rate: 30%


Not right now, you can add it fairly trivially to generate URIs, generating actual Nodes is tricky in the current code base because Nodes are currently scoped to Graphs (this will change in 2.0)

Simple implementation:

public class Vocabulary
{
  public Vocabulary(String nsUri)
  {
    this.NamespaceUri = nsUri;
  }

  public String NamespaceUri
  {
    get; private set;
  }

  public Uri this[String localName]
  {
    get
    {
      return UriFactory.Create(this.NamespaceURI + localName);
    }
  }
}
permanent link

answered 06 Nov '12, 10:32

Rob%20Vesse's gravatar image

Rob Vesse ♦
13.9k1715
accept rate: 29%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×80
×34
×18

question asked: 05 Nov '12, 09:48

question was seen: 1,155 times

last updated: 06 Nov '12, 10:32