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

public final Class Stylesheet

extends SyntaxTreeNode
Class Inheritance
Imports
com.sun.org.apache.bcel.internal.generic.ANEWARRAY, .BasicType, .ConstantPoolGen, .FieldGen, .GETFIELD, .GETSTATIC, .INVOKEINTERFACE, .INVOKESPECIAL, .INVOKESTATIC, .INVOKEVIRTUAL, .ISTORE, .InstructionHandle, .InstructionList, .LocalVariableGen, .NEW, .NEWARRAY, .PUSH, .PUTFIELD, .PUTSTATIC, .TargetLostException, com.sun.org.apache.bcel.internal.util.InstructionFinder, com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator, .ErrorMsg, .MethodGenerator, .Type, .TypeCheckError, .Util, com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet, com.sun.org.apache.xml.internal.dtm.DTM, com.sun.org.apache.xml.internal.utils.SystemIDResolver, java.util.ArrayList, .HashMap, .Iterator, .List, .Map, .Properties, .StringTokenizer

Authors
Jacek Ambroziak, Santiago Pericas-Geertsen, Morten Jorgensen

Field Summary

Modifier and TypeField and Description
private List<Template>
_allValidTemplates

Used to cache result of getAllValidTemplates().

private boolean
_callsNodeset

Flag indicating if nodset() is called.

private String
_className

The name of the class being generated.

private Mode
_defaultMode

A reference to the default Mode object.

private final Map<String, String>
_extensions

Mapping between extension URIs and their prefixes.

private List<VariableBase>
_globals

Contains global variables and parameters defined in the stylesheet.

private boolean
_hasIdCall

Flag indicating if id() is called.

private Boolean
_hasLocalParams

Used to cache the result returned by hasLocalParams().

public Stylesheet
_importedFrom

Reference to the stylesheet from which this stylesheet was imported (if any).

private int
_importPrecedence

Import precendence for this stylesheet.

public Stylesheet
_includedFrom

Reference to the stylesheet from which this stylesheet was included (if any).

private List<Stylesheet>
_includedStylesheets

Array of all the stylesheets imported or included from this one.

private Map<String, Key>
_keys

Mapping between key names and Key objects (needed by Key/IdPattern).

private Output
_lastOutputElement

A reference to the last xsl:output object found in the styleshet.

private SourceLoader
_loader

A reference to the SourceLoader set by the user (a URIResolver if the JAXP API is being used).

private int
_minimumDescendantPrecedence

Minimum precendence of any descendant stylesheet by inclusion or importation.

private final Map<String, Mode>
_modes

Mapping between mode names and Mode instances.

private boolean
_multiDocument

Flag indicating if multi-document support is needed.

private QName
_name

Internal name of this stylesheet used as a key into the symbol table.

private int
_nextModeSerial

Counter to generate unique mode suffixes.

private boolean
_numberFormattingUsed

Flag indicating if format-number() is called.

private int
_outputMethod

Output method for this stylesheet (must be set to one of the constants defined below).

private Properties
_outputProperties

Output properties for this stylesheet.

private Stylesheet
_parentStylesheet

A reference to the parent stylesheet or null if topmost.

private boolean
_simplified

Flag indicating if this is a simplified stylesheets.

private String
_systemId

A URI that represents the system ID for this stylesheet.

private boolean
_templateInlining

Set to true to enable template inlining optimization.

private final List<Template>
_templates

Contains all templates defined in this stylesheet

private String
_version

XSLT version defined in the stylesheet.

public static final int
public static final int
public static final int
public static final int
Inherited from com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode:
_attributes_parent_qnameDummyIndentIncrement

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public void
public int
addParam(Param param)

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

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.addPrefixMapping.

Adds a single prefix mapping to this syntax tree node.

private void
addStaticField(ClassGenerator classGen, String type, String name)

Add a static field

protected void
public int
public boolean
public boolean
checkForLoop(String systemId)

private void
checkOutputMethod()

Check and set the output method

private String
compileBuildKeys(ClassGenerator classGen)

Compile a buildKeys() method into the output class.

private void
compileConstructor(ClassGenerator classGen, Output output)

Compile the translet's constructor

private void
private void
compileStaticInitializer(ClassGenerator classGen)

Compile the namesArray, urisArray and typesArray into the static initializer.

private String
compileTopLevel(ClassGenerator classGen)

Compile a topLevel() method into the output class.

private void
compileTransform(ClassGenerator classGen)

Compile transform() into the output class.

public void
public void
display(int indent)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.display.

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

private void
extensionURI(String prefixes, SymbolTable stable)

Store extension URIs

public List<Template>
public String
public int
public Output
public int
getMinimumDescendantPrecedence()

Get the minimum of the precedence of this stylesheet, any stylesheet imported by this stylesheet and any include/import descendant of this stylesheet.

public Mode
getMode(QName modeName)

public String
public int
getOutputMethod()

Return the output method

public Properties
public Stylesheet
public SourceLoader
public String
public boolean
public List<Template>
public boolean
hasGlobals()

Returns true if this stylesheet has global vars or params.

public boolean
hasLocalParams()

Returns true if at least one template in the stylesheet has params defined.

public boolean
public boolean
public boolean
private QName
public void
public void
parseContents(Parser parser)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.parseContents.

Parse the version and uri fields of the stylesheet and add an entry to the symbol table mapping the name __stylesheet_ to an instance of this class.

public final void
parseOwnChildren(Parser parser)

Parse all direct children of the <xsl:stylesheet/> element.

private void
peepHoleOptimization(MethodGenerator methodGen)

Peephole optimization: Remove sequences of [ALOAD, POP].

public void
private List<SyntaxTreeNode>
resolveDependencies(List<SyntaxTreeNode> input)

This method returns a vector with variables/params and keys in the order in which they are to be compiled for initialization.

public void
setCallsNodeset(boolean flag)

public void
setHasIdCall(boolean flag)

public void
public void
setImportPrecedence(final int precedence)

public void
public void
setMultiDocument(boolean flag)

public void
public void
public void
public void
public void
public void
public void
setSystemId(String systemId)

public void
setTemplateInlining(boolean flag)

public void
translate(ClassGenerator classGen, MethodGenerator methodGen)

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.translate.

Translate the stylesheet into JVM bytecodes.

public void
translate()

Translate the stylesheet into JVM bytecodes.

public Type
typeCheck(SymbolTable stable)

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheck.

Type check all the children of this node.

Inherited from com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode:
addAttributeaddElementcompileResultTreecontextDependentdependentContentsdisplayContentselementAtelementCountelementsgetAttributegetAttributegetAttributesgetContentsgetLineNumbergetParentgetParsergetPrefixMappinggetQNamegetStylesheetgetSymbolTablegetTemplategetXSLTChasAttributehasContentsindentisDummylastChildlookupNamespacelookupPrefixnotTypeOfparseChildrenremoveElementreportErrorreportWarningsetAttributessetFirstElementsetLineNumbersetParentsetPrefixMappingsetQNamesetQNametranslateContentstypeCheckContentsupdateScope

Field Detail

_allValidTemplatesback to summary
private List<Template> _allValidTemplates

Used to cache result of getAllValidTemplates(). Only set in top-level stylesheets that include/import other stylesheets.

_callsNodesetback to summary
private boolean _callsNodeset

Flag indicating if nodset() is called.

_classNameback to summary
private String _className

The name of the class being generated.

_defaultModeback to summary
private Mode _defaultMode

A reference to the default Mode object.

_extensionsback to summary
private final Map<String, String> _extensions

Mapping between extension URIs and their prefixes.

_globalsback to summary
private List<VariableBase> _globals

Contains global variables and parameters defined in the stylesheet.

_hasIdCallback to summary
private boolean _hasIdCall

Flag indicating if id() is called.

_hasLocalParamsback to summary
private Boolean _hasLocalParams

Used to cache the result returned by hasLocalParams().

_importedFromback to summary
public Stylesheet _importedFrom

Reference to the stylesheet from which this stylesheet was imported (if any).

_importPrecedenceback to summary
private int _importPrecedence

Import precendence for this stylesheet.

_includedFromback to summary
public Stylesheet _includedFrom

Reference to the stylesheet from which this stylesheet was included (if any).

_includedStylesheetsback to summary
private List<Stylesheet> _includedStylesheets

Array of all the stylesheets imported or included from this one.

_keysback to summary
private Map<String, Key> _keys

Mapping between key names and Key objects (needed by Key/IdPattern).

_lastOutputElementback to summary
private Output _lastOutputElement

A reference to the last xsl:output object found in the styleshet.

_loaderback to summary
private SourceLoader _loader

A reference to the SourceLoader set by the user (a URIResolver if the JAXP API is being used).

_minimumDescendantPrecedenceback to summary
private int _minimumDescendantPrecedence

Minimum precendence of any descendant stylesheet by inclusion or importation.

_modesback to summary
private final Map<String, Mode> _modes

Mapping between mode names and Mode instances.

_multiDocumentback to summary
private boolean _multiDocument

Flag indicating if multi-document support is needed.

_nameback to summary
private QName _name

Internal name of this stylesheet used as a key into the symbol table.

_nextModeSerialback to summary
private int _nextModeSerial

Counter to generate unique mode suffixes.

_numberFormattingUsedback to summary
private boolean _numberFormattingUsed

Flag indicating if format-number() is called.

_outputMethodback to summary
private int _outputMethod

Output method for this stylesheet (must be set to one of the constants defined below).

_outputPropertiesback to summary
private Properties _outputProperties

Output properties for this stylesheet.

_parentStylesheetback to summary
private Stylesheet _parentStylesheet

A reference to the parent stylesheet or null if topmost.

_simplifiedback to summary
private boolean _simplified

Flag indicating if this is a simplified stylesheets. A template matching on "/" must be added in this case.

_systemIdback to summary
private String _systemId

A URI that represents the system ID for this stylesheet.

_templateInliningback to summary
private boolean _templateInlining

Set to true to enable template inlining optimization.

See Also
XSLTC#_templateInlining
_templatesback to summary
private final List<Template> _templates

Contains all templates defined in this stylesheet

_versionback to summary
private String _version

XSLT version defined in the stylesheet.

HTML_OUTPUTback to summary
public static final int HTML_OUTPUT
TEXT_OUTPUTback to summary
public static final int TEXT_OUTPUT
UNKNOWN_OUTPUTback to summary
public static final int UNKNOWN_OUTPUT
XML_OUTPUTback to summary
public static final int XML_OUTPUT

Constructor Detail

Stylesheetback to summary
public Stylesheet()

Method Detail

addDOMFieldback to summary
private void addDOMField(ClassGenerator classGen)
addIncludedStylesheetback to summary
public void addIncludedStylesheet(Stylesheet child)
addParamback to summary
public int addParam(Param param)
addPrefixMappingback to summary
protected void addPrefixMapping(String prefix, String uri)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.addPrefixMapping.

Adds a single prefix mapping to this syntax tree node.

Parameters
prefix:String

Namespace prefix.

uri:String

Namespace URI.

addStaticFieldback to summary
private void addStaticField(ClassGenerator classGen, String type, String name)

Add a static field

addTemplateback to summary
protected void addTemplate(Template template)
addVariableback to summary
public int addVariable(Variable global)
callsNodesetback to summary
public boolean callsNodeset()
checkForLoopback to summary
public boolean checkForLoop(String systemId)
checkOutputMethodback to summary
private void checkOutputMethod()

Check and set the output method

compileBuildKeysback to summary
private String compileBuildKeys(ClassGenerator classGen)

Compile a buildKeys() method into the output class. Note that keys for the input document are created in topLevel(), not in this method. However, we still need this method to create keys for documents loaded via the XPath document() function.

compileConstructorback to summary
private void compileConstructor(ClassGenerator classGen, Output output)

Compile the translet's constructor

compileModesback to summary
private void compileModes(ClassGenerator classGen)
compileStaticInitializerback to summary
private void compileStaticInitializer(ClassGenerator classGen)

Compile the namesArray, urisArray and typesArray into the static initializer. They are read-only from the translet. All translet instances can share a single copy of this informtion.

compileTopLevelback to summary
private String compileTopLevel(ClassGenerator classGen)

Compile a topLevel() method into the output class. This method is called from transform() to handle all non-template top-level elements. Returns the signature of the topLevel() method. Global variables/params and keys are first sorted to resolve dependencies between them. The XSLT 1.0 spec does not allow a key to depend on a variable. However, for compatibility with Xalan interpretive, that type of dependency is allowed. Note also that the buildKeys() method is still generated as it is used by the LoadDocument class, but it no longer called from transform().

compileTransformback to summary
private void compileTransform(ClassGenerator classGen)

Compile transform() into the output class. This method is used to initialize global variables and global parameters. The current node is set to be the document's root node.

declareExtensionPrefixesback to summary
public void declareExtensionPrefixes(Parser parser)
displayback to summary
public void display(int indent)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.display.

Doc from com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.display.

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.

extensionURIback to summary
private void extensionURI(String prefixes, SymbolTable stable)

Store extension URIs

getAllValidTemplatesback to summary
public List<Template> getAllValidTemplates()
getClassNameback to summary
public String getClassName()
getImportPrecedenceback to summary
public int getImportPrecedence()

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.getImportPrecedence.

Doc from com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.getImportPrecedence.

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

getLastOutputElementback to summary
public Output getLastOutputElement()
getMinimumDescendantPrecedenceback to summary
public int getMinimumDescendantPrecedence()

Get the minimum of the precedence of this stylesheet, any stylesheet imported by this stylesheet and any include/import descendant of this stylesheet.

getModeback to summary
public Mode getMode(QName modeName)
getNamespaceback to summary
public String getNamespace(String prefix)
getOutputMethodback to summary
public int getOutputMethod()

Return the output method

getOutputPropertiesback to summary
public Properties getOutputProperties()
getParentStylesheetback to summary
public Stylesheet getParentStylesheet()
getSourceLoaderback to summary
public SourceLoader getSourceLoader()
getSystemIdback to summary
public String getSystemId()
getTemplateInliningback to summary
public boolean getTemplateInlining()
getTemplatesback to summary
public List<Template> getTemplates()
hasGlobalsback to summary
public boolean hasGlobals()

Returns true if this stylesheet has global vars or params.

hasLocalParamsback to summary
public boolean hasLocalParams()

Returns true if at least one template in the stylesheet has params defined. Uses the variable _hasLocalParams to cache the result.

isExtensionback to summary
public boolean isExtension(String uri)
isMultiDocumentback to summary
public boolean isMultiDocument()
isSimplifiedback to summary
public boolean isSimplified()
makeStylesheetNameback to summary
private QName makeStylesheetName(String prefix)
numberFormattingUsedback to summary
public void numberFormattingUsed()
parseContentsback to summary
public void parseContents(Parser parser)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.parseContents.

Parse the version and uri fields of the stylesheet and add an entry to the symbol table mapping the name __stylesheet_ to an instance of this class.

parseOwnChildrenback to summary
public final void parseOwnChildren(Parser parser)

Parse all direct children of the <xsl:stylesheet/> element.

peepHoleOptimizationback to summary
private void peepHoleOptimization(MethodGenerator methodGen)

Peephole optimization: Remove sequences of [ALOAD, POP].

processModesback to summary
public void processModes()
resolveDependenciesback to summary
private List<SyntaxTreeNode> resolveDependencies(List<SyntaxTreeNode> input)

This method returns a vector with variables/params and keys in the order in which they are to be compiled for initialization. The order is determined by analyzing the dependencies between them. The XSLT 1.0 spec does not allow a key to depend on a variable. However, for compatibility with Xalan interpretive, that type of dependency is allowed and, therefore, consider to determine the partial order.

setCallsNodesetback to summary
public void setCallsNodeset(boolean flag)
setHasIdCallback to summary
public void setHasIdCall(boolean flag)
setImportingStylesheetback to summary
public void setImportingStylesheet(Stylesheet parent)
setImportPrecedenceback to summary
public void setImportPrecedence(final int precedence)
setIncludingStylesheetback to summary
public void setIncludingStylesheet(Stylesheet parent)
setMultiDocumentback to summary
public void setMultiDocument(boolean flag)
setOutputPropertiesback to summary
public void setOutputProperties(Properties props)
setOutputPropertyback to summary
public void setOutputProperty(String key, String value)
setParentStylesheetback to summary
public void setParentStylesheet(Stylesheet parent)
setParserback to summary
public void setParser(Parser parser)

Overrides com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.setParser.

Doc from com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.setParser.

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

setSimplifiedback to summary
public void setSimplified()
setSourceLoaderback to summary
public void setSourceLoader(SourceLoader loader)
setSystemIdback to summary
public void setSystemId(String systemId)
setTemplateInliningback to summary
public void setTemplateInlining(boolean flag)
translateback to summary
public void translate(ClassGenerator classGen, MethodGenerator methodGen)

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.translate.

Translate the stylesheet into JVM bytecodes.

translateback to summary
public void translate()

Translate the stylesheet into JVM bytecodes.

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

Implements abstract com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheck.

Type check all the children of this node.