Skip to content

Commit e701af4

Browse files
author
Miel Vander Sande
committed
Updated N3.js
1 parent df0755d commit e701af4

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

TurtleValidator.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env node
22

3-
/*! @license ©2014 Miel Vander Sande - Multimedia Lab / iMinds / Ghent University */
3+
/*! @license ©2014 Miel Vander Sande - IDLab / imec / Ghent University */
44
/* Command-line utility to validate Turtle files. */
55

6-
var N3 = require('n3'),
7-
fs = require('fs'),
8-
N3Util = N3.Util,
6+
var fs = require('fs'),
97
http = require('http');
108
url = require('url'),
119
fs = require('fs'),
@@ -14,7 +12,7 @@ var N3 = require('n3'),
1412
var help = function () {
1513
// In all other cases, let's help the user and return some help
1614
console.log('RDF NTriples/Turtle validator using Ruben Verborgh\'s N3 nodejs library');
17-
console.log('© 2014 - MMLab - Ghent University - iMinds');
15+
console.log('© 2014 - IDLab - Ghent University - imec');
1816
console.log('Source code: https://github.com/MMLab/TurtleValidator');
1917
console.log('');
2018
console.log('Examples:');
@@ -60,10 +58,10 @@ function validateArgument(arg) {
6058
// Use stdio as an input stream
6159
function showValidation(feedback) {
6260
feedback.errors.forEach(function (error) {
63-
console.log(error);
61+
console.log('ERROR: ' + error);
6462
});
6563
feedback.warnings.forEach(function (warning) {
66-
console.log(warning);
64+
console.log('WARNING: ' + warning);
6765
});
6866
console.log("Validator finished with " + feedback.warnings.length + " warnings and " + feedback.errors.length + " errors.");
6967
}

lib/validator.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
var N3 = require('n3'),
2-
N3Util = N3.Util;
1+
var N3 = require('n3');
32

43
var validate = function (turtleStream, callback) {
5-
var parser = N3.Parser();
4+
var parser = N3.Parser({ format: 'text/turtle' });
65
var errorCount = 0, warningCount = 0;
76
var regexp = {
87
'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])?$/,
@@ -12,20 +11,20 @@ var validate = function (turtleStream, callback) {
1211
};
1312

1413
var feedback = { warnings : [], errors : []};
15-
14+
1615
parser.parse(turtleStream, function(error, triple, prefixes) {
1716
if (error) {
18-
feedback.errors.push(error);
17+
feedback.errors.push(error.message);
1918
}
2019

2120
if (triple) {
22-
if (N3Util.isLiteral(triple.object)) {
23-
var value = N3Util.getLiteralValue(triple.object);
24-
var type = N3Util.getLiteralType(triple.object);
21+
if (triple.object.termType === 'literal') {
22+
var value = triple.object.value;
23+
var type = triple.object.datatype;
2524

2625
type = type.replace('http://www.w3.org/2001/XMLSchema#', '');
2726
if (regexp[type] && !regexp[type].test(value)) {
28-
feedback.warnings.push('WARNING: xsd:', type, 'does not validate for literal. {', triple.subject, triple.predicate, triple.object, '}');
27+
feedback.warnings.push('xsd:', type, 'does not validate for literal. {', triple.subject.value, triple.predicate.value, triple.object.value, '}');
2928
}
3029
}
3130
} else {

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
{
22
"name": "turtle-validator",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "This command line tool validates Turtle documents and does XSD datatype checks",
55
"main": "lib/validator.js",
66
"bin": {
77
"ttl": "./TurtleValidator.js"
88
},
99
"dependencies": {
10-
"n3": "0.11.3"
10+
"n3": "1.0.0-beta.1"
1111
},
1212
"devDependencies": {},
13+
"engines": {
14+
"node": ">=4.0"
15+
},
1316
"scripts": {
14-
"build": "browserify lib/validator.js -o public/js/ttl.js",
17+
"build": "browserify lib/validator.js -o public/js/ttl.js",
1518
"test": "echo \"Error: no test specified\" && exit 1"
1619
},
1720
"repository": {

0 commit comments

Comments
 (0)