Skip to content

Commit b828deb

Browse files
committed
Don't emit triple terms without rdf:version
1 parent a7122d6 commit b828deb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/RdfXmlParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ while ${attribute.value} and ${activeSubjectValue} where found.`);
691691
}
692692

693693
// Set the triple term value if we were collecting triple terms
694-
if (poppedTag.childrenTagsToTripleTerms && poppedTag.predicate) {
694+
if (poppedTag.childrenTagsToTripleTerms && poppedTag.predicate && poppedTag.rdfVersion) {
695695
if (poppedTag.childrenTripleTerms.length !== 1) {
696696
throw this.newParseError(`Expected exactly one triple term in rdf:parseType="Triple" but got ${poppedTag.childrenTripleTerms.length}`);
697697
}

test/RdfXmlParser-test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,24 @@ abc`)).rejects.toBeTruthy();
26172617
]);
26182618
});
26192619

2620+
// 2.19
2621+
it('on property elements with rdf:parseType="Triple" without rdf:version', async () => {
2622+
const array = await parse(parser, `<?xml version="1.0"?>
2623+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
2624+
xmlns:ex="http://example.org/stuff/1.0/"
2625+
xml:base="http://example.org/triples/">
2626+
<rdf:Description rdf:about="http://example.org/">
2627+
<ex:prop rdf:parseType="Triple">
2628+
<rdf:Description rdf:about="http://example.org/stuff/1.0/s">
2629+
<ex:p rdf:resource="http://example.org/stuff/1.0/o" />
2630+
</rdf:Description>
2631+
</ex:prop>
2632+
</rdf:Description>
2633+
</rdf:RDF>`);
2634+
return expect(array)
2635+
.toBeRdfIsomorphic([]);
2636+
});
2637+
26202638
it('on property elements with rdf:parseType="Triple" with blank subject', async () => {
26212639
const array = await parse(parser, `<?xml version="1.0"?>
26222640
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

0 commit comments

Comments
 (0)