Skip to content
This repository

Move literals handling to models and collections #114

Open
bergie opened this Issue June 14, 2012 · 1 comment

2 participants

Henri Bergius Sebastian Germesin
Henri Bergius
Owner
bergie commented June 14, 2012

Now we have two different ways to handle literals:

  • Literals from RDFa (and tools like Create.js) are stored as-is, as string values
  • Literals from services like Stanbol are arrays of objects with keys like @language and @value

This difference makes for messy code. We should implement all literals in the same way, as collections of Literal objects (with subtypes like StringLiteral and UriLiteral). __toString methods should be used to allow simple usage.

This would allow setting values with:

e.set({'rdfs:label': 'Foo'});

e.set({
  'rdfs:label': new v.StringLiteral({
      value: 'Foo',
      lang: 'en'
  })
});

e.set({'rdfs:label': 'Foo'}, { lang: 'en' });

And getting with:

"" + e.get('rdfs:label'); // Foo

"" + e.get(('rdfs:label').get('en'); // Foo
Sebastian Germesin

For this, we also need to add default language handling in VIE:

var v = new VIE();
v.getLang (); // the language of the document OR "en"
v.setLang("de"); // accepts language codes only in ISO 639-1 format
v.getLang(); // "de"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.