How do I fix the rdflib parse problem with a valid RDF file

I have tried all kinds of things and seem to get errors about the names spaces used within the RDF file. From what I have read, namespaces such as owl and xsd should already be defined. The code is written as a unit test and works in VSCode. I am having trouble loading the actual RDF file because the automated process keeps complaing about the content.

import FileSystem              from 'fs';
import rdflib                  from 'rdflib';
function unitTest ( filename )
{ console.log ( 'Starting TableOfRdfRecords.loadRdfFile -> ' + filename );
  var store        = rdflib.graph();
  var contentType  = 'application/rdf+xml';
  var baseUrl      = '';
  var statement;
  var fileContents
    = FileSystem.readFileSync
      ( filename,
  // console.log ( '-- fileContents BEGIN ->\n' + fileContents.split(/\r?\n/) + '\n<-- END' );
  { console.log ( '-- store: "' + store
                  + '",  -- baseUrl: "' + baseUrl
                  + '", -- contentType: "' + contentType
                  + '"'
    rdflib.parse ( fileContents, store, baseUrl, contentType );
    var statements = store.statementsMatching ( undefined, undefined , undefined );
    for ( var statementCounter=0; statementCounter<statements.length; statementCounter++ )
    { statement = statements [ statementCounter ];
      console.log ( statementCounter + '] ' + statement ); // the WebID of a friend
    } // End for
  }  // End try block
  catch ( errorMessage )
  { console.log ( '-- errorMessage ->\n' + errorMessage );
    console.log ( '-- statement    ->\n' + statement );
  } // End catch
  console.log ( 'Finishing TableOfRdfRecords.loadRdfFile' );
} // End function unitTest

unitTest ( './Data/Commons/Designators.rdf' );

Here is the Designators.rdf

<?xml version="1.0" encoding="UTF-8"?>
	<!ENTITY cmns-av "">
	<!ENTITY cmns-dsg "">
	<!ENTITY cmns-txt "">
	<!ENTITY dct "">
	<!ENTITY owl "">
	<!ENTITY rdf "">
	<!ENTITY rdfs "">
	<!ENTITY skos "">
	<!ENTITY xsd "">
<rdf:RDF xml:base=""
	<owl:Ontology rdf:about="">
		<rdfs:label>Commons Designators Ontology</rdfs:label>
		<dct:abstract>The designators ontology defines commonly used concepts for naming, derived in part from the     patterns defined in ISO 1087 for terminology work and ISO 11179-3, Metadata Registries.  It includes several     very high level semiotic relationships, including defines, describes, and denotes for associating designators     with the concepts they reference.</dct:abstract>
		<dct:contributor>Davide Sottara, Mayo Clinic</dct:contributor>
		<dct:contributor>Dean Allemang, Working Ontologist</dct:contributor>
		<dct:contributor>Elisa Kendall, Thematix Partners LLC</dct:contributor>
		<dct:contributor>Pete Rivett, U.K. Ltd</dct:contributor>
		<dct:license rdf:datatype="&xsd;anyURI"></dct:license>
		<owl:imports rdf:resource=""/>
		<owl:imports rdf:resource=""/>
		<owl:versionIRI rdf:resource=""/>
		<skos:note>The designators ontology conforms with the OWL 2 DL semantics, and is outside of OWL 2 RL due to     the inclusion of one minimum cardinality constraint (which is tyically ignored, but is important - see note on     the Designator class) and two value restrictions. These constraints can be removed if required to support OWL     RL rule-based applications that cannot be extended to support them.</skos:note>
		<cmns-av:copyright>Copyright (c) 2014-2022 Thematix Partners LLC</cmns-av:copyright>
		<cmns-av:copyright>Copyright (c) 2021-2022 Mayo Clinic</cmns-av:copyright>
		<cmns-av:copyright>Copyright (c) 2021-2022 Working Ontologist LLC</cmns-av:copyright>
		<cmns-av:copyright>Copyright (c) 2021-2022 U.K. Ltd</cmns-av:copyright>
		<cmns-av:copyright>Copyright (c) 2022 Object Management Group, Inc.</cmns-av:copyright>
	<owl:Class rdf:about="&cmns-dsg;Designation">
				<owl:onProperty rdf:resource="&cmns-txt;hasTextValue"/>
				<owl:minQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">0</owl:minQualifiedCardinality>
				<owl:onDataRange rdf:resource="&cmns-txt;Text"/>
				<owl:onProperty rdf:resource="&cmns-dsg;denotes"/>
				<owl:someValuesFrom rdf:resource="&owl;Thing"/>
		<dct:source>ISO 1087 Terminology work and terminology science - Vocabulary, Second edition, 2019-09, clause 3.    4.1</dct:source>
		<skos:definition>representation for someone or something by a sign that denotes it</skos:definition>
		<skos:note>A designation can be a term including appellations, a proper name, or a symbol.</skos:note>
		<skos:note>A designation can be linguistic or non-linguistic. It can consist of various types of characters,     but also punctuation marks such as hyphens and parentheses, governed by domain-, subject-, or     language-specific conventions.</skos:note>
		<skos:note>Note that the use of the min 0 cardinality restriction in the definition of this class is provided     as a reminder that designators are expected, in many cases, to have a text value associated with them. There     are cases where this is not true, however, including symbols.  And, there may be cases where the value is not     known. Additionally, not all tools support rdf:langString, thus its use in the definition of the Text datatype     may cause errors, for example in value and some number restrictions. Min 0 cardinality constraints are ignored     by reasoners and other processors, so this allows us to say that the possible values for this property are     likely either xsd:string or rdf:langString, but does not require it depending on the environment in which the     ontology is deployed.</skos:note>
	<owl:Class rdf:about="&cmns-dsg;Name">
		<rdfs:subClassOf rdf:resource="&cmns-dsg;Designation"/>
				<owl:onProperty rdf:resource="&cmns-dsg;isNameOf"/>
				<owl:someValuesFrom rdf:resource="&owl;Thing"/>
		<dct:source>ISO/IEC 11179-3 Information technology - Metadata registries (MDR) - Registry metamodel and basic     attributes, Third edition, 2013-02-15</dct:source>
		<skos:definition>distinctive designation for an individual (person, organization or thing)</skos:definition>
	<owl:ObjectProperty rdf:about="&cmns-dsg;defines">
		<rdfs:seeAlso rdf:resource=""/>
		<owl:inverseOf rdf:resource="&cmns-dsg;isDefinedIn"/>
		<skos:definition>specifies the meaning of something in terms of one or more of its essential qualities</    skos:definition>
		<skos:note>A quality is an elementary characteristic of something. An &apos;essential quality&apos; is one     that provides a necessary criteria for being that thing and differentiating criteria for not being something     else.</skos:note>
	<owl:ObjectProperty rdf:about="&cmns-dsg;denotes">
		<rdfs:domain rdf:resource="&cmns-dsg;Designation"/>
		<rdfs:seeAlso rdf:resource=""/>
		<rdfs:seeAlso rdf:resource=""/>
		<skos:definition>serves as a sign for something</skos:definition>
		<skos:note>Note that in some references, such as the semiotics ontology from Ontology Design Patterns,&apos;    denotes&apos; can be used to talk about e.g. entities denoted by proper nouns: the proper noun &apos;Leonardo     da Vinci&apos; denotes the person Leonardo da Vinci; as well as to talk about sets of entities that can be     described by a common noun: the common noun &apos;person&apos; denotes the collection of all persons in a     domain of discourse. Other references that may be useful for interpreting &apos;denotes&apos; include OntoLex.     The interpretation of &apos;denotes&apos; in this context is more general, but intended to reflect its usage     in the semiotic triangle.</skos:note>
	<owl:ObjectProperty rdf:about="&cmns-dsg;describes">
		<owl:inverseOf rdf:resource="&cmns-dsg;isDescribedBy"/>
		<skos:definition>conveys the nature of</skos:definition>
	<owl:DatatypeProperty rdf:about="&cmns-dsg;hasDescription">
		<rdfs:subPropertyOf rdf:resource="&cmns-txt;hasTextValue"/>
		<rdfs:label>has description</rdfs:label>
		<skos:definition>provides a textual statement, picture in words, or account that describes something</    skos:definition>
		<skos:note>Note that the hasDescription property defined herein has an implicit range of rdfs:Literal. This is     purposeful, so that users can specify any element that has a name with or without a language tag without     concern for conflicting datatypes (i.e., xsd:string vs. rdf:langString, which are logically disjoint).</    skos:note>
	<owl:ObjectProperty rdf:about="&cmns-dsg;hasName">
		<rdfs:subPropertyOf rdf:resource="&cmns-dsg;isSignifiedBy"/>
		<rdfs:label>has name</rdfs:label>
		<rdfs:range rdf:resource="&cmns-dsg;Name"/>
		<owl:inverseOf rdf:resource="&cmns-dsg;isNameOf"/>
		<skos:definition>is known by</skos:definition>
	<owl:ObjectProperty rdf:about="&cmns-dsg;isDefinedIn">
		<rdfs:label>is defined in</rdfs:label>
		<skos:definition>indicates something that specifies the meaning associated with the subject</skos:definition>
		<skos:note>Typically, a concept, such as a classifier or identifier, will be defined in terms of a scheme,     contract, specification, standard, or other reference.</skos:note>
	<owl:ObjectProperty rdf:about="&cmns-dsg;isDescribedBy">
		<rdfs:label>is described by</rdfs:label>
		<skos:definition>has general nature or description of</skos:definition>
	<owl:ObjectProperty rdf:about="&cmns-dsg;isNameOf">
		<rdfs:subPropertyOf rdf:resource="&cmns-dsg;denotes"/>
		<rdfs:label>is name of</rdfs:label>
		<rdfs:domain rdf:resource="&cmns-dsg;Name"/>
		<skos:definition>denotes in some context</skos:definition>
	<owl:ObjectProperty rdf:about="&cmns-dsg;isSignifiedBy">
		<rdfs:label>is signified by</rdfs:label>
		<rdfs:range rdf:resource="&cmns-dsg;Designation"/>
		<owl:inverseOf rdf:resource="&cmns-dsg;denotes"/>
		<skos:definition>has representation, denotation or sign of</skos:definition>


here are the results of the unitTest

 [Running] node "/Users/robertstavros/Documents/TemplateFoundryJS/Code/aaa_test.js"
 Starting TableOfRdfRecords.loadRdfFile -> ./Data/Commons/Designators.rdf
 -- store: "{}",  -- baseUrl: "", -- contentType: "application/rdf+xml"
 [xmldom error]	entity not found:&xsd; 
 [xmldom error]	entity not found:&xsd; 
 [xmldom error]	entity not found:&owl; 
 [xmldom error]	entity not found:&owl; 
 -- errorMessage ->
 Error: Error: NamedNode IRI "&xsd;anyURI" must be absolute. while trying to parse <> as      application/rdf+xml
 -- statement    ->
 Finishing TableOfRdfRecords.loadRdfFile
 [Done] exited with code=0 in 0.726 seconds

I might be wrong, but it might be because: XML Schema is only available in xml, html, or dtd, not an rdf content type like text/turtle or n3, etc

I’m sure Jesse will pop in with the answer, he always knows stuff like this

My first port of call would be to try parsing it using GitHub - rubensworks/rdf-parse.js: Parses RDF from any serialization (which is using GitHub - rdfjs/rdfxml-streaming-parser.js: Streaming RDF/XML parser under the hood in the case of parsing rdfxml) - that can help rule out any issues with one of the parsers not being spec compliant.

That said, I would avoid using rdfxml in the context of Solid since it is not well supported (for instance there aren’t any spec compliant rdfxml serialisers that I know of in JavaScript). Similarly I can’t verify your Designators.rdf is spec compliant with rdfxml without having to refer back to the spec.

1 Like