From d7827fd1d336b8fbf5c25e25df158beb9587c6a5 Mon Sep 17 00:00:00 2001 From: pmcb55 Date: Mon, 2 Oct 2023 00:38:25 +0100 Subject: [PATCH] fix RDF and RDFS term IRIs --- CHANGELOG.md | 2 ++ src/VocabTerm.test.ts | 6 +++--- src/VocabTerm.ts | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af3bb6c..79aacc02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html ## Unreleased +- Fix RDF and RDFS term IRIs. + ## 1.1.0 2023/10/01 - Add the ability to retrieve all the RDF:type values for any vocab term. diff --git a/src/VocabTerm.test.ts b/src/VocabTerm.test.ts index f02bff95..2b0f6177 100755 --- a/src/VocabTerm.test.ts +++ b/src/VocabTerm.test.ts @@ -627,8 +627,8 @@ describe("VocabTerm tests", () => { }); it("should handle rdf:type of Class", () => { - const RDF_CLASS = rdfFactory.namedNode( - "http://www.w3.org/1999/02/22-rdf-syntax-ns#Class", + const RDFS_CLASS = rdfFactory.namedNode( + "http://www.w3.org/2000/01/rdf-schema#Class", ); const myTerm = buildBasicTerm( "http://some.vocab#myTerm", @@ -637,7 +637,7 @@ describe("VocabTerm tests", () => { ); expect(myTerm.isClass).toBe(false); - myTerm.addType(RDF_CLASS); + myTerm.addType(RDFS_CLASS); expect(myTerm.isClass).toBe(true); }); diff --git a/src/VocabTerm.ts b/src/VocabTerm.ts index bfeca9c9..6dd30a46 100755 --- a/src/VocabTerm.ts +++ b/src/VocabTerm.ts @@ -42,10 +42,10 @@ const DEFAULT_LOCALE = "en"; // We need an instance of an RDF Factory to instantiate a Named Node, but we // only want to create instances of these RDF types if we are checking for the // -let LAZY_TYPE_RDF_CLASS: NamedNode | undefined = undefined; +let LAZY_TYPE_RDFS_CLASS: NamedNode | undefined = undefined; let LAZY_TYPE_OWL_CLASS: NamedNode | undefined = undefined; -let LAZY_TYPE_RDFS_PROPERTY: NamedNode | undefined = undefined; +let LAZY_TYPE_RDF_PROPERTY: NamedNode | undefined = undefined; let LAZY_TYPE_OWL_DATATYPE_PROPERTY: NamedNode | undefined = undefined; let LAZY_TYPE_OWL_OBJECT_PROPERTY: NamedNode | undefined = undefined; let LAZY_TYPE_OWL_ANNOTATION_PROPERTY: NamedNode | undefined = undefined; @@ -266,8 +266,8 @@ class VocabTerm implements NamedNode { } createNamedNodeConstantsClass(): void { - LAZY_TYPE_RDF_CLASS = this.rdfFactory.namedNode( - "http://www.w3.org/1999/02/22-rdf-syntax-ns#Class", + LAZY_TYPE_RDFS_CLASS = this.rdfFactory.namedNode( + "http://www.w3.org/2000/01/rdf-schema#Class", ); LAZY_TYPE_OWL_CLASS = this.rdfFactory.namedNode( @@ -276,8 +276,8 @@ class VocabTerm implements NamedNode { } createNamedNodeConstantsProperty(): void { - LAZY_TYPE_RDFS_PROPERTY = this.rdfFactory.namedNode( - "http://www.w3.org/2000/01/rdf-schema#Property", + LAZY_TYPE_RDF_PROPERTY = this.rdfFactory.namedNode( + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property", ); LAZY_TYPE_OWL_DATATYPE_PROPERTY = this.rdfFactory.namedNode( "http://www.w3.org/2002/07/owl#Property", @@ -303,23 +303,23 @@ class VocabTerm implements NamedNode { } get isClass(): boolean { - if (!LAZY_TYPE_RDF_CLASS) { + if (!LAZY_TYPE_RDFS_CLASS) { this.createNamedNodeConstantsClass(); } return ( - (this._type?.has(LAZY_TYPE_RDF_CLASS!) || + (this._type?.has(LAZY_TYPE_RDFS_CLASS!) || this._type?.has(LAZY_TYPE_OWL_CLASS!)) !== undefined ); } get isProperty(): boolean { - if (!LAZY_TYPE_RDFS_PROPERTY) { + if (!LAZY_TYPE_RDF_PROPERTY) { this.createNamedNodeConstantsProperty(); } return ( - (this._type?.has(LAZY_TYPE_RDFS_PROPERTY!) || + (this._type?.has(LAZY_TYPE_RDF_PROPERTY!) || this._type?.has(LAZY_TYPE_OWL_OBJECT_PROPERTY!) || this._type?.has(LAZY_TYPE_OWL_DATATYPE_PROPERTY!) || this._type?.has(LAZY_TYPE_OWL_ANNOTATION_PROPERTY!) ||