com.saxonica.ptree
Class PTreeReader

java.lang.Object
  extended by com.saxonica.ptree.PTreeReader

public class PTreeReader
extends Object

This class loads a TinyTree held as a serialized binary file on disk, in a proprietary format designed for speed of loading back into a new TinyTree.

The format stored on disk is not dependent on the NamePool. Although it still uses name codes, it also contains a mapping of namecodes to the actual QNames.

The base URIs of nodes are not retained. Line numbers (if they were present in the original tree) are not retained.


Nested Class Summary
static class PTreeReader.PTreeException
           
 
Constructor Summary
PTreeReader()
           
 
Method Summary
static void main(String[] args)
          Command line interface to read a PTree document and convert it to lexical XML
 DocumentInfo readTree(DataInputStream in, String systemId, Configuration config)
          Read an input stream containing an XML document in PTree format, returning an in-memory representation of the document
 void readTree(DataInputStream in, String systemId, Configuration config, Receiver out)
          Read an input stream containing an XML document in PTree format, passing the events associated with the document to a Saxon Receiver
 void setTextMangler(TextMangler mangler)
          Set a callback object that will be used to unmangle the content of attribute nodes and text nodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PTreeReader

public PTreeReader()
Method Detail

setTextMangler

public void setTextMangler(TextMangler mangler)
Set a callback object that will be used to unmangle the content of attribute nodes and text nodes

Parameters:
mangler - the object to perform the content mangling

readTree

public DocumentInfo readTree(DataInputStream in,
                             String systemId,
                             Configuration config)
                      throws IOException,
                             XPathException
Read an input stream containing an XML document in PTree format, returning an in-memory representation of the document

Parameters:
in - the input stream holding the PTree document. The method will consume the stream; the caller is responsible for closing the stream after use.
systemId - the base URI to be used for the document associated with this input stream
config - the Saxon Configuration
Returns:
the root node of the constructed in-memory document
Throws:
IOException - if an error occurs reading the input stream
XPathException - if an error occurs building the in-memory document

readTree

public void readTree(DataInputStream in,
                     String systemId,
                     Configuration config,
                     Receiver out)
              throws IOException,
                     XPathException
Read an input stream containing an XML document in PTree format, passing the events associated with the document to a Saxon Receiver

Parameters:
in - the input stream holding the PTree document. The method will consume the stream; the caller is responsible for closing the stream after use.
systemId - the base URI to be used for the document associated with this input stream
config - the Saxon Configuration
out - the Receiver to receive the document events
Throws:
IOException - if an error occurs reading the input stream
XPathException - if an error occurs building the in-memory document

main

public static void main(String[] args)
                 throws Exception
Command line interface to read a PTree document and convert it to lexical XML

Parameters:
args - [-t] source.ptree out.xml
Throws:
PTreeReader.PTreeException
Exception


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.