286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2001-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * @author Jacek Ambroziak 286N/A * @author Santiago Pericas-Geertsen 286N/A * @author Morten Jorgensen 286N/A * XSLT version defined in the stylesheet. 286N/A * Internal name of this stylesheet used as a key into the symbol table. 286N/A * A URI that represents the system ID for this stylesheet. 286N/A * A reference to the parent stylesheet or null if topmost. 286N/A * Contains global variables and parameters defined in the stylesheet. 286N/A * Used to cache the result returned by <code>hasLocalParams()</code>. 286N/A * The name of the class being generated. 286N/A * Contains all templates defined in this stylesheet 286N/A * Used to cache result of <code>getAllValidTemplates()</code>. Only 286N/A * Counter to generate unique mode suffixes. 286N/A * Mapping between mode names and Mode instances. 286N/A * A reference to the default Mode object. 286N/A * Mapping between extension URIs and their prefixes. 286N/A * Reference to the stylesheet from which this stylesheet was 286N/A * Reference to the stylesheet from which this stylesheet was 286N/A * Array of all the stylesheets imported or included from this one. 286N/A * Import precendence for this stylesheet. 286N/A * Minimum precendence of any descendant stylesheet by inclusion or 286N/A * A reference to the SourceLoader set by the user (a URIResolver 286N/A * if the JAXP API is being used). 286N/A * Flag indicating if format-number() is called. 286N/A * Flag indicating if this is a simplified stylesheets. A template 286N/A * matching on "/" must be added in this case. 286N/A * Flag indicating if multi-document support is needed. 286N/A * Flag indicating if nodset() is called. 286N/A * Flag indicating if id() is called. 286N/A * Set to true to enable template inlining optimization. 286N/A * @see XSLTC#_templateInlining 286N/A * A reference to the last xsl:output object found in the styleshet. 286N/A * Output properties for this stylesheet. 286N/A * Output method for this stylesheet (must be set to one of 286N/A * the constants defined below). 286N/A // Output method constants 286N/A * Return the output method 286N/A * Check and set the output method 286N/A * Fix for bug 23046, if the stylesheet is included, set the 286N/A * numberFormattingUsed flag to the parent stylesheet too. 286N/A * AbstractTranslet.addDecimalFormat() will be inlined once for the 286N/A * outer most stylesheet. 286N/A // Set import precedence for this stylesheet 286N/A // Set import precedence for all included stylesheets 286N/A // Set import precedence for the stylesheet that imported this one 286N/A // Set import precedence for the stylesheet that included this one 286N/A * Get the minimum of the precedence of this stylesheet, any stylesheet 286N/A // Start with precedence of current stylesheet as a basis. 286N/A * Returns true if this stylesheet has global vars or params. 286N/A * Returns true if at least one template in the stylesheet has params 286N/A * defined. Uses the variable <code>_hasLocalParams</code> to cache the 286N/A for (
int i =
0; i < n; i++) {
286N/A * Adds a single prefix mapping to this syntax tree node. 286N/A * @param prefix Namespace prefix. 286N/A * @param uri Namespace URI. 286N/A * Parse the version and uri fields of the stylesheet and add an 286N/A * entry to the symbol table mapping the name <tt>__stylesheet_</tt> 286N/A * to an instance of this class. 286N/A // Make sure the XSL version set in this stylesheet 286N/A if ((_version == null) || (_version.equals(EMPTYSTRING))) { 286N/A reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR,"version"); 286N/A // Verify that the version is 1.0 and nothing else 286N/A else if (!_version.equals("1.0")) { 286N/A reportError(this, parser, ErrorMsg.XSL_VERSION_ERR, _version); 286N/A // Add the implicit mapping of 'xml' to the XML namespace URI 286N/A // Report and error if more than one stylesheet defined 286N/A // Error: more that one stylesheet defined 286N/A // If this is a simplified stylesheet we must create a template that 286N/A // grabs the root node of the input doc ( <xsl:template match="/"/> ). 286N/A // This template needs the current element (the one passed to this 286N/A // method) as its only child, so the Template class has a special 286N/A // method that handles this (parseSimplified()). 286N/A // Parse the children of this node 286N/A * Parse all direct children of the <xsl:stylesheet/> element. 286N/A // We have to scan the stylesheet element's top-level elements for 286N/A // variables and/or parameters before we parse the other elements 286N/A // Now go through all the other top-level elements... 286N/A // All template code should be compiled as methods if the 286N/A // <xsl:apply-imports/> element was ever used in this stylesheet 286N/A * Type check all the children of this node. 286N/A * Translate the stylesheet into JVM bytecodes. 286N/A * Translate the stylesheet into JVM bytecodes. 286N/A // Define a new class by extending TRANSLET_CLASS 286N/A // Compile transform() to initialize parameters, globals & output 286N/A // and run the transformation 286N/A // Translate all non-template elements and filter out all templates 286N/A // Separate templates by modes 286N/A //_templates.addElement(template); 286N/A // save the element for later to pass to compileConstructor 286N/A // Global variables and parameters are handled elsewhere. 286N/A // Other top-level non-template elements are ignored. Literal 286N/A // elements outside of templates will never be output. 293N/A * Compile the namesArray, urisArray and typesArray into 286N/A * the static initializer. They are read-only from the 286N/A * translet. All translet instances can share a single 293N/A * copy of this informtion. 286N/A // Create fields of type char[] that will contain literal text from 286N/A // Put the namespace names array into the translet 286N/A // Grab all the literal text in the stylesheet and put it in a char[] 286N/A * Compile the translet's constructor 286N/A // Call the constructor in the AbstractTranslet superclass 286N/A // Compile in code to set the output configuration from <xsl:output> 286N/A // Set all the output settings files in the translet 286N/A // Compile default decimal formatting symbols. 286N/A // This is an implicit, nameless xsl:decimal-format top-level element. 286N/A * Compile a topLevel() method into the output class. This method is 286N/A * called from transform() to handle all non-template top-level elements. 286N/A * Returns the signature of the topLevel() method. 286N/A * dependencies between them. The XSLT 1.0 spec does not allow a key 286N/A * to depend on a variable. However, for compatibility with Xalan 286N/A * interpretive, that type of dependency is allowed. Note also that 286N/A * the buildKeys() method is still generated as it is used by the 286N/A * LoadDocument class, but it no longer called from transform(). 286N/A // Define and initialize 'current' variable with the root node 286N/A // Compile code for other top-level elements 286N/A // Compute max locals + stack and add method to class 286N/A * order in which they are to be compiled for initialization. The order 286N/A * is determined by analyzing the dependencies between them. The XSLT 1.0 286N/A * spec does not allow a key to depend on a variable. However, for 286N/A * compatibility with Xalan interpretive, that type of dependency is 286N/A * allowed and, therefore, consider to determine the partial order. 286N/A for (int i = 0; i < input.size(); i++) { 286N/A final TopLevelElement e = (TopLevelElement) input.elementAt(i); 286N/A System.out.println("e = " + e + " depends on:"); 286N/A Vector dep = e.getDependencies(); 286N/A for (int j = 0; j < (dep != null ? dep.size() : 0); j++) { 286N/A System.out.println("\t" + dep.elementAt(j)); 286N/A System.out.println("================================="); 286N/A // If nothing was changed in this pass then we have a circular ref 286N/A System.out.println("================================="); 286N/A for (int i = 0; i < result.size(); i++) { 286N/A final TopLevelElement e = (TopLevelElement) result.elementAt(i); 286N/A System.out.println("e = " + e); 286N/A * Compile a buildKeys() method into the output class. Note that keys 286N/A * for the input document are created in topLevel(), not in this method. 286N/A * However, we still need this method to create keys for documents loaded 286N/A * via the XPath document() function. 286N/A // Compute max locals + stack and add method to class 286N/A * Compile transform() into the output class. This method is used to 286N/A * initialize global variables and global parameters. The current node 286N/A * is set to be the document's root node. 286N/A * Define the the method transform with the following signature: 286N/A * void transform(DOM, NodeIterator, HandlerBase) 286N/A // Define and initialize current with the root node 286N/A // push translet for PUTFIELD 286N/A // prepare appropriate DOM implementation 286N/A // DOMAdapter is on the stack 286N/A // MultiDOM is on the stack 286N/A //store to _dom variable 286N/A // continue with globals initialization 286N/A // Transfer the output settings to the output post-processor 286N/A "transferOutputSettings",
286N/A * Compile buildKeys() method. Note that this method is not 286N/A * invoked here as keys for the input document are now created 286N/A * in topLevel(). However, this method is still needed by the 286N/A // Look for top-level elements that need handling 286N/A // Compile method for handling top-level elements 286N/A // Get a reference to that method 286N/A // Push all parameters on the stack and call topLevel() 286N/A // push first arg for applyTemplates 286N/A // push translet for GETFIELD to get DOM arg 286N/A // push remaining 2 args 286N/A // Compute max locals + stack and add method to class 286N/A * Peephole optimization: Remove sequences of [ALOAD, POP]. 286N/A // TODO: move target down into the list 286N/A // do we need this wrapper ????? 286N/A // Is returned value cached? 286N/A //templates.addAll(_templates); 286N/A // Cache results in top-level stylesheet only