shaclc-parse
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -5,4 +5,5 @@ import { Quad } from '@rdfjs/types'; | ||
extendedSyntax?: boolean; | ||
baseIRI?: string; | ||
} | ||
export declare function parse(str: string, options?: ParseOptions): Quad[] & { prefixes: Record<string, string> }; |
const ShaclcParser = require('./ShaclcParser').Parser; | ||
const N3 = require('n3'); | ||
// const arr = []; | ||
// this._parser.Parser = { | ||
// factory: N3.DataFactory, | ||
// base: N3.DataFactory.namedNode('urn:x-base:default'), | ||
// prefixes: { | ||
// rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||
// rdfs: 'http://www.w3.org/2000/01/rdf-schema#', | ||
// sh: 'http://www.w3.org/ns/shacl#', | ||
// xsd: 'http://www.w3.org/2001/XMLSchema#' | ||
// }, | ||
// onQuad: (quad) => { arr.push(quad) }, | ||
// extended: extendedSyntax === true | ||
// } | ||
class Parser { | ||
@@ -23,7 +8,7 @@ constructor() { | ||
parse(str, { extendedSyntax } = {}) { | ||
parse(str, { extendedSyntax, baseIRI } = {}) { | ||
this._parser = new ShaclcParser(); | ||
this._parser.Parser.factory = N3.DataFactory; | ||
this._parser.Parser.base = N3.DataFactory.namedNode('urn:x-base:default'); | ||
this._parser.Parser.base = N3.DataFactory.namedNode(baseIRI || 'urn:x-base:default'); | ||
this._parser.Parser.extended = extendedSyntax === true; | ||
@@ -40,3 +25,3 @@ this._parser.Parser.prefixes = { | ||
this._parser.Parser.tempCurrentNodeShape = undefined; | ||
this._parser.Parser.n3Parser = new N3.Parser({ baseIRI: 'urn:x-base:default' }); | ||
this._parser.Parser.n3Parser = new N3.Parser({ baseIRI: baseIRI || 'urn:x-base:default' }); | ||
@@ -43,0 +28,0 @@ const arr = [] |
{ | ||
"name": "shaclc-parse", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "A parser for files written with SHACL compact syntax", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
57832
1099