Skip to content

Commit

Permalink
Fix xmlns in datatyped property tags causing errors, Closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jan 12, 2020
1 parent 3479a47 commit 6913fa1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/RdfXmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ while ${attributeValue} and ${activeSubjectValue} where found.`);

// Interpret attributes at this point as properties via implicit blank nodes on the property,
// but we ignore attributes that have no prefix or known expanded URI
if (propertyAttributeKeyExpanded.prefix !== 'xml' && propertyAttributeKeyExpanded.uri) {
if (propertyAttributeKeyExpanded.prefix !== 'xml' && propertyAttributeKeyExpanded.prefix !== 'xmlns'
&& propertyAttributeKeyExpanded.uri) {
if (parseType || activeTag.datatype) {
throw this.newParseError(`Found illegal rdf:* properties on property element with attribute: ${
propertyAttributeValue}`);
Expand Down
17 changes: 17 additions & 0 deletions test/RdfXmlParser-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,23 @@ abc`)).rejects.toBeTruthy();
quad('_:b2', 'http://www.w3.org/2000/01/rdf-schema#label', '"XYZ"'),
]);
});

// 2.12
it('on property elements with an xmlns property and rdf:datatype', async () => {
const array = await parse(parser, `<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ex="http://example.org/stuff/1.0/">
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
<bla:editor xmlns:bla="http://x.p.t/o/TBox#" rdf:datatype="http://www.w3.org/TR/rdf-syntax-grammar">Yes</bla:editor>
</rdf:Description>
</rdf:RDF>`);
return expect(array)
.toBeRdfIsomorphic([
quad('http://www.w3.org/TR/rdf-syntax-grammar', 'http://x.p.t/o/TBox#editor',
'"Yes"^^http://www.w3.org/TR/rdf-syntax-grammar'),
]);
});
});

describe('streaming-wise', () => {
Expand Down

0 comments on commit 6913fa1

Please sign in to comment.