Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URIs don't begin with < or end with > #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ VIE.prototype.Collection = Backbone.Collection.extend({
id = id.replace("_:bnode", 'c');
return this._byCid[id];
} else {
return this._byId["<" + id + ">"];
return this._byId[id];
}
} else {
id = this.toReference(id);
Expand Down Expand Up @@ -104,7 +104,7 @@ VIE.prototype.Collection = Backbone.Collection.extend({
},

isReference: function(uri){
var matcher = new RegExp("^\\<([^\\>]*)\\>$");
var matcher = new RegExp("^([^\\>]*)$");
if (matcher.exec(uri)) {
return true;
}
Expand All @@ -115,7 +115,7 @@ VIE.prototype.Collection = Backbone.Collection.extend({
if (this.isReference(uri)) {
return uri;
}
return '<' + uri + '>';
return uri;
},

fromReference: function(uri){
Expand Down
8 changes: 4 additions & 4 deletions src/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ VIE.prototype.Entity = function(attrs, opts) {
},

isReference: function(uri){
var matcher = new RegExp("^\\<([^\\>]*)\\>$");
var matcher = new RegExp("^([^\\>]*)$");
if (matcher.exec(uri)) {
return true;
}
Expand All @@ -254,12 +254,12 @@ VIE.prototype.Entity = function(attrs, opts) {
}
else if (ns.isCurie(uri)) {
ret = ns.uri(uri);
if (ret === "<" + ns.base() + uri + ">") {
if (ret === ns.base() + uri) {
/* no base namespace extension with IDs */
ret = '<' + uri + '>';
ret = uri;
}
} else if (!ns.isUri(uri)) {
ret = '<' + uri + '>';
ret = uri;
}
return ret;
},
Expand Down
57 changes: 29 additions & 28 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ VIE.Util = {
((safe)? "]" : "");
}
}
throw new Error("No prefix found for URI '" + uri + "'!");
return uri;
// throw new Error("No prefix found for URI '" + uri + "'!");
},

// ### VIE.Util.isCurie(curie, namespaces)
Expand Down Expand Up @@ -78,15 +79,15 @@ VIE.Util = {
// VIE.Util.isCurie(scurie, ns); // --> true
// VIE.Util.isCurie(text, ns); // --> false
isCurie : function (curie, namespaces) {
try {
VIE.Util.toUri(curie, namespaces);
return true;
} catch (e) {
return false;
}
if (VIE.Util.isUri(curie)) {
return false;
} else {
try {
VIE.Util.toUri(curie, namespaces);
return true;
} catch (e) {
return false;
}
}
},

Expand Down Expand Up @@ -117,12 +118,12 @@ VIE.Util = {
for (var prefix in namespaces.toObj()) {
if (prefix !== "" && (curie.indexOf(prefix + ":") === 0 || curie.indexOf("[" + prefix + ":") === 0)) {
var pattern = new RegExp("^" + "\\[{0,1}" + prefix + delim);
return "<" + curie.replace(pattern, namespaces.get(prefix)).replace(/\]{0,1}$/, '') + ">";
return curie.replace(pattern, namespaces.get(prefix)).replace(/\]{0,1}$/, '');
}
}
/* check for the default namespace */
if (curie.indexOf(delim) === -1) {
return "<" + namespaces.base() + curie + ">";
return namespaces.base() + curie;
}
throw new Error("No prefix found for CURIE '" + curie + "'!");
},
Expand All @@ -142,7 +143,7 @@ VIE.Util = {
// VIE.Util.isUri(uri); // --> true
// VIE.Util.isUri(curie); // --> false
isUri : function (something) {
return (typeof something === "string" && something.search(/^<.+>$/) === 0);
return (typeof something === "string" && something.search(/^.+$/) === 0);
},

// ### VIE.Util.mapAttributeNS(attr, ns)
Expand All @@ -167,9 +168,9 @@ VIE.Util = {
a = ns.uri(attr);
} else if (!ns.isUri(attr)) {
if (attr.indexOf(":") === -1) {
a = '<' + ns.base() + attr + '>';
a = ns.base() + attr;
} else {
a = '<' + attr + '>';
a = attr ;
}
}
return a;
Expand Down Expand Up @@ -388,12 +389,12 @@ VIE.Util = {
var jsonLD = [];
_.forEach(results, function(value, key) {
var entity = {};
entity['@subject'] = '<' + key + '>';
entity['@subject'] = key ;
_.forEach(value, function(triples, predicate) {
predicate = '<' + predicate + '>';
//predicate = '<' + predicate;
_.forEach(triples, function(triple) {
if (triple.type === 'uri') {
triple.value = '<' + triple.value + '>';
triple.value = triple.value;
}

if (entity[predicate] && !_.isArray(entity[predicate])) {
Expand Down Expand Up @@ -431,7 +432,7 @@ VIE.Util = {
if (!SchemaOrg) {
throw new Error("Please load the schema.json file.");
}
vie.types.remove("<http://schema.org/Thing>");
vie.types.remove("http://schema.org/Thing");

var baseNSBefore = (baseNS)? baseNS : vie.namespaces.base();
vie.namespaces.base(baseNS);
Expand Down Expand Up @@ -613,11 +614,11 @@ VIE.Util = {
return [
jQuery.rdf.triple(this.subject.toString(),
'a',
'<' + ns.base() + 'Person>', {
ns.base() + 'Person', {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'name>',
ns.base() + 'name',
this.label, {
namespaces: ns.toObj()
})
Expand All @@ -636,11 +637,11 @@ VIE.Util = {
return [
jQuery.rdf.triple(this.subject.toString(),
'a',
'<' + ns.base() + 'Person>', {
ns.base() + 'Person', {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'name>',
ns.base() + 'name',
this.label, {
namespaces: ns.toObj()
})
Expand All @@ -659,11 +660,11 @@ VIE.Util = {
return [
jQuery.rdf.triple(this.subject.toString(),
'a',
'<' + ns.base() + 'Place>', {
ns.base() + 'Place', {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'name>',
ns.base() + 'name',
this.label.toString(), {
namespaces: ns.toObj()
})
Expand All @@ -684,21 +685,21 @@ VIE.Util = {
return [
jQuery.rdf.triple(this.subject.toString(),
'a',
'<' + ns.base() + 'City>', {
ns.base() + 'City', {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'name>',
ns.base() + 'name',
this.label.toString(), {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'description>',
ns.base() + 'description',
this.abs.toString(), {
namespaces: ns.toObj()
}),
jQuery.rdf.triple(this.subject.toString(),
'<' + ns.base() + 'containedIn>',
ns.base() + 'containedIn',
this.country.toString(), {
namespaces: ns.toObj()
})
Expand Down Expand Up @@ -746,9 +747,9 @@ VIE.Util = {
'left' : [ '?subject a dbpedia:' + key, '?subject rdfs:label ?label' ],
'right' : function(ns) {
return function() {
return [ jQuery.rdf.triple(this.subject.toString(), 'a', '<' + ns.base() + mapping[key] + '>', {
return [ jQuery.rdf.triple(this.subject.toString(), 'a', ns.base() + mapping[key], {
namespaces : ns.toObj()
}), jQuery.rdf.triple(this.subject.toString(), '<' + ns.base() + 'name>', this.label.toString(), {
}), jQuery.rdf.triple(this.subject.toString(), ns.base() + 'name', this.label.toString(), {
namespaces : ns.toObj()
}) ];
};
Expand Down
8 changes: 4 additions & 4 deletions src/service/RdfaService.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ VIE.prototype.RdfaService.prototype = {
if (jQuery(element).attr('typeof') !== this.options.attributeExistenceComparator) {
type = jQuery(element).attr('typeof');
if (type.indexOf("://") !== -1) {
return "<" + type + ">";
return type;
} else {
return type;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ VIE.prototype.RdfaService.prototype = {
if (subject.indexOf('<') === 0) {
return subject;
}
return "<" + subject + ">";
return subject;
},

setElementSubject : function(subject, element) {
Expand Down Expand Up @@ -416,13 +416,13 @@ VIE.prototype.RdfaService.prototype = {
// RDF resource.
var resource = element.attr('resource');
if (resource) {
return ["<" + resource + ">"];
return [resource];
}

// `href` attribute also links to another RDF resource.
var href = element.attr('href');
if (href && element.attr('rel') === predicate) {
return ["<" + href + ">"];
return [href];
}

// If the predicate is a relation, we look for identified child objects
Expand Down