Updated N3.js
This commit is contained in:
parent
df0755da80
commit
e701af4433
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/*! @license ©2014 Miel Vander Sande - Multimedia Lab / iMinds / Ghent University */
|
||||
/*! @license ©2014 Miel Vander Sande - IDLab / imec / Ghent University */
|
||||
/* Command-line utility to validate Turtle files. */
|
||||
|
||||
var N3 = require('n3'),
|
||||
fs = require('fs'),
|
||||
N3Util = N3.Util,
|
||||
var fs = require('fs'),
|
||||
http = require('http');
|
||||
url = require('url'),
|
||||
fs = require('fs'),
|
||||
|
@ -14,7 +12,7 @@ var N3 = require('n3'),
|
|||
var help = function () {
|
||||
// In all other cases, let's help the user and return some help
|
||||
console.log('RDF NTriples/Turtle validator using Ruben Verborgh\'s N3 nodejs library');
|
||||
console.log('© 2014 - MMLab - Ghent University - iMinds');
|
||||
console.log('© 2014 - IDLab - Ghent University - imec');
|
||||
console.log('Source code: https://github.com/MMLab/TurtleValidator');
|
||||
console.log('');
|
||||
console.log('Examples:');
|
||||
|
@ -60,10 +58,10 @@ function validateArgument(arg) {
|
|||
// Use stdio as an input stream
|
||||
function showValidation(feedback) {
|
||||
feedback.errors.forEach(function (error) {
|
||||
console.log(error);
|
||||
console.log('ERROR: ' + error);
|
||||
});
|
||||
feedback.warnings.forEach(function (warning) {
|
||||
console.log(warning);
|
||||
console.log('WARNING: ' + warning);
|
||||
});
|
||||
console.log("Validator finished with " + feedback.warnings.length + " warnings and " + feedback.errors.length + " errors.");
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
var N3 = require('n3'),
|
||||
N3Util = N3.Util;
|
||||
var N3 = require('n3');
|
||||
|
||||
var validate = function (turtleStream, callback) {
|
||||
var parser = N3.Parser();
|
||||
var parser = N3.Parser({ format: 'text/turtle' });
|
||||
var errorCount = 0, warningCount = 0;
|
||||
var regexp = {
|
||||
'dateTime' : /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])?T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)??(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$/,
|
||||
|
@ -15,17 +14,17 @@ var validate = function (turtleStream, callback) {
|
|||
|
||||
parser.parse(turtleStream, function(error, triple, prefixes) {
|
||||
if (error) {
|
||||
feedback.errors.push(error);
|
||||
feedback.errors.push(error.message);
|
||||
}
|
||||
|
||||
if (triple) {
|
||||
if (N3Util.isLiteral(triple.object)) {
|
||||
var value = N3Util.getLiteralValue(triple.object);
|
||||
var type = N3Util.getLiteralType(triple.object);
|
||||
if (triple.object.termType === 'literal') {
|
||||
var value = triple.object.value;
|
||||
var type = triple.object.datatype;
|
||||
|
||||
type = type.replace('http://www.w3.org/2001/XMLSchema#', '');
|
||||
if (regexp[type] && !regexp[type].test(value)) {
|
||||
feedback.warnings.push('WARNING: xsd:', type, 'does not validate for literal. {', triple.subject, triple.predicate, triple.object, '}');
|
||||
feedback.warnings.push('xsd:', type, 'does not validate for literal. {', triple.subject.value, triple.predicate.value, triple.object.value, '}');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "turtle-validator",
|
||||
"version": "1.0.1",
|
||||
"version": "1.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"n3": {
|
||||
"version": "0.11.2",
|
||||
"resolved": "https://registry.npmjs.org/n3/-/n3-0.11.2.tgz",
|
||||
"integrity": "sha512-ICSiOmFLbZ4gI35+4H3e2vYGHDC944WZkCa1iVNRAx/mRZESEevQNFhfHaui/lhqynoZYvBVDNjM/2Tfd3TICQ=="
|
||||
"version": "1.0.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/n3/-/n3-1.0.0-beta.1.tgz",
|
||||
"integrity": "sha512-A9SAvNIkqxNEsZBjxnEwL7pacqGR4zbE25MfXkdZiroqo/2wnsiqx1eQFDsbQXgyxcDtwATaaMf+VT2I474uWA=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
{
|
||||
"name": "turtle-validator",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"description": "This command line tool validates Turtle documents and does XSD datatype checks",
|
||||
"main": "lib/validator.js",
|
||||
"bin": {
|
||||
"ttl": "./TurtleValidator.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"n3": "0.11.3"
|
||||
"n3": "1.0.0-beta.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "browserify lib/validator.js -o public/js/ttl.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
|
Loading…
Reference in New Issue