net.sf.joost.stx
Class Parser

java.lang.Object
  extended by net.sf.joost.stx.Parser
All Implemented Interfaces:
Constants, ContentHandler

public class Parser
extends Object
implements Constants, ContentHandler

Creates the tree representation of an STX transformation sheet. The Parser object acts as a SAX ContentHandler.

Version:
$Revision: 2.23 $ $Date: 2007/11/25 19:33:34 $
Author:
Oliver Becker

Field Summary
private  StringBuffer collectedCharacters
          Buffer for collecting consecutive character data
 Vector compilableNodes
          List of nodes that need another call to NodeBase.compile(int, net.sf.joost.stx.ParseContext)
private  NodeBase currentNode
          The current (last created) Node.
 GroupBase includingGroup
          Group which had an stx:include, which in turn created this Parser object
private  Hashtable inScopeNamespaces
          Hashtable: keys = prefixes, values = URI stacks
private  Hashtable joostFactories
          Hashtable for Joost extension factory objects, one for each type.
private  LitElementFactory litFac
          The factory for literal result elements.
private  Hashtable newNamespaces
          Hashtable for newly declared namespaces between literal elements; keys = prefixes, values = URIs
private  Stack openedElements
          Stack for opened elements, contains Node instances.
private  ParserListener parserListener
          An optional ParserListener
private  ParseContext pContext
          The context object for parsing
private  Hashtable stxFactories
          Hashtable for STX factory objects, one for each type.
 
Fields inherited from interface net.sf.joost.Constants
DEBUG, DEFAULT_ENCODING, FEAT_NS, FEAT_NSPREFIX, FEATURE_URI_PREFIX, FUNC_NS, JOOST_EXT_NS, PR_ATTRIBUTES, PR_BUFFER, PR_CHILDREN, PR_CONTINUE, PR_ERROR, PR_SELF, PR_SIBLINGS, STX_NS
 
Constructor Summary
Parser(ParseContext pContext)
          Constructs a new Parser instance.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
private  Hashtable createFactoryMap(FactoryBase[] data)
          creates hashtable and sets its initial content to the given array
 void endDocument()
           
 void endElement(String uri, String lName, String qName)
           
 void endPrefixMapping(String prefix)
           
 Map getFactories()
           
 Hashtable getInScopeNamespaces()
          Constructs a hashtable containing a mapping from all namespace prefixes in scope to their URIs.
 TransformFactory.Instance getTransformNode()
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
private  void processCharacters()
          Processes collected character fragments
 void processingInstruction(String target, String data)
           
 void setDocumentLocator(Locator locator)
           
 void skippedEntity(String name)
           
 void startDocument()
           
 void startElement(String uri, String lName, String qName, Attributes attrs)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pContext

private ParseContext pContext
The context object for parsing


openedElements

private Stack openedElements
Stack for opened elements, contains Node instances.


currentNode

private NodeBase currentNode
The current (last created) Node.


stxFactories

private Hashtable stxFactories
Hashtable for STX factory objects, one for each type.


joostFactories

private Hashtable joostFactories
Hashtable for Joost extension factory objects, one for each type.


litFac

private LitElementFactory litFac
The factory for literal result elements.


inScopeNamespaces

private Hashtable inScopeNamespaces
Hashtable: keys = prefixes, values = URI stacks


newNamespaces

private Hashtable newNamespaces
Hashtable for newly declared namespaces between literal elements; keys = prefixes, values = URIs


compilableNodes

public Vector compilableNodes
List of nodes that need another call to NodeBase.compile(int, net.sf.joost.stx.ParseContext)


includingGroup

public GroupBase includingGroup
Group which had an stx:include, which in turn created this Parser object


parserListener

private ParserListener parserListener
An optional ParserListener


collectedCharacters

private StringBuffer collectedCharacters
Buffer for collecting consecutive character data

Constructor Detail

Parser

public Parser(ParseContext pContext)
Constructs a new Parser instance.

Method Detail

createFactoryMap

private Hashtable createFactoryMap(FactoryBase[] data)
creates hashtable and sets its initial content to the given array

Parameters:
data - to be filled in the map
Returns:
the created hashtable

getFactories

public Map getFactories()
Returns:
the STX node factories, indexed by local name

getTransformNode

public TransformFactory.Instance getTransformNode()
Returns:
the root node representing stx:transform.

processCharacters

private void processCharacters()
                        throws SAXParseException
Processes collected character fragments

Throws:
SAXParseException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String lName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String lName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface ContentHandler

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
Specified by:
ignorableWhitespace in interface ContentHandler

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
Specified by:
startPrefixMapping in interface ContentHandler

endPrefixMapping

public void endPrefixMapping(String prefix)
Specified by:
endPrefixMapping in interface ContentHandler

skippedEntity

public void skippedEntity(String name)
Specified by:
skippedEntity in interface ContentHandler

getInScopeNamespaces

public Hashtable getInScopeNamespaces()
Constructs a hashtable containing a mapping from all namespace prefixes in scope to their URIs.