Post details: Javascript RDFParser from Tabulator

Nov 25, 2006 : Javascript RDFParser from Tabulator

David Sheets introduces himself and the new RDF/XML parser he added to the Tabulator all-javascript RDF browser. I've been using the RDF parser from Jim Ley in a generic JavaScript RDF Editor (to work with any OWL/schema files; no public release yet, but let me know if you're interested, especially in helping out). So recently I worked on using Tabulator's rdf parser to see if it was better. It seems to be designed a bit better (separate data store from parser from XML loading) and David's post says it is more accurate and often faster.

I had been hoping to find some additional functionality to use in my JsRdfEditor. Namely, modelling the RDF document instead of just getting all the triples. For example, knowing where a nodeID was used, and the XML arrangement of the triples. That way the JsRdfEditor could parse a file, add some triples, and output a new document that is arranged much like the one that was loaded. But no luck there; sounds like I'll have to add that capability to the parser myself, if I want to have elegant RDF/XML output.

So here's how you can use Tabulator's RDF Parser in your own projects:

// depends on:

// TestStore implementation from
// see also RDFIndexedFormula from
//  (extends RDFFormula from no indexing and smushing)
// for the real implementation used by Tabulator which uses indexing and smushing
var store = new TestStore()
var parser = new RDFParser(store);
parser.reify = parser.forceRDF = true;
// forceRDF isn't used??

var url = 'http://something.or/other';

// get the XML
var xhr = XMLHTTPFactory(); // returns a new XMLHttpRequest, or ActiveX XMLHTTP object
if (xhr.overrideMimeType) {
// the "data/" path and encoding is just how I store files locally"GET", "data/" + encodeURIComponent(encodeURIComponent(url)), false);
var nodeTree = xhr.responseXML;
if (nodeTree === null && xhr.responseText !== null) {
    // Only if the server fails to set Content-Type: text/xml AND xmlhttprequest doesn't have the overrideMimeType method
    console.debug("no responseXML, parsing responseText");
    nodeTree = (new DOMParser()).parseFromString(xhr.responseText, 'text/xml');
// must be an XML document node tree

// use FireBug extension to inspect console.debug'd objects
// Using TestStore you can access store.triples
Technorati tags:

Comments, Pingbacks:

Comment from: Chris Zeriouz [Visitor] ·
I would like to present you Zeriouz.Zeriouz is the most simple traffic generating network online. All you have to do is enter your domain into the homepage. Then you will be taken to step 2 which allows you to check your referrers and make sure they are following the rules. Once you've moderated your referrers, hit submit at the bottom of that page and follow the directions from there. Becoming a zeriouz Network Partner takes only minutes.
Permalink 09/16/08 @ 18:47
Comment from: JavaScript Tutorials [Visitor] ·
Cool! It just works man!
Permalink 08/11/09 @ 01:15
Comment from: Aliza [Visitor] ·
Permalink 03/18/10 @ 05:58
Comment from: Dan Brickley [Visitor] ·
Hi there! I've been trying to get this to work following your five-year old instructions. It's not quite doing it, ... but I have skeleton of how to add it into Firefox 'contacts in the browser' extension if you're interested, see
Permalink 06/12/10 @ 13:41

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.
What is the 2-letter abbreviation for Michigan?
Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email & url)

<  September 2017  >
Mon Tue Wed Thu Fri Sat Sun
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  




Syndicate this blog XML

powered by