|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.xsltc.compiler.Parser
public class Parser
Field Summary | |
---|---|
private int |
_currentImportPrecedence
|
private Stylesheet |
_currentStylesheet
|
private java.util.Vector |
_errors
|
private QName |
_excludeResultPrefixes
|
private QName |
_extensionElementPrefixes
|
private java.util.Hashtable |
_instructionAttrs
|
private java.util.Hashtable |
_instructionClasses
|
private org.xml.sax.Locator |
_locator
|
private java.util.Hashtable |
_namespaces
|
private Output |
_output
|
private java.util.Stack |
_parentStack
SAX2 ContentHandler INTERFACE |
private java.lang.String |
_PIcharset
|
private java.lang.String |
_PImedia
|
private java.lang.String |
_PItitle
|
private java.util.Hashtable |
_prefixMapping
|
private java.util.Hashtable |
_qNames
|
private SyntaxTreeNode |
_root
|
private boolean |
_rootNamespaceDef
|
private SymbolTable |
_symbolTable
|
private java.lang.String |
_target
|
private Template |
_template
|
private int |
_templateIndex
|
private QName |
_useAttributeSets
|
private java.util.Hashtable |
_variableScope
|
private java.util.Vector |
_warnings
|
private XPathParser |
_xpathParser
|
private XSLTC |
_xsltc
|
private static java.lang.String |
TRANSLET
|
private boolean |
versionIsOne
Creates a new node in the abstract syntax tree. |
private static java.lang.String |
XSL
|
Constructor Summary | |
---|---|
Parser(XSLTC xsltc)
|
Method Summary | |
---|---|
void |
addParameter(Param param)
|
void |
addVariable(Variable var)
|
private void |
addVariableOrParam(VariableBase var)
|
void |
characters(char[] ch,
int start,
int length)
SAX2: Receive notification of character data. |
private void |
checkForSuperfluousAttributes(SyntaxTreeNode node,
org.xml.sax.Attributes attrs)
checks the list of attributes against a list of allowed attributes for a particular element node. |
void |
createAST(Stylesheet stylesheet)
Instanciates a SAX2 parser and generate the AST from the input. |
boolean |
elementSupported(java.lang.String namespace,
java.lang.String localName)
|
void |
endDocument()
SAX2: Receive notification of the end of a document. |
void |
endElement(java.lang.String uri,
java.lang.String localname,
java.lang.String qname)
SAX2: Receive notification of the end of an element. |
void |
endPrefixMapping(java.lang.String prefix)
SAX2: End the scope of a prefix-URI Namespace mapping. |
boolean |
errorsFound()
Returns true if there were any errors during compilation |
private SyntaxTreeNode |
findStylesheet(SyntaxTreeNode root,
java.lang.String href)
Find a Stylesheet element with a specific ID attribute value. |
boolean |
functionSupported(java.lang.String fname)
|
int |
getCurrentImportPrecedence()
|
Stylesheet |
getCurrentStylesheet()
|
SyntaxTreeNode |
getDocumentRoot()
|
java.util.Vector |
getErrors()
|
QName |
getExcludeResultPrefixes()
|
QName |
getExtensionElementPrefixes()
|
private int |
getLineNumber()
Get the line number, or zero if there is no _locator. |
int |
getNextImportPrecedence()
|
Output |
getOutput()
|
java.util.Properties |
getOutputProperties()
|
QName |
getQName(QName scope,
QName name)
|
QName |
getQName(java.lang.String stringRep)
|
QName |
getQName(java.lang.String stringRep,
boolean reportError)
|
private QName |
getQName(java.lang.String stringRep,
boolean reportError,
boolean ignoreDefaultNs)
|
QName |
getQName(java.lang.String scope,
java.lang.String name)
|
QName |
getQName(java.lang.String namespace,
java.lang.String prefix,
java.lang.String localname)
|
QName |
getQNameIgnoreDefaultNs(java.lang.String stringRep)
|
QName |
getQNameSafe(java.lang.String stringRep)
|
private SyntaxTreeNode |
getStylesheet(SyntaxTreeNode root)
Extracts the DOM for the stylesheet. |
SymbolTable |
getSymbolTable()
|
Template |
getTemplate()
|
int |
getTemplateIndex()
|
private java.lang.String |
getTokenValue(java.lang.String token)
|
Stylesheet |
getTopLevelStylesheet()
|
QName |
getUseAttributeSets()
|
java.util.Vector |
getWarnings()
|
XSLTC |
getXSLTC()
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
IGNORED - all ignorable whitespace is ignored |
void |
init()
|
private void |
initAttrTable(java.lang.String elementName,
java.lang.String[] attrs)
|
private void |
initExtClass(java.lang.String elementName,
java.lang.String className)
|
private void |
initExtClass(java.lang.String namespace,
java.lang.String elementName,
java.lang.String className)
|
private void |
initExtClasses()
|
private void |
initInstructionAttrs()
|
private void |
initStdClass(java.lang.String elementName,
java.lang.String className)
|
private void |
initStdClasses()
Initialize the _instructionClasses Hashtable, which maps XSL element names to Java classes in this package. |
private void |
initSymbolTable()
Add primops and base functions to the symbol table. |
private SyntaxTreeNode |
loadExternalStylesheet(java.lang.String location)
For embedded stylesheets: Load an external file with stylesheet |
VariableBase |
lookupVariable(QName name)
|
SyntaxTreeNode |
makeInstance(java.lang.String uri,
java.lang.String prefix,
java.lang.String local,
org.xml.sax.Attributes attributes)
|
Stylesheet |
makeStylesheet(SyntaxTreeNode element)
Create an instance of the Stylesheet class,
and then parse, typecheck and compile the instance. |
SyntaxTreeNode |
parse(org.xml.sax.InputSource input)
Parses a stylesheet and builds the internal abstract syntax tree |
SyntaxTreeNode |
parse(org.xml.sax.XMLReader reader,
org.xml.sax.InputSource input)
Parses a stylesheet and builds the internal abstract syntax tree |
Expression |
parseExpression(SyntaxTreeNode parent,
java.lang.String exp)
Parse an XPath expression: |
Expression |
parseExpression(SyntaxTreeNode parent,
java.lang.String attr,
java.lang.String def)
Parse an XPath expression: |
Pattern |
parsePattern(SyntaxTreeNode parent,
java.lang.String pattern)
Parse an XPath pattern: |
Pattern |
parsePattern(SyntaxTreeNode parent,
java.lang.String attr,
java.lang.String def)
Parse an XPath pattern: |
private SyntaxTreeNode |
parseTopLevel(SyntaxTreeNode parent,
java.lang.String text,
java.lang.String expression)
Parse an XPath expression or pattern using the generated XPathParser The method will return a Dummy node if the XPath parser fails. |
void |
printErrors()
Prints all compile-time errors |
void |
printWarnings()
Prints all compile-time warnings |
void |
processingInstruction(java.lang.String name,
java.lang.String value)
SAX2: Receive notification of a processing instruction. |
void |
removeVariable(QName name)
|
void |
reportError(int category,
ErrorMsg error)
Common error/warning message handler |
void |
setCurrentStylesheet(Stylesheet stylesheet)
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
Store the document locator to later retrieve line numbers of all elements from the stylesheet |
void |
setOutput(Output output)
|
protected void |
setPIParameters(java.lang.String media,
java.lang.String title,
java.lang.String charset)
Set the parameters to use to locate the correct processing instruction in the case where the input document is an XML document with one or more references to a stylesheet. |
void |
setTemplate(Template template)
|
void |
setXSLTC(XSLTC xsltc)
|
void |
skippedEntity(java.lang.String name)
IGNORED - we do not have to do anything with skipped entities |
void |
startDocument()
SAX2: Receive notification of the beginning of a document. |
void |
startElement(java.lang.String uri,
java.lang.String localname,
java.lang.String qname,
org.xml.sax.Attributes attributes)
SAX2: Receive notification of the beginning of an element. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
SAX2: Begin the scope of a prefix-URI Namespace mapping. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String XSL
private static final java.lang.String TRANSLET
private org.xml.sax.Locator _locator
private XSLTC _xsltc
private XPathParser _xpathParser
private java.util.Vector _errors
private java.util.Vector _warnings
private java.util.Hashtable _instructionClasses
private java.util.Hashtable _instructionAttrs
private java.util.Hashtable _qNames
private java.util.Hashtable _namespaces
private QName _useAttributeSets
private QName _excludeResultPrefixes
private QName _extensionElementPrefixes
private java.util.Hashtable _variableScope
private Stylesheet _currentStylesheet
private SymbolTable _symbolTable
private Output _output
private Template _template
private boolean _rootNamespaceDef
private SyntaxTreeNode _root
private java.lang.String _target
private int _currentImportPrecedence
private java.lang.String _PImedia
private java.lang.String _PItitle
private java.lang.String _PIcharset
private int _templateIndex
private boolean versionIsOne
private java.util.Stack _parentStack
private java.util.Hashtable _prefixMapping
Constructor Detail |
---|
public Parser(XSLTC xsltc)
Method Detail |
---|
public void init()
public void setOutput(Output output)
public Output getOutput()
public java.util.Properties getOutputProperties()
public void addVariable(Variable var)
public void addParameter(Param param)
private void addVariableOrParam(VariableBase var)
public void removeVariable(QName name)
public VariableBase lookupVariable(QName name)
public void setXSLTC(XSLTC xsltc)
public XSLTC getXSLTC()
public int getCurrentImportPrecedence()
public int getNextImportPrecedence()
public void setCurrentStylesheet(Stylesheet stylesheet)
public Stylesheet getCurrentStylesheet()
public Stylesheet getTopLevelStylesheet()
public QName getQNameSafe(java.lang.String stringRep)
public QName getQName(java.lang.String stringRep)
public QName getQNameIgnoreDefaultNs(java.lang.String stringRep)
public QName getQName(java.lang.String stringRep, boolean reportError)
private QName getQName(java.lang.String stringRep, boolean reportError, boolean ignoreDefaultNs)
public QName getQName(java.lang.String namespace, java.lang.String prefix, java.lang.String localname)
public QName getQName(java.lang.String scope, java.lang.String name)
public QName getQName(QName scope, QName name)
public QName getUseAttributeSets()
public QName getExtensionElementPrefixes()
public QName getExcludeResultPrefixes()
public Stylesheet makeStylesheet(SyntaxTreeNode element) throws CompilerException
Stylesheet
class,
and then parse, typecheck and compile the instance.
Must be called after parse()
.
CompilerException
public void createAST(Stylesheet stylesheet)
public SyntaxTreeNode parse(org.xml.sax.XMLReader reader, org.xml.sax.InputSource input)
reader
- A SAX2 SAXReader (parser)input
- A SAX2 InputSource can be passed to a SAX reader
public SyntaxTreeNode parse(org.xml.sax.InputSource input)
input
- A SAX2 InputSource can be passed to a SAX reader
public SyntaxTreeNode getDocumentRoot()
protected void setPIParameters(java.lang.String media, java.lang.String title, java.lang.String charset)
media
- The media attribute to be matched. May be null, in which
case the prefered templates will be used (i.e. alternate = no).title
- The value of the title attribute to match. May be null.charset
- The value of the charset attribute to match. May be null.private SyntaxTreeNode getStylesheet(SyntaxTreeNode root) throws CompilerException
CompilerException
private SyntaxTreeNode findStylesheet(SyntaxTreeNode root, java.lang.String href)
private SyntaxTreeNode loadExternalStylesheet(java.lang.String location) throws CompilerException
CompilerException
private void initAttrTable(java.lang.String elementName, java.lang.String[] attrs)
private void initInstructionAttrs()
private void initStdClasses()
private void initStdClass(java.lang.String elementName, java.lang.String className)
public boolean elementSupported(java.lang.String namespace, java.lang.String localName)
public boolean functionSupported(java.lang.String fname)
private void initExtClasses()
private void initExtClass(java.lang.String elementName, java.lang.String className)
private void initExtClass(java.lang.String namespace, java.lang.String elementName, java.lang.String className)
private void initSymbolTable()
public SymbolTable getSymbolTable()
public Template getTemplate()
public void setTemplate(Template template)
public int getTemplateIndex()
public SyntaxTreeNode makeInstance(java.lang.String uri, java.lang.String prefix, java.lang.String local, org.xml.sax.Attributes attributes)
private void checkForSuperfluousAttributes(SyntaxTreeNode node, org.xml.sax.Attributes attrs)
public Expression parseExpression(SyntaxTreeNode parent, java.lang.String exp)
parent
- - XSL element where the expression occuredexp
- - textual representation of the expressionpublic Expression parseExpression(SyntaxTreeNode parent, java.lang.String attr, java.lang.String def)
parent
- - XSL element where the expression occuredattr
- - name of this element's attribute to get expression fromdef
- - default expression (if the attribute was not found)public Pattern parsePattern(SyntaxTreeNode parent, java.lang.String pattern)
parent
- - XSL element where the pattern occuredpattern
- - textual representation of the patternpublic Pattern parsePattern(SyntaxTreeNode parent, java.lang.String attr, java.lang.String def)
parent
- - XSL element where the pattern occuredattr
- - name of this element's attribute to get pattern fromdef
- - default pattern (if the attribute was not found)private SyntaxTreeNode parseTopLevel(SyntaxTreeNode parent, java.lang.String text, java.lang.String expression)
public boolean errorsFound()
public void printErrors()
public void printWarnings()
public void reportError(int category, ErrorMsg error)
public java.util.Vector getErrors()
public java.util.Vector getWarnings()
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping
in interface org.xml.sax.ContentHandler
public void endPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interface org.xml.sax.ContentHandler
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
startElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String localname, java.lang.String qname)
endElement
in interface org.xml.sax.ContentHandler
public void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
private java.lang.String getTokenValue(java.lang.String token)
public void processingInstruction(java.lang.String name, java.lang.String value)
processingInstruction
in interface org.xml.sax.ContentHandler
public void ignorableWhitespace(char[] ch, int start, int length)
ignorableWhitespace
in interface org.xml.sax.ContentHandler
public void skippedEntity(java.lang.String name)
skippedEntity
in interface org.xml.sax.ContentHandler
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
private int getLineNumber()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |