|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.xsltc.compiler.SyntaxTreeNode org.apache.xalan.xsltc.compiler.Stylesheet
public final class Stylesheet
Field Summary | |
---|---|
private java.util.Vector |
_allValidTemplates
Used to cache result of getAllValidTemplates() . |
private boolean |
_callsNodeset
Flag indicating if nodset() is called. |
private java.lang.String |
_className
The name of the class being generated. |
private Mode |
_defaultMode
A reference to the default Mode object. |
private java.util.Vector |
_elementsWithNamespacesUsedDynamically
|
private java.util.Hashtable |
_extensions
Mapping between extension URIs and their prefixes. |
private java.util.Vector |
_globals
Contains global variables and parameters defined in the stylesheet. |
private boolean |
_hasIdCall
Flag indicating if id() is called. |
private java.lang.Boolean |
_hasLocalParams
Used to cache the result returned by hasLocalParams() . |
Stylesheet |
_importedFrom
Reference to the stylesheet from which this stylesheet was imported (if any). |
private int |
_importPrecedence
Import precendence for this stylesheet. |
Stylesheet |
_includedFrom
Reference to the stylesheet from which this stylesheet was included (if any). |
private java.util.Vector |
_includedStylesheets
Array of all the stylesheets imported or included from this one. |
private java.util.Hashtable |
_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 java.util.Hashtable |
_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 java.util.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 java.lang.String |
_systemId
A URI that represents the system ID for this stylesheet. |
private boolean |
_templateInlining
Set to true to enable template inlining optimization. |
private java.util.Vector |
_templates
Contains all templates defined in this stylesheet |
private java.lang.String |
_version
XSLT version defined in the stylesheet. |
static int |
HTML_OUTPUT
|
static int |
TEXT_OUTPUT
|
static int |
UNKNOWN_OUTPUT
|
static int |
XML_OUTPUT
|
Fields inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode |
---|
_attributes, _parent, _qname, Dummy, IndentIncrement, UNKNOWN_STYLESHEET_NODE_ID |
Constructor Summary | |
---|---|
Stylesheet()
|
Method Summary | |
---|---|
private void |
addDOMField(ClassGenerator classGen)
|
void |
addIncludedStylesheet(Stylesheet child)
|
int |
addParam(Param param)
|
protected void |
addPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Adds a single prefix mapping to this syntax tree node. |
private void |
addStaticField(ClassGenerator classGen,
java.lang.String type,
java.lang.String name)
Add a static field |
protected void |
addTemplate(Template template)
|
int |
addVariable(Variable global)
|
boolean |
callsNodeset()
|
boolean |
checkForLoop(java.lang.String systemId)
|
private void |
checkOutputMethod()
Check and set the output method |
private java.lang.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 |
compileModes(ClassGenerator classGen)
|
private void |
compileStaticInitializer(ClassGenerator classGen)
Compile the namesArray, urisArray, typesArray, namespaceArray, namespaceAncestorsArray, prefixURIsIdxArray and prefixURIPairsArray into the static initializer. |
private java.lang.String |
compileTopLevel(ClassGenerator classGen)
Compile a topLevel() method into the output class. |
private void |
compileTransform(ClassGenerator classGen)
Compile transform() into the output class. |
void |
declareExtensionPrefixes(Parser parser)
|
void |
display(int indent)
Displays the contents of this syntax tree node (to stdout). |
private void |
extensionURI(java.lang.String prefixes,
SymbolTable stable)
Store extension URIs |
java.util.Vector |
getAllValidTemplates()
|
java.lang.String |
getClassName()
|
int |
getImportPrecedence()
Get the import precedence of this element. |
Output |
getLastOutputElement()
|
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. |
Mode |
getMode(QName modeName)
|
java.lang.String |
getNamespace(java.lang.String prefix)
|
int |
getOutputMethod()
Return the output method |
java.util.Properties |
getOutputProperties()
|
Stylesheet |
getParentStylesheet()
|
SourceLoader |
getSourceLoader()
|
java.lang.String |
getSystemId()
|
boolean |
getTemplateInlining()
|
java.util.Vector |
getTemplates()
|
boolean |
hasGlobals()
Returns true if this stylesheet has global vars or params. |
boolean |
hasLocalParams()
Returns true if at least one template in the stylesheet has params defined. |
boolean |
isExtension(java.lang.String uri)
|
boolean |
isMultiDocument()
|
boolean |
isSimplified()
|
private QName |
makeStylesheetName(java.lang.String prefix)
|
void |
numberFormattingUsed()
|
void |
parseContents(Parser parser)
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. |
void |
parseOwnChildren(Parser parser)
Parse all direct children of the |
private void |
peepHoleOptimization(MethodGenerator methodGen)
Peephole optimization: Remove sequences of [ALOAD, POP]. |
void |
processModes()
|
private java.util.Vector |
resolveDependencies(java.util.Vector input)
This method returns a vector with variables/params and keys in the order in which they are to be compiled for initialization. |
void |
setCallsNodeset(boolean flag)
|
void |
setHasIdCall(boolean flag)
|
void |
setImportingStylesheet(Stylesheet parent)
|
void |
setImportPrecedence(int precedence)
|
void |
setIncludingStylesheet(Stylesheet parent)
|
void |
setMultiDocument(boolean flag)
|
void |
setOutputProperties(java.util.Properties props)
|
void |
setOutputProperty(java.lang.String key,
java.lang.String value)
|
void |
setParentStylesheet(Stylesheet parent)
|
void |
setParser(Parser parser)
Set this node's parser. |
void |
setSimplified()
|
void |
setSourceLoader(SourceLoader loader)
|
void |
setSystemId(java.lang.String systemId)
|
void |
setTemplateInlining(boolean flag)
|
void |
translate()
Translate the stylesheet into JVM bytecodes. |
void |
translate(ClassGenerator classGen,
MethodGenerator methodGen)
Translate the stylesheet into JVM bytecodes. |
Type |
typeCheck(SymbolTable stable)
Type check all the children of this node. |
Methods inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode |
---|
addAttribute, addElement, compileResultTree, contextDependent, dependentContents, displayContents, elementAt, elementCount, elements, getAttribute, getAttribute, getAttributes, getContents, getLineNumber, getNodeIDForStylesheetNSLookup, getParent, getParser, getPrefixMapping, getQName, getStylesheet, getSymbolTable, getTemplate, getXSLTC, hasAttribute, hasContents, indent, isDummy, lastChild, lookupNamespace, lookupPrefix, parseChildren, removeElement, reportError, reportWarning, setAttributes, setFirstElement, setLineNumber, setParent, setPrefixMapping, setQName, setQName, translateContents, typeCheckContents, updateScope |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String _version
private QName _name
private java.lang.String _systemId
private Stylesheet _parentStylesheet
private java.util.Vector _globals
private java.lang.Boolean _hasLocalParams
hasLocalParams()
.
private java.lang.String _className
private final java.util.Vector _templates
private java.util.Vector _allValidTemplates
getAllValidTemplates()
. Only
set in top-level stylesheets that include/import other stylesheets.
private java.util.Vector _elementsWithNamespacesUsedDynamically
private int _nextModeSerial
private final java.util.Hashtable _modes
private Mode _defaultMode
private final java.util.Hashtable _extensions
public Stylesheet _importedFrom
public Stylesheet _includedFrom
private java.util.Vector _includedStylesheets
private int _importPrecedence
private int _minimumDescendantPrecedence
private java.util.Hashtable _keys
private SourceLoader _loader
private boolean _numberFormattingUsed
private boolean _simplified
private boolean _multiDocument
private boolean _callsNodeset
private boolean _hasIdCall
private boolean _templateInlining
XSLTC._templateInlining
private Output _lastOutputElement
private java.util.Properties _outputProperties
private int _outputMethod
public static final int UNKNOWN_OUTPUT
public static final int XML_OUTPUT
public static final int HTML_OUTPUT
public static final int TEXT_OUTPUT
Constructor Detail |
---|
public Stylesheet()
Method Detail |
---|
public int getOutputMethod()
private void checkOutputMethod()
public boolean getTemplateInlining()
public void setTemplateInlining(boolean flag)
public boolean isSimplified()
public void setSimplified()
public void setHasIdCall(boolean flag)
public void setOutputProperty(java.lang.String key, java.lang.String value)
public void setOutputProperties(java.util.Properties props)
public java.util.Properties getOutputProperties()
public Output getLastOutputElement()
public void setMultiDocument(boolean flag)
public boolean isMultiDocument()
public void setCallsNodeset(boolean flag)
public boolean callsNodeset()
public void numberFormattingUsed()
public void setImportPrecedence(int precedence)
public int getImportPrecedence()
SyntaxTreeNode
getImportPrecedence
in class SyntaxTreeNode
public int getMinimumDescendantPrecedence()
public boolean checkForLoop(java.lang.String systemId)
public void setParser(Parser parser)
SyntaxTreeNode
setParser
in class SyntaxTreeNode
parser
- The XSLT parser.public void setParentStylesheet(Stylesheet parent)
public Stylesheet getParentStylesheet()
public void setImportingStylesheet(Stylesheet parent)
public void setIncludingStylesheet(Stylesheet parent)
public void addIncludedStylesheet(Stylesheet child)
public void setSystemId(java.lang.String systemId)
public java.lang.String getSystemId()
public void setSourceLoader(SourceLoader loader)
public SourceLoader getSourceLoader()
private QName makeStylesheetName(java.lang.String prefix)
public boolean hasGlobals()
public boolean hasLocalParams()
_hasLocalParams
to cache the
result.
protected void addPrefixMapping(java.lang.String prefix, java.lang.String uri)
addPrefixMapping
in class SyntaxTreeNode
prefix
- Namespace prefix.uri
- Namespace URI.private void extensionURI(java.lang.String prefixes, SymbolTable stable)
public boolean isExtension(java.lang.String uri)
public void declareExtensionPrefixes(Parser parser)
public void parseContents(Parser parser)
parseContents
in class SyntaxTreeNode
parser
- reference to the XSLT parserpublic final void parseOwnChildren(Parser parser)
public void processModes()
private void compileModes(ClassGenerator classGen)
public Mode getMode(QName modeName)
public Type typeCheck(SymbolTable stable) throws TypeCheckError
typeCheck
in class SyntaxTreeNode
stable
- The compiler/parser's symbol table
TypeCheckError
public void translate(ClassGenerator classGen, MethodGenerator methodGen)
translate
in class SyntaxTreeNode
classGen
- BCEL Java class generatormethodGen
- BCEL Java method generatorprivate void addDOMField(ClassGenerator classGen)
private void addStaticField(ClassGenerator classGen, java.lang.String type, java.lang.String name)
public void translate()
private void compileStaticInitializer(ClassGenerator classGen)
Compile the namesArray, urisArray, typesArray, namespaceArray, namespaceAncestorsArray, prefixURIsIdxArray and prefixURIPairsArray into the static initializer. They are read-only from the translet. All translet instances can share a single copy of this informtion.
The namespaceAncestorsArray
,
prefixURIsIdxArray
and prefixURIPairsArray
contain namespace information accessible from the stylesheet:
namespaceAncestorsArray
-1
if there is no such ancestor. There
can be more than one disjoint tree of nodes - one for each stylesheet
moduleprefixURIsIdxArray
prefixURIPairsArray
of the first namespace prefix
declared for the node. The values are stored in ascending order, so
the next value in this array (if any) can be used to find the last such
prefix-URI pairFor this stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="*" xmlns:foo="foouri">
<xsl:element name="{n}" xmlns:foo="baruri">
</xsl:for-each>
<out xmlns="lumpit"/>
<xsl:element name="{n}" xmlns="foouri"/>
<xsl:element name="{n}" namespace="{ns}" xmlns="limpit"/gt;
</xsl:template>
</xsl:stylesheet>
there will be four stylesheet nodes whose namespace information is
needed, and
namespaceAncestorsArray
will have the value
[-1,0,1,0]
;prefixURIsIdxArray
will have the value
[0,4,6,8]
; andprefixURIPairsArray
will have the value
["xml","http://www.w3.org/XML/1998/namespace",
"xsl","http://www.w3.org/1999/XSL/Transform"
"foo","foouri","foo","baruri","","foouri"].
private void compileConstructor(ClassGenerator classGen, Output output)
private java.lang.String compileTopLevel(ClassGenerator classGen)
private java.util.Vector resolveDependencies(java.util.Vector input)
private java.lang.String compileBuildKeys(ClassGenerator classGen)
private void compileTransform(ClassGenerator classGen)
private void peepHoleOptimization(MethodGenerator methodGen)
public int addParam(Param param)
public int addVariable(Variable global)
public void display(int indent)
SyntaxTreeNode
display
in class SyntaxTreeNode
indent
- Indentation level for syntax tree levels.public java.lang.String getNamespace(java.lang.String prefix)
public java.lang.String getClassName()
public java.util.Vector getTemplates()
public java.util.Vector getAllValidTemplates()
protected void addTemplate(Template template)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |