Skip to content

Commit

Permalink
Support for CDATA in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaspalmer committed Nov 6, 2023
1 parent a55f6ae commit efc8f9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/RdfXmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class RdfXmlParser extends Transform implements RDF.Sink<EventEmitter, RD
this.saxParser.on('error', (error) => this.emit('error', error));
this.saxParser.on('opentag', this.onTag.bind(this));
this.saxParser.on('text', this.onText.bind(this));
this.saxParser.on('cdata', this.onText.bind(this));
this.saxParser.on('closetag', this.onCloseTag.bind(this));
this.saxParser.on('doctype', this.onDoctype.bind(this));
}
Expand Down
12 changes: 12 additions & 0 deletions test/RdfXmlParser-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,18 @@ abc`)).rejects.toBeTruthy();
]);
});

it('cdata support', async () => {
return expect(await parse(parser, `<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dct="http://purl.org/dc/terms/" >
<rdf:Description rdf:about="http://example.com">
<dct:title><![CDATA[A title with a <tag>]]></dct:title>
</rdf:Description>
</rdf:RDF>`))
.toBeRdfIsomorphic([
quad('http://example.com',
'http://purl.org/dc/terms/title', '"A title with a <tag>"'),
]);
});


it('DOCTYPE and ENTITY\'s', async () => {
Expand Down

0 comments on commit efc8f9a

Please sign in to comment.