Class Parser

  • All Implemented Interfaces:
    org.apache.bcel.generic.InstructionConstants, Constants, org.xml.sax.ContentHandler

    public class Parser
    extends java.lang.Object
    implements Constants, org.xml.sax.ContentHandler
    Author:
    Jacek Ambroziak, Santiago Pericas-Geertsen, G. Todd Miller, Morten Jorgensen, Erwin Bolwidt
    • Constructor Detail

      • Parser

        public Parser​(XSLTC xsltc)
    • Method Detail

      • 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 java.util.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​(java.lang.String stringRep)
      • getQName

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

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

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

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

        public org.apache.xalan.xsltc.compiler.QName getQName​(java.lang.String scope,
                                                              java.lang.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()
      • createAST

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

        public SyntaxTreeNode parse​(org.xml.sax.XMLReader reader,
                                    org.xml.sax.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​(org.xml.sax.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
      • elementSupported

        public boolean elementSupported​(java.lang.String namespace,
                                        java.lang.String localName)
      • functionSupported

        public boolean functionSupported​(java.lang.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​(java.lang.String uri,
                                           java.lang.String prefix,
                                           java.lang.String local,
                                           org.xml.sax.Attributes attributes)
      • parseExpression

        public org.apache.xalan.xsltc.compiler.Expression parseExpression​(SyntaxTreeNode parent,
                                                                          java.lang.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,
                                                                          java.lang.String attr,
                                                                          java.lang.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,
                                    java.lang.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,
                                    java.lang.String attr,
                                    java.lang.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 java.util.Vector getErrors()
      • getWarnings

        public java.util.Vector getWarnings()
      • startDocument

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

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

        public void startPrefixMapping​(java.lang.String prefix,
                                       java.lang.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 org.xml.sax.ContentHandler
      • endPrefixMapping

        public void endPrefixMapping​(java.lang.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 org.xml.sax.ContentHandler
      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localname,
                                 java.lang.String qname,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.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 org.xml.sax.ContentHandler
        Throws:
        org.xml.sax.SAXException
      • endElement

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

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

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

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

        public void skippedEntity​(java.lang.String name)
        IGNORED - we do not have to do anything with skipped entities
        Specified by:
        skippedEntity in interface org.xml.sax.ContentHandler
      • setDocumentLocator

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