Class Parser

java.lang.Object
org.apache.xalan.xsltc.compiler.Parser
All Implemented Interfaces:
org.apache.bcel.generic.InstructionConstants, Constants, ContentHandler

public class Parser extends Object implements Constants, ContentHandler
Author:
Jacek Ambroziak, Santiago Pericas-Geertsen, G. Todd Miller, Morten Jorgensen, Erwin Bolwidt invalid input: '<'ejb@klomp.org>
  • Constructor Details

    • Parser

      public Parser(XSLTC xsltc)
  • Method Details

    • init

      public void init()
    • setOutput

      public void setOutput(org.apache.xalan.xsltc.compiler.Output output)
    • getOutput

      public org.apache.xalan.xsltc.compiler.Output getOutput()
    • getOutputProperties

      public Properties getOutputProperties()
    • addVariable

      public void addVariable(org.apache.xalan.xsltc.compiler.Variable var)
    • addParameter

      public void addParameter(org.apache.xalan.xsltc.compiler.Param param)
    • removeVariable

      public void removeVariable(org.apache.xalan.xsltc.compiler.QName name)
    • lookupVariable

      public org.apache.xalan.xsltc.compiler.VariableBase lookupVariable(org.apache.xalan.xsltc.compiler.QName name)
    • setXSLTC

      public void setXSLTC(XSLTC xsltc)
    • getXSLTC

      public XSLTC getXSLTC()
    • getCurrentImportPrecedence

      public int getCurrentImportPrecedence()
    • getNextImportPrecedence

      public int getNextImportPrecedence()
    • setCurrentStylesheet

      public void setCurrentStylesheet(Stylesheet stylesheet)
    • getCurrentStylesheet

      public Stylesheet getCurrentStylesheet()
    • getTopLevelStylesheet

      public Stylesheet getTopLevelStylesheet()
    • getQNameSafe

      public org.apache.xalan.xsltc.compiler.QName getQNameSafe(String stringRep)
    • getQName

      public org.apache.xalan.xsltc.compiler.QName getQName(String stringRep)
    • getQNameIgnoreDefaultNs

      public org.apache.xalan.xsltc.compiler.QName getQNameIgnoreDefaultNs(String stringRep)
    • getQName

      public org.apache.xalan.xsltc.compiler.QName getQName(String stringRep, boolean reportError)
    • getQName

      public org.apache.xalan.xsltc.compiler.QName getQName(String namespace, String prefix, String localname)
    • getQName

      public org.apache.xalan.xsltc.compiler.QName getQName(String scope, String name)
    • getQName

      public org.apache.xalan.xsltc.compiler.QName getQName(org.apache.xalan.xsltc.compiler.QName scope, org.apache.xalan.xsltc.compiler.QName name)
    • getUseAttributeSets

      public org.apache.xalan.xsltc.compiler.QName getUseAttributeSets()
    • getExtensionElementPrefixes

      public org.apache.xalan.xsltc.compiler.QName getExtensionElementPrefixes()
    • getExcludeResultPrefixes

      public org.apache.xalan.xsltc.compiler.QName getExcludeResultPrefixes()
    • makeStylesheet

      public Stylesheet makeStylesheet(SyntaxTreeNode element) throws CompilerException
      Create an instance of the Stylesheet class, and then parse, typecheck and compile the instance. Must be called after parse().
      Throws:
      CompilerException
    • createAST

      public void createAST(Stylesheet stylesheet)
      Instanciates a SAX2 parser and generate the AST from the input.
    • parse

      public SyntaxTreeNode parse(XMLReader reader, InputSource input)
      Parses a stylesheet and builds the internal abstract syntax tree
      Parameters:
      reader - A SAX2 SAXReader (parser)
      input - A SAX2 InputSource can be passed to a SAX reader
      Returns:
      The root of the abstract syntax tree
    • parse

      public SyntaxTreeNode parse(InputSource input)
      Parses a stylesheet and builds the internal abstract syntax tree
      Parameters:
      input - A SAX2 InputSource can be passed to a SAX reader
      Returns:
      The root of the abstract syntax tree
    • getDocumentRoot

      public SyntaxTreeNode getDocumentRoot()
    • elementSupported

      public boolean elementSupported(String namespace, String localName)
    • functionSupported

      public boolean functionSupported(String fname)
    • getSymbolTable

      public org.apache.xalan.xsltc.compiler.SymbolTable getSymbolTable()
    • getTemplate

      public Template getTemplate()
    • setTemplate

      public void setTemplate(Template template)
    • getTemplateIndex

      public int getTemplateIndex()
    • makeInstance

      public SyntaxTreeNode makeInstance(String uri, String prefix, String local, Attributes attributes)
    • parseExpression

      public org.apache.xalan.xsltc.compiler.Expression parseExpression(SyntaxTreeNode parent, String exp)
      Parse an XPath expression:
      Parameters:
      parent - - XSL element where the expression occured
      exp - - textual representation of the expression
    • parseExpression

      public org.apache.xalan.xsltc.compiler.Expression parseExpression(SyntaxTreeNode parent, String attr, String def)
      Parse an XPath expression:
      Parameters:
      parent - - XSL element where the expression occured
      attr - - name of this element's attribute to get expression from
      def - - default expression (if the attribute was not found)
    • parsePattern

      public Pattern parsePattern(SyntaxTreeNode parent, String pattern)
      Parse an XPath pattern:
      Parameters:
      parent - - XSL element where the pattern occured
      pattern - - textual representation of the pattern
    • parsePattern

      public Pattern parsePattern(SyntaxTreeNode parent, String attr, String def)
      Parse an XPath pattern:
      Parameters:
      parent - - XSL element where the pattern occured
      attr - - name of this element's attribute to get pattern from
      def - - default pattern (if the attribute was not found)
    • errorsFound

      public boolean errorsFound()
      Returns true if there were any errors during compilation
    • printErrors

      public void printErrors()
      Prints all compile-time errors
    • printWarnings

      public void printWarnings()
      Prints all compile-time warnings
    • reportError

      public void reportError(int category, ErrorMsg error)
      Common error/warning message handler
    • getErrors

      public Vector getErrors()
    • getWarnings

      public Vector getWarnings()
    • startDocument

      public void startDocument()
      SAX2: Receive notification of the beginning of a document.
      Specified by:
      startDocument in interface ContentHandler
    • endDocument

      public void endDocument()
      SAX2: Receive notification of the end of a document.
      Specified by:
      endDocument in interface ContentHandler
    • startPrefixMapping

      public void startPrefixMapping(String prefix, String uri)
      SAX2: Begin the scope of a prefix-URI Namespace mapping. This has to be passed on to the symbol table!
      Specified by:
      startPrefixMapping in interface ContentHandler
    • endPrefixMapping

      public void endPrefixMapping(String prefix)
      SAX2: End the scope of a prefix-URI Namespace mapping. This has to be passed on to the symbol table!
      Specified by:
      endPrefixMapping in interface ContentHandler
    • startElement

      public void startElement(String uri, String localname, String qname, Attributes attributes) throws SAXException
      SAX2: Receive notification of the beginning of an element. The parser may re-use the attribute list that we're passed so we clone the attributes in our own Attributes implementation
      Specified by:
      startElement in interface ContentHandler
      Throws:
      SAXException
    • endElement

      public void endElement(String uri, String localname, String qname)
      SAX2: Receive notification of the end of an element.
      Specified by:
      endElement in interface ContentHandler
    • characters

      public void characters(char[] ch, int start, int length)
      SAX2: Receive notification of character data.
      Specified by:
      characters in interface ContentHandler
    • processingInstruction

      public void processingInstruction(String name, String value)
      SAX2: Receive notification of a processing instruction. These require special handling for stylesheet PIs.
      Specified by:
      processingInstruction in interface ContentHandler
    • ignorableWhitespace

      public void ignorableWhitespace(char[] ch, int start, int length)
      IGNORED - all ignorable whitespace is ignored
      Specified by:
      ignorableWhitespace in interface ContentHandler
    • skippedEntity

      public void skippedEntity(String name)
      IGNORED - we do not have to do anything with skipped entities
      Specified by:
      skippedEntity in interface ContentHandler
    • setDocumentLocator

      public void setDocumentLocator(Locator locator)
      Store the document locator to later retrieve line numbers of all elements from the stylesheet
      Specified by:
      setDocumentLocator in interface ContentHandler