jd.xml.xpath.model
Class ModelReader

java.lang.Object
  extended byjd.xml.xpath.model.ModelReader

public class ModelReader
extends Object

A ModelReader is used to create a XPath model from an input source.

Internally it uses a ParseHandler and a ModelBuilder to construct the document. Therefore the ModelReader is independent of the parsing technique (SAX, pull, etc.) and the concrete XPath model implementation.


Constructor Summary
ModelReader()
          Create a ModelReader with a default parser.
ModelReader(Object parser)
          Create a ModelReader.
 
Method Summary
 void collectLineNumbers(boolean mode)
          Specifies that the a line number map is created when documents are parsed.
 ParseHandler getParseHandler()
          Return the parse handler.
 XPathRootNode getTextNodeFragment(String text, NodeNamePool nodeNamePool)
          Return a text node fragment, i.e.
 XPathRootNode read(String uri)
          Read a xml document.
 XPathRootNode read(XmlSource source)
          Read a xml document.
 XPathRootNode read(XmlSource source, NodeNamePool nodeNamePool)
          Read a xml document.
 void setModelBuilder(ModelBuilder modelBuilder)
           
 void setNextDocumentId(int id)
          Set the document id for the next document.
 void setParser(Object parser)
          Set a new parser object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelReader

public ModelReader()
            throws SAXException
Create a ModelReader with a default parser.


ModelReader

public ModelReader(Object parser)
            throws SAXException
Create a ModelReader.

Parameters:
parser - a Sax1, Sax2 or a pull parser or null if a default parser should be used.
Throws:
SAXException - thrown if the parser is invalid or cannot be initialized
Method Detail

setParser

public void setParser(Object parser)
               throws SAXException
Set a new parser object.

Parameters:
parser - a Sax1, Sax2 or a pull parser.
Throws:
SAXException - thrown if the parser is invalid or cannot be initialized
SAXException - thrown if the parser cannot be initialized

getParseHandler

public ParseHandler getParseHandler()
Return the parse handler. Use the ParseHandler to specify a EntityResolver or the validation mode.


setModelBuilder

public void setModelBuilder(ModelBuilder modelBuilder)

setNextDocumentId

public void setNextDocumentId(int id)
Set the document id for the next document.


collectLineNumbers

public void collectLineNumbers(boolean mode)
Specifies that the a line number map is created when documents are parsed.

See Also:
XPathNode.getLineNumber()

read

public XPathRootNode read(String uri)
                   throws IOException,
                          SAXException
Read a xml document. The document uses a new empty name pool.

Parameters:
uri - the uri of a document
Throws:
IOException
SAXException

read

public XPathRootNode read(XmlSource source)
                   throws IOException,
                          SAXException
Read a xml document. The document uses a new empty name pool.

Parameters:
source - the document source.
Throws:
IOException
SAXException

read

public XPathRootNode read(XmlSource source,
                          NodeNamePool nodeNamePool)
                   throws IOException,
                          SAXException,
                          XPathException
Read a xml document.

Parameters:
source - the document source.
nodeNamePool - the name of the document pool, or null if a new name pool should be used
Returns:
the document root
Throws:
IOException
SAXException
XPathException

getTextNodeFragment

public XPathRootNode getTextNodeFragment(String text,
                                         NodeNamePool nodeNamePool)
Return a text node fragment, i.e. a root node with one text child.