From 4fdb6d37e44e29ef2f5739d9bcde525a26c2ffbb Mon Sep 17 00:00:00 2001 From: Matthias Palmer Date: Thu, 6 Apr 2023 12:52:02 +0200 Subject: [PATCH 1/3] Add support for namespace declaration using xmlns. --- test/RdfXmlParser-test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/RdfXmlParser-test.ts b/test/RdfXmlParser-test.ts index 995f8e5..f65c5da 100644 --- a/test/RdfXmlParser-test.ts +++ b/test/RdfXmlParser-test.ts @@ -957,7 +957,6 @@ abc`)).rejects.toBeTruthy(); ]); }); - it('DOCTYPE and ENTITY\'s', async () => { return expect(await parse(parser, ` From 01d9811647b42447375632765a77ec4286d0f494 Mon Sep 17 00:00:00 2001 From: matthias Date: Wed, 22 Nov 2023 23:11:24 +0100 Subject: [PATCH 2/3] Handle namespace declarations on resource nodes --- lib/RdfXmlParser.ts | 4 +++- test/RdfXmlParser-test.ts | 46 +++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/lib/RdfXmlParser.ts b/lib/RdfXmlParser.ts index c480a47..4430c4f 100644 --- a/lib/RdfXmlParser.ts +++ b/lib/RdfXmlParser.ts @@ -306,7 +306,9 @@ while ${attribute.value} and ${activeSubjectValue} where found.`); // Interpret attributes at this point as properties on this node, // but we ignore attributes that have no prefix or known expanded URI - if (attribute.prefix !== 'xml' && attribute.uri) { + if (attribute.prefix !== 'xml' && attribute.prefix !== 'xmlns' + && (attribute.prefix !== '' || attribute.local !== 'xmlns') + && attribute.uri) { predicates.push(this.uriToNamedNode(attribute.uri + attribute.local)); objects.push(attribute.value); } diff --git a/test/RdfXmlParser-test.ts b/test/RdfXmlParser-test.ts index f65c5da..80a62a1 100644 --- a/test/RdfXmlParser-test.ts +++ b/test/RdfXmlParser-test.ts @@ -930,16 +930,54 @@ abc`)).rejects.toBeTruthy(); ]); }); - - it('declaration of the namespace on the element', async () => { + it('declaration of the default namespace on the property element', async () => { return expect(await parse(parser, ` - + RDF1.1 XML Syntax `)) .toBeRdfIsomorphic([ - quad('http://www.w3.org/TR/rdf-syntax-grammar', + quad('http://example.com', + 'http://purl.org/dc/terms/title', '"RDF1.1 XML Syntax"@en'), + ]); + }); + + it('declaration of the namespace on the property element', async () => { + return expect(await parse(parser, ` + + + RDF1.1 XML Syntax + +`)) + .toBeRdfIsomorphic([ + quad('http://example.com', + 'http://purl.org/dc/terms/title', '"RDF1.1 XML Syntax"@en'), + ]); + }); + + it('declaration of the namespace on the resource element', async () => { + return expect(await parse(parser, ` + + + RDF1.1 XML Syntax + +`)) + .toBeRdfIsomorphic([ + quad('http://example.com', + 'http://purl.org/dc/terms/title', '"RDF1.1 XML Syntax"@en'), + ]); + }); + + it('declaration of the default namespace on the resource element', async () => { + return expect(await parse(parser, ` + + + RDF1.1 XML Syntax + +`)) + .toBeRdfIsomorphic([ + quad('http://example.com', 'http://purl.org/dc/terms/title', '"RDF1.1 XML Syntax"@en'), ]); }); From 3c3255e2b9b0b66014bba66272e714beb3aba6eb Mon Sep 17 00:00:00 2001 From: matthias Date: Wed, 22 Nov 2023 23:20:57 +0100 Subject: [PATCH 3/3] Support namespace declaration on typed elements --- test/RdfXmlParser-test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/RdfXmlParser-test.ts b/test/RdfXmlParser-test.ts index 80a62a1..1b753e6 100644 --- a/test/RdfXmlParser-test.ts +++ b/test/RdfXmlParser-test.ts @@ -982,6 +982,19 @@ abc`)).rejects.toBeTruthy(); ]); }); + + it('declaration of the namespace on a typed resource element', async () => { + return expect(await parse(parser, ` + + + +`)) + .toBeRdfIsomorphic([ + quad('http://example.com', + 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://purl.org/dc/terms/Standard'), + ]); + }); + it('cdata support', async () => { return expect(await parse(parser, `