Move literals handling to models and collections #114

bergie opened this Issue Jun 14, 2012 · 1 comment


None yet
2 participants

bergie commented Jun 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'});

  '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

neogermi commented Jun 14, 2012

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