NxParser - Parser for NTriples, NQuads, and more

Main Author: Aidan Hogan Contributions: Andreas Harth


Check out the NxParser's new home here for newer versions...

This page is left for reference.


Here you can find the Java source for a parser of file in Nx format, where x = Triples, Quads, or any other number.

Download

The NxParser subversion repository is available. Current version (V1.1) of the JAR (Version 1.0 of the JAR).

Usage

The NxParser object implements the Iterator interface and returns an array of Node (which can be either Resource, BNode, or Literal).

  NxParser nxp = new NxParser(new FileInputStream("filetoparse.nq"),false);
		
  while (nxp.hasNext()) {
    Node[] ns = nxp.next();
			
    for (Node n: ns) {
      System.out.print(n.toN3());
      System.out.print(" ");
    }
    System.out.println(".");
  }

See code snippet from Uldis Bojars here for using NxParser from Python. Thanks Uldis!

References

NQuads post from Sean Palmer, 2001.

Draft specification of the NQuads/Nx format

This project is released under the BSD license (file: license.txt).


$Id: index.html 21624 2011-10-12 16:54:01Z aidanh $