19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: StylesheetComposed.java 468643 2006-10-28 06:56:03Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.templates; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Vector; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.TransformerException; 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Represents a stylesheet that has methods that resolve includes and 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * imports. It has methods on it that 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * return "composed" properties, which mean that: 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <ol> 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>Properties that are aggregates, like OutputProperties, will 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * be composed of properties declared in this stylsheet and all 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * included stylesheets.</li> 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>Properties that aren't found, will be searched for first in 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the includes, and, if none are located, will be searched for in 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the imports.</li> 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>Properties in that are not atomic on a stylesheet will 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * have the form getXXXComposed. Some properties, like version and id, 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * are not inherited, and so won't have getXXXComposed methods.</li> 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </ol> 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>In some cases getXXXComposed methods may calculate the composed 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * values dynamically, while in other cases they may store the composed 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * values.</p> 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class StylesheetComposed extends Stylesheet 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final long serialVersionUID = -3444072247410233923L; 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Uses an XSL stylesheet document. 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param parent The including or importing stylesheet. 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public StylesheetComposed(Stylesheet parent) 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson super(parent); 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Tell if this can be cast to a StylesheetComposed, meaning, you 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * can ask questions from getXXXComposed functions. 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return True since this is a StylesheetComposed 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public boolean isAggregatedType() 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return true; 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Adds all recomposable values for this precedence level into the recomposableElements Vector 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * that was passed in as the first parameter. All elements added to the 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * recomposableElements vector should extend ElemTemplateElement. 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param recomposableElements a Vector of ElemTemplateElement objects that we will add all of 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * our recomposable objects to. 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void recompose(Vector recomposableElements) throws TransformerException 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson //recomposeImports(); // Calculate the number of this import. 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson //recomposeIncludes(this); // Build the global include list for this stylesheet. 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Now add in all of the recomposable elements at this precedence level 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int n = getIncludeCountComposed(); 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = -1; i < n; i++) 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Stylesheet included = getIncludeComposed(i); 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Add in the output elements 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int s = included.getOutputCount(); 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getOutput(j)); 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Next, add in the attribute-set elements 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getAttributeSetCount(); 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getAttributeSet(j)); 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Now the decimal-formats 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getDecimalFormatCount(); 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getDecimalFormat(j)); 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Now the keys 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getKeyCount(); 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getKey(j)); 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // And the namespace aliases 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getNamespaceAliasCount(); 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getNamespaceAlias(j)); 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Next comes the templates 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getTemplateCount(); 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getTemplate(j)); 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Then, the variables 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getVariableOrParamCount(); 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getVariableOrParam(j)); 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // And lastly the whitespace preserving and stripping elements 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getStripSpaceCount(); 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getStripSpace(j)); 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson s = included.getPreserveSpaceCount(); 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int j = 0; j < s; j++) 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposableElements.addElement(included.getPreserveSpace(j)); 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** Order in import chain. 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial */ 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int m_importNumber = -1; 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** The precedence of this stylesheet in the global import list. 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The lowest precedence stylesheet is 0. A higher 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * number has a higher precedence. 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int m_importCountComposed; 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /* The count of imports composed for this stylesheet */ 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int m_endImportCountComposed; 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Recalculate the precedence of this stylesheet in the global 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * import list. The lowest precedence stylesheet is 0. A higher 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * number has a higher precedence. 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void recomposeImports() 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_importNumber = getStylesheetRoot().getImportNumber(this); 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetRoot root = getStylesheetRoot(); 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int globalImportCount = root.getGlobalImportCount(); 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_importCountComposed = (globalImportCount - m_importNumber) - 1; 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Now get the count of composed imports from this stylesheet's imports 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int count = getImportCount(); 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ( count > 0) 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_endImportCountComposed += count; 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson while (count > 0) 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_endImportCountComposed += this.getImport(--count).getEndImportCountComposed(); 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Now get the count of composed imports from this stylesheet's 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // composed includes. 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson count = getIncludeCountComposed(); 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson while (count>0) 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int imports = getIncludeComposed(--count).getImportCount(); 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_endImportCountComposed += imports; 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson while (imports > 0) 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_endImportCountComposed +=getIncludeComposed(count).getImport(--imports).getEndImportCountComposed(); 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get a stylesheet from the "import" list. 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#import">import in XSLT Specification</a> 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param i Index of stylesheet in import list 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The stylesheet at the given index 2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws ArrayIndexOutOfBoundsException 2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public StylesheetComposed getImportComposed(int i) 2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws ArrayIndexOutOfBoundsException 2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetRoot root = getStylesheetRoot(); 2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Get the stylesheet that is offset past this stylesheet. 2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Thus, if the index of this stylesheet is 3, an argument 2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // to getImportComposed of 0 will return the 4th stylesheet 2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // in the global import list. 2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return root.getGlobalImport(1 + m_importNumber + i); 2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the precedence of this stylesheet in the global import list. 2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The lowest precedence is 0. A higher number has a higher precedence. 2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#import">import in XSLT Specification</a> 2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the precedence of this stylesheet in the global import list. 2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getImportCountComposed() 2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_importCountComposed; 2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the number of import in this stylesheet's composed list. 2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the number of imports in this stylesheet's composed list. 2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getEndImportCountComposed() 2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_endImportCountComposed; 2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The combined list of includes. 2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private transient Vector m_includesComposed; 2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Recompose the value of the composed include list. Builds a composite 2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * list of all stylesheets included by this stylesheet to any depth. 2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param including Stylesheet to recompose 2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void recomposeIncludes(Stylesheet including) 2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int n = including.getIncludeCount(); 2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (n > 0) 2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null == m_includesComposed) 2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_includesComposed = new Vector(); 2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < n; i++) 2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Stylesheet included = including.getInclude(i); 2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_includesComposed.addElement(included); 2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposeIncludes(included); 2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get an "xsl:include" property. 2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#include">include in XSLT Specification</a> 2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param i Index of stylesheet in "include" list 2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The stylesheet at the given index in the "include" list 2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws ArrayIndexOutOfBoundsException 3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Stylesheet getIncludeComposed(int i) 3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws ArrayIndexOutOfBoundsException 3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (-1 == i) 3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return this; 3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null == m_includesComposed) 3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new ArrayIndexOutOfBoundsException(); 3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return (Stylesheet) m_includesComposed.elementAt(i); 3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the number of included stylesheets. 3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#import">import in XSLT Specification</a> 3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the number of included stylesheets. 3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getIncludeCountComposed() 3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return (null != m_includesComposed) ? m_includesComposed.size() : 0; 3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * For compilation support, we need the option of overwriting 3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (rather than appending to) previous composition. 3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * We could phase out the old API in favor of this one, but I'm 3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * holding off until we've made up our minds about compilation. 3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * ADDED 9/5/2000 to support compilation experiment. 3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * NOTE: GLP 29-Nov-00 I've left this method in so that CompilingStylesheetHandler will compile. However, 3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * I'm not sure why it's needed or what it does and I've commented out the body. 3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#section-Defining-Template-Rules">section-Defining-Template-Rules in XSLT Specification</a> 3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param flushFirst Flag indicating the option of overwriting 3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (rather than appending to) previous composition. 3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws TransformerException 3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void recomposeTemplates(boolean flushFirst) throws TransformerException 3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*************************************** KEEP METHOD IN FOR COMPILATION 3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (flushFirst) 3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_templateList = new TemplateList(this); 3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson recomposeTemplates(); 3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson*****************************************/ 3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 350