JSPM

rdflib

2.3.2-2bc27df4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3813
  • Score
    100M100P100Q128189F
  • License MIT

an RDF library for node.js. Suitable for client and server side.

Package Exports

  • rdflib
  • rdflib/esm/index.js
  • rdflib/lib
  • rdflib/lib/index.js
  • rdflib/lib/serializer
  • rdflib/lib/serializer.js
  • rdflib/lib/tf-types
  • rdflib/lib/tf-types.js
  • rdflib/lib/types
  • rdflib/lib/types.js
  • rdflib/lib/utils/default-graph-uri
  • rdflib/lib/utils/default-graph-uri.js

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 (rdflib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rdflib.js

NPM Version Join the chat at https://gitter.im/linkeddata/rdflib.js

Javascript RDF library for browsers and Node.js.

  • Reads and writes RDF/XML, Turtle and N3; Reads RDFa and JSON-LD
  • Read/Write Linked Data client, using WebDav or SPARQL/Update
  • Real-Time Collaborative editing with web sockets and PATCHes
  • Local API for querying a store
  • Compatible with RDFJS task force spec
  • SPARQL queries (not full SPARQL - just graph match and optional)
  • Smushing of nodes from owl:sameAs, and owl:{f,inverseF}unctionProperty
  • Tracks provenance of triples keeps metadata (in RDF) from HTTP accesses

Documentation

See:

for more information.

Install

Browser (using a bundler like Webpack)

npm install rdflib

Browser (generating a <script> file to include)

git clone git@github.com:linkeddata/rdflib.js.git;
cd rdflib.js;
npm install;

Generate the dist directory

npm run build:browser

Node.js

Make sure you have Node.js and Node Package Manager (npm) installed.

npm install --save rdflib

Serializer flags

The Turtle/N3/JSON‑LD serializers accept an optional flags string to tweak output formatting and abbreviation behavior.

  • Pass flags via the options argument to serialize(...):
import { graph, serialize, sym } from 'rdflib'

const kb = graph()
const doc = sym('http://example.com/doc')
// ... add some statements ...

// Example: prevent dotted local parts in prefixed names
const turtle = serialize(doc, kb, doc.value, 'text/turtle', undefined, { flags: 'o' })

Common flags used internally (you can combine them, e.g. 'o k'):

  • s i – used by default for Turtle to suppress =, => notations
  • d e i n p r s t u x – used for N-Triples/N-Quads to simplify output
  • dr – used with JSON‑LD conversion (no default, no relative prefix)
  • o – new: do not abbreviate to a prefixed name when the local part contains a dot. This keeps IRIs like http://example.org/ns/subject.example in <...> form instead of ns:subject.example.

Notes:

  • For Turtle and JSON‑LD, user‑provided flags are merged with the defaults so your flags (like o) are honored.
  • By contrast, passing 'p' disables prefix abbreviations entirely (all terms are written as <...> IRIs).

Contribute

Subdirectories

  • dist: Where the bundled libraries are built. Run npm run build to generate them.
  • test: Tests are here.
  • lib: Transpiled, non-bundled library is built here when the library is published to npm.

Dependencies

- XMLHTTPRequest (Node.js version)

Thanks

Thanks to the many contributors who have been involved along the way. LinkedData team & TimBL

LICENSE

MIT