A fairly modular, cross-platform, extensible package to extract RDF information from RDFa-enabled documents.
Features:
Goals:
const rdfa = require('rdfa');
const fs = require('fs');
const DOMParser = require('xmldom').DOMParser;
const filepath = './test/rdfa.github.io/test-suite/test-cases/rdfa1.1-lite/xhtml1/0021.xhtml';
const document = new DOMParser().parseFromString(fs.readFileSync(filepath, 'UTF-8'), 'text/xml');
const result = rdfa.parseDOM(rdfa.RDFaXMLParser, 'http://example.com/', document);
result.outputGraph.forEach(function(n){ console.log(n.toTurtle()); });
<http://example.com/> <http://purl.org/dc/elements/1.1/creator> "Mark Birbeck" .
There is no included document parser, instead supports reading from a DOM (W3C or compatible), or a SAX-like event stream.
Tests are written for the following packages:
Supports plain XML, HTML, and SVG out-of-the-box, and is extendible for new host languages.
Supported host languages:
application/xhtml+xml
text/html
Extracts RDF statements out of a DOM document document
, assuming a URI base base
(always ignoring the URI in the DOM node, if any).
Returns an RDFaParser instance (see below).
Content-Language
header, if any)Maintains state during processing of a document. Pass a subclass of this to parseDOM
as the first argument Processor
.
RDFaParser with the default RDF context loaded.
RDFaParser extended with the parsing rules for application/xhtml+xml
documents.
RDFaParser extended with the parsing rules for text/html
documents.
Represents an RDFa processing context that's generated during processing of an element and passed to child elements.