JSPM

rdfxmlprocessor

0.0.2-alpha
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q59450F
  • License MIT

RDF/XML processor

Package Exports

  • rdfxmlprocessor

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rdfxmlprocessor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

RDF/XML parser

This library processes RDF/XML from an XML DOM. It returns RDFJS compliant triples.

Use

Install it through NPM:

npm i rdfxmlprocessor

Then use it in your code as follows:

const RDFXMLProcessor = require('rdfxmlprocessor');
const {DataFactory} = require('n3');
const {DOMParser} = require('xmldom'); //Or just DOMParser in the browser

//You can choose your own data factory (useful if, among others, you’re using different RDFJS compliant parsers and they each parse blanknodes).
var parser = new RDFXMLProcessor(DataFactory);
try {
    parser.parse(new DOMParser().parseFromString(`<?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"
           dc:title="RDF/XML Syntax Specification (Revised)">
    <ex:editor>
      <rdf:Description ex:fullName="Dave Beckett">
    <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
      </rdf:Description>
    </ex:editor>
  </rdf:Description>
  </rdf:RDF>`), 'http://example.org/baseuri/', 'http://example.org/graphname', function (triple) {
    if (triple)
      console.log(triple);
});
} catch (e) {
    console.trace(e);
}

You can also use it in your browserify or webpack projects.

Tests

You need to have mocha installed globally (npm i -g mocha).

Limitations

As it relies on a DOM tree, the size of the XML document to be read is limited to the size of your memory.

This library has been split off from the librdf.js project by timbl and contributors. The RDF/XML processor was originally written by David Sheets. Pieter Colpaert adapted the processor to be RDFJS compliant.

MIT license