Tutorial
This tutorial will show you how to use RDF-Ext.
Example Workspace
All examples of this tutorial are available as Gitpod workspace:
Basics
Let's start with some basics.
Example Dataset
We will use the housemd example dataset in this tutorial. The following lines show how to load it:
import housemd from 'housemd'
import rdf from 'rdf-ext'
// import the housemd RDF/JS Quads and use RDF-Ext as factory
const quads = housemd({ factory: rdf })
// load the quads into a RDF/JS dataset
const dataset = rdf.dataset(quads)
// dump the content of the dataset to the console
console.log(dataset.toCanonical())
N-Triples
Converting Term, Quads, or Dataset to N-Triples string can be helpful for debugging. The example shows how to do it:
import housemd from 'housemd'
import rdf from 'rdf-ext'
// import the housemd RDF/JS Quads and use RDF-Ext as factory
const quads = housemd({ factory: rdf })
// load the quads into a RDF/JS dataset
const dataset = rdf.dataset(quads)
// dump the content of the dataset to the console
console.log(dataset.toCanonical())
Browser
A module bundler is required to build a Web application with RDF-Ext. Vite is a modern, fast, and very popular one, which we will use in this tutorial.
Dependencies
First, you need to install vite
. The following command will install it and add it as a developer dependency:
npm install --save-dev `vite`
Bundle
Now you can run the bundler in developer mode. It will start a server and bundles the code on the fly:
vite dev examples/browser
Run the following command for a production build:
vite build --outDir=../../dist examples/browser