org.tinyjee.maven.dim.utils
Class PositioningDocumentBuilder

java.lang.Object
  extended by org.tinyjee.maven.dim.utils.AbstractPositioningDocumentBuilder
      extended by org.tinyjee.maven.dim.utils.PositioningDocumentBuilder

public class PositioningDocumentBuilder
extends AbstractPositioningDocumentBuilder

Creates a Document builder that adds user-data into the parsed DOM nodes that covers line number and column information. The purpose of this implementation is to get positions of selected elements in order to allow snippet selection via XPath.

This implementation is roughly based on the examples found at:

Author:
Juergen_Kellerer, 2011-10-12
See Also:
PositioningJsonDocumentBuilder

Field Summary
 
Fields inherited from class org.tinyjee.maven.dim.utils.AbstractPositioningDocumentBuilder
KEY_COLUMN_NUMBER, KEY_LINE_NUMBER
 
Constructor Summary
PositioningDocumentBuilder(boolean namespaceAware)
          Creates a new document builder that adds line and column number to the user data sections of resulting element nodes.
 
Method Summary
 SAXParserFactory getSaxParserFactory()
           
 TransformerFactory getTransformerFactory()
           
 Document parse(URL systemId)
          Parses the given XML document.
 Document parse(URL systemIdUrl, Reader reader)
          Parses the given URL to a Document.
 
Methods inherited from class org.tinyjee.maven.dim.utils.AbstractPositioningDocumentBuilder
getColumnNumber, getLineNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PositioningDocumentBuilder

public PositioningDocumentBuilder(boolean namespaceAware)
Creates a new document builder that adds line and column number to the user data sections of resulting element nodes.

Parameters:
namespaceAware - whether XML processing is namespace aware.
Method Detail

getSaxParserFactory

public SAXParserFactory getSaxParserFactory()

getTransformerFactory

public TransformerFactory getTransformerFactory()

parse

public Document parse(URL systemId)
               throws SAXException,
                      IOException,
                      TransformerException,
                      ParserConfigurationException
Parses the given XML document.

Specified by:
parse in class AbstractPositioningDocumentBuilder
Parameters:
systemId - the URL of the document to parse.
Returns:
a parsed document with line and column numbers being included for elements.
Throws:
SAXException - If SAX parses cannot be created.
IOException - If reading fails.
TransformerException - If XML transformation is unavailable.
ParserConfigurationException - If parsers are not configured correctly.

parse

public Document parse(URL systemIdUrl,
                      Reader reader)
               throws SAXException,
                      IOException,
                      TransformerException,
                      ParserConfigurationException
Description copied from class: AbstractPositioningDocumentBuilder
Parses the given URL to a Document.

Specified by:
parse in class AbstractPositioningDocumentBuilder
Parameters:
systemIdUrl - the URL of the document to parse.
reader - a reader containing the content to parse.
Returns:
the parsed document.
Throws:
SAXException
IOException
TransformerException
ParserConfigurationException