APIdia Launch Partner
Top Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.compiler

public abstract Class SyntaxTreeNode

extends Object
implements Constants
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xalan.internal.xsltc.compiler.Constants
Known Direct Subclasses
com.sun.org.apache.xalan.internal.xsltc.compiler.UnsupportedElement, com.sun.org.apache.xalan.internal.xsltc.compiler.Expression, com.sun.org.apache.xalan.internal.xsltc.compiler.Instruction, com.sun.org.apache.xalan.internal.xsltc.compiler.TopLevelElement, com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet
Imports
com.sun.org.apache.bcel.internal.generic.ANEWARRAY, .BasicType, .CHECKCAST, .ConstantPoolGen, .DUP_X1, .GETFIELD, .ICONST, .INVOKEINTERFACE, .INVOKESPECIAL, .INVOKEVIRTUAL, .InstructionList, .NEW, .NEWARRAY, .PUSH, com.sun.org.apache.xalan.internal.xsltc.DOM, com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator, .ErrorMsg, .MethodGenerator, .Type, .TypeCheckError, .Util, java.util.ArrayList, .HashMap, .Iterator, .List, .Map, org.xml.sax.Attributes, org.xml.sax.helpers.AttributesImpl

Authors
Jacek Ambroziak, Santiago Pericas-Geertsen, G. Todd Miller, Morten Jorensen, Erwin Bolwidt , John Howard

Field Summary

Modifier and TypeField and Description
protected AttributesImpl
private final List<SyntaxTreeNode>
private int
protected SyntaxTreeNode
private Parser
private Map<String, String>
protected QName
private static final char[]
private Stylesheet
private Template
protected static final SyntaxTreeNode
protected static final int

Constructor Summary

AccessConstructor and Description
public
SyntaxTreeNode()

Creates a new SyntaxTreeNode with a 'null' QName and no source file line number reference.

public
SyntaxTreeNode(int
Source file line number reference
line
)

Creates a new SyntaxTreeNode with a 'null' QName.

public
SyntaxTreeNode(String
The element's namespace URI
uri
,
String
The element's namespace prefix
prefix
,
String
The element's local name
local
)

Creates a new SyntaxTreeNode with no source file line number reference.

Method Summary

Modifier and TypeMethod and Description
protected void
addAttribute(String qname, String value)

protected final void
addElement(SyntaxTreeNode
is the new child node.
element
)

Adds a child node to this syntax tree node.

protected void
addPrefixMapping(String
Namespace prefix.
prefix
,
String
Namespace URI.
uri
)

Adds a single prefix mapping to this syntax tree node.

protected void
compileResultTree(ClassGenerator
BCEL Java class generator
classGen
,
MethodGenerator
BCEL Java method generator
methodGen
)

Utility method used by parameters and variables to store result trees

protected boolean

Returns:

'true' if this node depends on the context.
contextDependent
()

Returns true if this expression/instruction depends on the context.

protected boolean

Returns:

'true' if the contents of this node is context dependent.
dependentContents
()

Return true if any of the expressions/instructions in the contents of this node is context dependent.

public void
display(int
Indentation level for syntax tree levels.
indent
)

Displays the contents of this syntax tree node (to stdout).

protected void
displayContents(int
Indentation level for syntax tree levels.
indent
)

Displays the contents of this syntax tree node (to stdout).

protected final SyntaxTreeNode

Returns:

The child node.
elementAt
(int
The child node's position.
pos
)

Returns a child node at a given position.

protected final int

Returns:

Number of child nodes.
elementCount
()

Returns the number of children this node has.

protected final Iterator<SyntaxTreeNode>

Returns:

An Iterator of all child nodes of this node.
elements
()

Returns an Iterator of all child nodes of this node.

protected String

Returns:

The value of the attribute of name 'qname'.
getAttribute
(String
The QName of the attribute to return.
qname
)

Returns a value for an attribute from the source element.

protected String
getAttribute(String prefix, String localName)

protected Attributes

Returns:

Attributes for this syntax tree node
getAttributes
()

Returns a list of all attributes declared for the element represented by this syntax tree node.

protected final List<SyntaxTreeNode>

Returns:

A List containing all the child nodes of this node.
getContents
()

Returns a List containing all the child nodes of this node.

protected int

Returns:

The import precedence of this syntax tree node.
getImportPrecedence
()

Get the import precedence of this element.

public final int

Returns:

The source file line number.
getLineNumber
()

Get the source file line number for this element.

protected final SyntaxTreeNode

Returns:

The parent syntax tree node.
getParent
()

Returns this syntax tree node's parent node.

public final Parser

Returns:

The XSLT parser.
getParser
()

Returns this node's XSLT parser.

protected Map<String, String>

Returns:

Prefix mappings (for this element only).
getPrefixMapping
()

Returns a Map containing the prefix mappings that were declared for this element.

protected QName
getQName()

Set the QName for the SyntaxTreeNode

public Stylesheet

Returns:

The Stylesheet ancestor node of this node.
getStylesheet
()

Get the Stylesheet node that represents the <xsl:stylesheet/> element that this node occured under.

protected final SymbolTable

Returns:

Symbol table.
getSymbolTable
()

Returns the XSLT parser's symbol table.

protected Template

Returns:

The Template ancestor node of this node or 'null'.
getTemplate
()

Get the Template node that represents the <xsl:template/> element that this node occured under.

protected final XSLTC

Returns:

XSLTC - XSLT compiler.
getXSLTC
()

Returns a reference to the XSLTC (XSLT compiler) in use.

protected boolean
protected final boolean

Returns:

'true' if this node has any children.
hasContents
()

Tells you if this node has any child nodes.

protected final void
indent(int
Indentation level for syntax tree levels.
indent
)

Set the indentation level for debug output.

private boolean

Returns:

true if the node content can be considered as an adaptive RTF.
isAdaptiveRTF
(SyntaxTreeNode
A node
node
)

Return true if the node represents an adaptive RTF.

protected final boolean

Returns:

'true' if this syntax tree node is the Sentinal node.
isDummy
()

Returns 'true' if this syntax tree node is the Sentinal node.

private boolean

Returns:

true if the node content can be considered as a simple RTF.
isSimpleRTF
(SyntaxTreeNode
A node
node
)

Return true if the node represents a simple RTF.

private boolean

Returns:

true if the node of Text type
isTextElement
(SyntaxTreeNode
A node
node
,
boolean
If this flag is true, <xsl:call-template> and <xsl:apply-templates> are also considered as Text elements.
doExtendedCheck
)

Return true if the node only produces Text content.

protected final SyntaxTreeNode

Returns:

The child node.
lastChild
()

Returns this element's last child

protected String

Returns:

Namespace URI.
lookupNamespace
(String
Namespace prefix.
prefix
)

Returns any namespace URI that is in scope for a given prefix.

protected String

Returns:

Namespace prefix.
lookupPrefix
(String
Namespace URI.
uri
)

Returns any namespace prefix that is mapped to a prefix in the current scope.

public boolean

Returns:

true if there is at least one child that is not of the specified type, false otherwise.
notTypeOf
(Class<?>
the type to be checked against
type
)

Checks whether any children of this node is not of the specified type.

protected final void
parseChildren(Parser
reference to the XSLT parser
parser
)

Parse all children of this syntax tree node.

public void
parseContents(Parser
reference to the XSLT parser
parser
)

Parse the contents of this syntax tree nodes (child nodes, XPath expressions, patterns and functions).

protected final void
removeElement(SyntaxTreeNode
is the child node to remove.
element
)

Removed a child node of this syntax tree node.

protected void
reportError(SyntaxTreeNode
The element in which the error occured (normally 'this' but it could also be an expression/pattern/etc.)
element
,
Parser
The XSLT parser to report the error to.
parser
,
String errorCode, String
Any additional error message.
message
)

Report an error to the parser.

protected void
reportWarning(SyntaxTreeNode
The element in which the error occured (normally 'this' but it could also be an expression/pattern/etc.)
element
,
Parser
The XSLT parser to report the error to.
parser
,
String errorCode, String
Any additional error message.
message
)

Report a recoverable error to the parser.

protected void
setAttributes(AttributesImpl
Attributes for the element. Must be passed in as an implementation of org.xml.sax.Attributes.
attributes
)

Set the attributes for this SyntaxTreeNode.

protected final void
setFirstElement(SyntaxTreeNode
is the new child node.
element
)

Inserts the first child node of this syntax tree node.

protected final void
setLineNumber(int
The source file line number.
line
)

Set the source file line number for this element

protected void
setParent(SyntaxTreeNode
The parent node.
parent
)

Set this syntax tree node's parent node, if unset.

protected void
setParser(Parser
The XSLT parser.
parser
)

Set this node's parser.

protected void
setPrefixMapping(Map<String, String>
The Map containing the mappings.
mapping
)

Sets the prefix mapping for the namespaces that were declared in this element.

protected void
setQName(QName
The QName for the syntax tree node
qname
)

Set the QName for the syntax tree node.

protected void
setQName(String
The element's namespace URI
uri
,
String
The element's namespace prefix
prefix
,
String localname)

Set the QName for the SyntaxTreeNode

public abstract void
translate(ClassGenerator
BCEL Java class generator
classGen
,
MethodGenerator
BCEL Java method generator
methodGen
)

Translate this abstract syntax tree node into JVM bytecodes.

protected void
translateContents(ClassGenerator
BCEL Java class generator
classGen
,
MethodGenerator
BCEL Java method generator
methodGen
)

Call translate() on all child syntax tree nodes.

public abstract Type
typeCheck(SymbolTable
The compiler/parser's symbol table
stable
)

Type check the children of this node.

protected Type
typeCheckContents(SymbolTable
The compiler/parser's symbol table
stable
)

Call typeCheck() on all child syntax tree nodes.

protected QName
updateScope(Parser parser, SyntaxTreeNode node)

Add a node to the current scope and return name of a variable or parameter if the node represents a variable or a parameter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_attributesback to summary
protected AttributesImpl _attributes
_contentsback to summary
private final List<SyntaxTreeNode> _contents
_lineback to summary
private int _line
_parentback to summary
protected SyntaxTreeNode _parent
_parserback to summary
private Parser _parser
_prefixMappingback to summary
private Map<String, String> _prefixMapping
_qnameback to summary
protected QName _qname
_spacesback to summary
private static final char[] _spaces
_stylesheetback to summary
private Stylesheet _stylesheet
_templateback to summary
private Template _template
Dummyback to summary
protected static final SyntaxTreeNode Dummy
IndentIncrementback to summary
protected static final int IndentIncrement

Constructor Detail

SyntaxTreeNodeback to summary
public SyntaxTreeNode()

Creates a new SyntaxTreeNode with a 'null' QName and no source file line number reference.

SyntaxTreeNodeback to summary
public SyntaxTreeNode(int line)

Creates a new SyntaxTreeNode with a 'null' QName.

Parameters
line:int

Source file line number reference

SyntaxTreeNodeback to summary
public SyntaxTreeNode(String uri, String prefix, String local)

Creates a new SyntaxTreeNode with no source file line number reference.

Parameters
uri:String

The element's namespace URI

prefix:String

The element's namespace prefix

local:String

The element's local name

Method Detail

addAttributeback to summary
protected void addAttribute(String qname, String value)
addElementback to summary
protected final void addElement(SyntaxTreeNode element)

Adds a child node to this syntax tree node.

Parameters
element:SyntaxTreeNode

is the new child node.

addPrefixMappingback to summary
protected void addPrefixMapping(String prefix, String uri)

Adds a single prefix mapping to this syntax tree node.

Parameters
prefix:String

Namespace prefix.

uri:String

Namespace URI.

compileResultTreeback to summary
protected void compileResultTree(ClassGenerator classGen, MethodGenerator methodGen)

Utility method used by parameters and variables to store result trees

Parameters
classGen:ClassGenerator

BCEL Java class generator

methodGen:MethodGenerator

BCEL Java method generator

contextDependentback to summary
protected boolean contextDependent()

Returns true if this expression/instruction depends on the context. By default, every expression/instruction depends on the context unless it overrides this method. Currently used to determine if result trees are compiled using procedures or little DOMs (result tree fragments).

Returns:boolean

'true' if this node depends on the context.

dependentContentsback to summary
protected boolean dependentContents()

Return true if any of the expressions/instructions in the contents of this node is context dependent.

Returns:boolean

'true' if the contents of this node is context dependent.

displayback to summary
public void display(int indent)

Displays the contents of this syntax tree node (to stdout). This method is intended for debugging _only_, and should be overridden by all syntax tree node implementations.

Parameters
indent:int

Indentation level for syntax tree levels.

displayContentsback to summary
protected void displayContents(int indent)

Displays the contents of this syntax tree node (to stdout). This method is intended for debugging _only_ !!!

Parameters
indent:int

Indentation level for syntax tree levels.

elementAtback to summary
protected final SyntaxTreeNode elementAt(int pos)

Returns a child node at a given position.

Parameters
pos:int

The child node's position.

Returns:SyntaxTreeNode

The child node.

elementCountback to summary
protected final int elementCount()

Returns the number of children this node has.

Returns:int

Number of child nodes.

elementsback to summary
protected final Iterator<SyntaxTreeNode> elements()

Returns an Iterator of all child nodes of this node.

Returns:Iterator<SyntaxTreeNode>

An Iterator of all child nodes of this node.

getAttributeback to summary
protected String getAttribute(String qname)

Returns a value for an attribute from the source element.

Parameters
qname:String

The QName of the attribute to return.

Returns:String

The value of the attribute of name 'qname'.

getAttributeback to summary
protected String getAttribute(String prefix, String localName)
getAttributesback to summary
protected Attributes getAttributes()

Returns a list of all attributes declared for the element represented by this syntax tree node.

Returns:Attributes

Attributes for this syntax tree node

getContentsback to summary
protected final List<SyntaxTreeNode> getContents()

Returns a List containing all the child nodes of this node.

Returns:List<SyntaxTreeNode>

A List containing all the child nodes of this node.

getImportPrecedenceback to summary
protected int getImportPrecedence()

Get the import precedence of this element. The import precedence equals the import precedence of the stylesheet in which this element occured.

Returns:int

The import precedence of this syntax tree node.

getLineNumberback to summary
public final int getLineNumber()

Get the source file line number for this element. If unavailable, lookup in ancestors.

Returns:int

The source file line number.

getParentback to summary
protected final SyntaxTreeNode getParent()

Returns this syntax tree node's parent node.

Returns:SyntaxTreeNode

The parent syntax tree node.

getParserback to summary
public final Parser getParser()

Returns this node's XSLT parser.

Returns:Parser

The XSLT parser.

getPrefixMappingback to summary
protected Map<String, String> getPrefixMapping()

Returns a Map containing the prefix mappings that were declared for this element. This does not include all prefix mappings in scope, so one may have to check ancestor elements to get all mappings that are in in scope.

Returns:Map<String, String>

Prefix mappings (for this element only).

getQNameback to summary
protected QName getQName()

Set the QName for the SyntaxTreeNode

getStylesheetback to summary
public Stylesheet getStylesheet()

Get the Stylesheet node that represents the <xsl:stylesheet/> element that this node occured under.

Returns:Stylesheet

The Stylesheet ancestor node of this node.

getSymbolTableback to summary
protected final SymbolTable getSymbolTable()

Returns the XSLT parser's symbol table.

Returns:SymbolTable

Symbol table.

getTemplateback to summary
protected Template getTemplate()

Get the Template node that represents the <xsl:template/> element that this node occured under. Note that this method will return 'null' for nodes that represent top-level elements.

Returns:Template

The Template ancestor node of this node or 'null'.

getXSLTCback to summary
protected final XSLTC getXSLTC()

Returns a reference to the XSLTC (XSLT compiler) in use.

Returns:XSLTC

XSLTC - XSLT compiler.

hasAttributeback to summary
protected boolean hasAttribute(String qname)
hasContentsback to summary
protected final boolean hasContents()

Tells you if this node has any child nodes.

Returns:boolean

'true' if this node has any children.

indentback to summary
protected final void indent(int indent)

Set the indentation level for debug output.

Parameters
indent:int

Indentation level for syntax tree levels.

isAdaptiveRTFback to summary
private boolean isAdaptiveRTF(SyntaxTreeNode node)

Return true if the node represents an adaptive RTF. A node is an adaptive RTF if each children is a Text element or it is <xsl:call-template> or <xsl:apply-templates>.

Parameters
node:SyntaxTreeNode

A node

Returns:boolean

true if the node content can be considered as an adaptive RTF.

isDummyback to summary
protected final boolean isDummy()

Returns 'true' if this syntax tree node is the Sentinal node.

Returns:boolean

'true' if this syntax tree node is the Sentinal node.

isSimpleRTFback to summary
private boolean isSimpleRTF(SyntaxTreeNode node)

Return true if the node represents a simple RTF. A node is a simple RTF if all children only produce Text value.

Parameters
node:SyntaxTreeNode

A node

Returns:boolean

true if the node content can be considered as a simple RTF.

isTextElementback to summary
private boolean isTextElement(SyntaxTreeNode node, boolean doExtendedCheck)

Return true if the node only produces Text content. A node is a Text element if it is Text, xsl:value-of, xsl:number, or a combination of these nested in a control instruction (xsl:if or xsl:choose). If the doExtendedCheck flag is true, xsl:call-template and xsl:apply-templates are also considered as Text elements.

Parameters
node:SyntaxTreeNode

A node

doExtendedCheck:boolean

If this flag is true, <xsl:call-template> and <xsl:apply-templates> are also considered as Text elements.

Returns:boolean

true if the node of Text type

lastChildback to summary
protected final SyntaxTreeNode lastChild()

Returns this element's last child

Returns:SyntaxTreeNode

The child node.

lookupNamespaceback to summary
protected String lookupNamespace(String prefix)

Returns any namespace URI that is in scope for a given prefix. This method checks namespace mappings for this element, and if necessary for ancestor elements as well (ie. if the prefix maps to an URI in this scope then you'll definately get the URI from this method).

Parameters
prefix:String

Namespace prefix.

Returns:String

Namespace URI.

lookupPrefixback to summary
protected String lookupPrefix(String uri)

Returns any namespace prefix that is mapped to a prefix in the current scope. This method checks namespace mappings for this element, and if necessary for ancestor elements as well (ie. if the URI is declared within the current scope then you'll definately get the prefix from this method). Note that this is a very slow method and consequentially it should only be used strictly when needed.

Parameters
uri:String

Namespace URI.

Returns:String

Namespace prefix.

notTypeOfback to summary
public boolean notTypeOf(Class<?> type)

Checks whether any children of this node is not of the specified type.

Parameters
type:Class<?>

the type to be checked against

Returns:boolean

true if there is at least one child that is not of the specified type, false otherwise.

parseChildrenback to summary
protected final void parseChildren(Parser parser)

Parse all children of this syntax tree node. This method is normally called by the parseContents() method.

Parameters
parser:Parser

reference to the XSLT parser

parseContentsback to summary
public void parseContents(Parser parser)

Parse the contents of this syntax tree nodes (child nodes, XPath expressions, patterns and functions). The default behaviour is to parser the syntax tree node's children (since there are no common expressions, patterns, etc. that can be handled in this base class.

Parameters
parser:Parser

reference to the XSLT parser

removeElementback to summary
protected final void removeElement(SyntaxTreeNode element)

Removed a child node of this syntax tree node.

Parameters
element:SyntaxTreeNode

is the child node to remove.

reportErrorback to summary
protected void reportError(SyntaxTreeNode element, Parser parser, String errorCode, String message)

Report an error to the parser.

Parameters
element:SyntaxTreeNode

The element in which the error occured (normally 'this' but it could also be an expression/pattern/etc.)

parser:Parser

The XSLT parser to report the error to.

message:String

Any additional error message.

reportWarningback to summary
protected void reportWarning(SyntaxTreeNode element, Parser parser, String errorCode, String message)

Report a recoverable error to the parser.

Parameters
element:SyntaxTreeNode

The element in which the error occured (normally 'this' but it could also be an expression/pattern/etc.)

parser:Parser

The XSLT parser to report the error to.

message:String

Any additional error message.

setAttributesback to summary
protected void setAttributes(AttributesImpl attributes)

Set the attributes for this SyntaxTreeNode.

Parameters
attributes:AttributesImpl

Attributes for the element. Must be passed in as an implementation of org.xml.sax.Attributes.

setFirstElementback to summary
protected final void setFirstElement(SyntaxTreeNode element)

Inserts the first child node of this syntax tree node. The existing children are shifted back one position.

Parameters
element:SyntaxTreeNode

is the new child node.

setLineNumberback to summary
protected final void setLineNumber(int line)

Set the source file line number for this element

Parameters
line:int

The source file line number.

setParentback to summary
protected void setParent(SyntaxTreeNode parent)

Set this syntax tree node's parent node, if unset. For re-parenting just use node._parent = newparent.

Parameters
parent:SyntaxTreeNode

The parent node.

setParserback to summary
protected void setParser(Parser parser)

Set this node's parser. The parser (the XSLT parser) gives this syntax tree node access to the symbol table and XPath parser.

Parameters
parser:Parser

The XSLT parser.

setPrefixMappingback to summary
protected void setPrefixMapping(Map<String, String> mapping)

Sets the prefix mapping for the namespaces that were declared in this element. This does not include all prefix mappings in scope, so one may have to check ancestor elements to get all mappings that are in in scope. The prefixes must be passed in as a Map that maps namespace prefixes (String objects) to namespace URIs (also String).

Parameters
mapping:Map<String, String>

The Map containing the mappings.

setQNameback to summary
protected void setQName(QName qname)

Set the QName for the syntax tree node.

Parameters
qname:QName

The QName for the syntax tree node

setQNameback to summary
protected void setQName(String uri, String prefix, String localname)

Set the QName for the SyntaxTreeNode

Parameters
uri:String

The element's namespace URI

prefix:String

The element's namespace prefix

translateback to summary
public abstract void translate(ClassGenerator classGen, MethodGenerator methodGen)

Translate this abstract syntax tree node into JVM bytecodes.

Parameters
classGen:ClassGenerator

BCEL Java class generator

methodGen:MethodGenerator

BCEL Java method generator

translateContentsback to summary
protected void translateContents(ClassGenerator classGen, MethodGenerator methodGen)

Call translate() on all child syntax tree nodes.

Parameters
classGen:ClassGenerator

BCEL Java class generator

methodGen:MethodGenerator

BCEL Java method generator

typeCheckback to summary
public abstract Type typeCheck(SymbolTable stable) throws TypeCheckError

Type check the children of this node. The type check phase may add coercions (CastExpr) to the AST.

Parameters
stable:SymbolTable

The compiler/parser's symbol table

typeCheckContentsback to summary
protected Type typeCheckContents(SymbolTable stable) throws TypeCheckError

Call typeCheck() on all child syntax tree nodes.

Parameters
stable:SymbolTable

The compiler/parser's symbol table

updateScopeback to summary
protected QName updateScope(Parser parser, SyntaxTreeNode node)

Add a node to the current scope and return name of a variable or parameter if the node represents a variable or a parameter.