Populate Contents Tutorial

This is a developer tutorial, demonstrating how one may use information from the registry within other implementations.

Contents of a registry may be used as structured information. The registry provides a query endpoint where queries using the W3 SPARQL query language may be run.

For example, JavaScript may be written to target the service query endpoint and run a query that obtains all the registers and their current version

let endpoint = "/system/query";
let query = "prefix version: 
            prefix reg: 
            select * where {
            ?register a reg:Register; version:currentVersion ?regVer.} limit 10"

A javascript function can be provided to run the query on the end point and return results that may be processed and presented, used in forms, and applied to other aspects of user interaction.

let divResults = document.getElementById("results");

function sparqlQueryJson(queryStr, endpoint, callback) {
    // Build the request URI
    let requestUri = endpoint + "?query=" + escape(queryStr) + "&output=json";

    // Get our HTTP request object.
    if (window.XMLHttpRequest) {
        let xhr = new XMLHttpRequest();
        xhr.open('GET', requestUri, true);

        // Set up callback to get the response asynchronously.
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    // Do something with the results
                } else {
                    // Some kind of error occurred.
                    alert("Sparql query error: " + xhr.status + " " + xhr.responseText);

        // Send the query to the endpoint.
    } else {
        divResults.innerHTML = "Your browser does not support XMLHttpRequest";

Defining a callback function in the script to process results provides easy access to information from the register.

function myCallback(str) {
    // Convert result to JSON
    let jsonObj = eval('(' + str + ')');

    // Build up a table of results.
    let table = document.createElement("table");
    table.className = "table table-striped table-bordered datatable dataTable";

    // Create column headers
    let tableHeader = document.createElement("tr");

    for (let dataColumn of jsonObj.head.vars) {
        let th = document.createElement("th");


    // Create result rows
    for (let dataRow of jsonObj.results.bindings) {
        let tableRow = document.createElement("tr");

        // Create columns in row
        for (let column of jsonObj.head.vars) {
            let td = document.createElement("td");


    // Append the table to the results HTML container
    divResults.textContent = "";

Finally, call the sparqlQueryJson method to initiate the query.

sparqlQueryJson(query, endpoint, myCallback);

Queries may be structured to deliver the information required for a particular use case, based on knowledge of the targeted register information.

Example Results

Results from this example are presented below. 'browse source' on this page to see this working example code set out.

It may take a few moments for the info to be displayed here...