de.fuberlin.wiwiss.ng4j.trix
Class TriXParserWithExtensions

java.lang.Object
  extended by de.fuberlin.wiwiss.ng4j.trix.TriXParserWithExtensions

public class TriXParserWithExtensions
extends Object

A parser for TriX files (see TriX specification). Parsed graphs and triples are passed to a ParserCallback for further processing.

The parser supports TriX syntactic extensions, which are XSLT stylesheets referenced using a processing instructions. The implementation loads the input document as a DOM tree, finds the processing instructions, applies the stylesheets if any are found, re-serializes the tree as XML, then parses again using a SAX parser. The reason for this waste of resources is that I didn't find a way to validate a DOM tree against an XML schema.

TODO: Implement syntactic extensions in a less braindead way
TODO: Have only one parse() method, with InputSource argument

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
TriXParserWithExtensions()
           
 
Method Summary
 void parse(InputStream source, URI baseURI, ParserCallback callback)
          Parses a TriX file from an InputStream.
 void parse(Reader source, URI baseURI, ParserCallback callback)
          Parses a TriX file from a Reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriXParserWithExtensions

public TriXParserWithExtensions()
Method Detail

parse

public void parse(InputStream source,
                  URI baseURI,
                  ParserCallback callback)
           throws IOException,
                  SAXException,
                  TransformerException
Parses a TriX file from an InputStream. Parsed graphs and triples are passed to the callback.

Parameters:
source - a stream containing a TriX file
baseURI - the URI of the input file (for resolving relative URIs)
callback - receives parsed graphs and triples
Throws:
SAXException - on XML parse error
IOException - on I/O error when reading from source
TransformerException - on error when applying an XSLT syntactic extension

parse

public void parse(Reader source,
                  URI baseURI,
                  ParserCallback callback)
           throws IOException,
                  SAXException,
                  TransformerException
Parses a TriX file from a Reader. Parsed graphs and triples are passed to the callback.

Parameters:
source - a stream containing a TriX file
baseURI - the URI of the input file (for resolving relative URIs)
callback - receives parsed graphs and triples
Throws:
SAXException - on XML parse error
IOException - on I/O error when reading from source
TransformerException - on error when applying an XSLT syntactic extension