1 16 19 package org.apache.xalan.templates; 20 21 import java.util.Vector ; 22 23 import javax.xml.transform.TransformerException ; 24 25 44 public class StylesheetComposed extends Stylesheet 45 { 46 47 51 public StylesheetComposed(Stylesheet parent) 52 { 53 super(parent); 54 } 55 56 62 public boolean isAggregatedType() 63 { 64 return true; 65 } 66 67 74 public void recompose(Vector recomposableElements) throws TransformerException 75 { 76 77 80 82 int n = getIncludeCountComposed(); 83 84 for (int i = -1; i < n; i++) 85 { 86 Stylesheet included = getIncludeComposed(i); 87 88 90 int s = included.getOutputCount(); 91 for (int j = 0; j < s; j++) 92 { 93 recomposableElements.addElement(included.getOutput(j)); 94 } 95 96 98 s = included.getAttributeSetCount(); 99 for (int j = 0; j < s; j++) 100 { 101 recomposableElements.addElement(included.getAttributeSet(j)); 102 } 103 104 106 s = included.getDecimalFormatCount(); 107 for (int j = 0; j < s; j++) 108 { 109 recomposableElements.addElement(included.getDecimalFormat(j)); 110 } 111 112 114 s = included.getKeyCount(); 115 for (int j = 0; j < s; j++) 116 { 117 recomposableElements.addElement(included.getKey(j)); 118 } 119 120 122 s = included.getNamespaceAliasCount(); 123 for (int j = 0; j < s; j++) 124 { 125 recomposableElements.addElement(included.getNamespaceAlias(j)); 126 } 127 128 130 s = included.getTemplateCount(); 131 for (int j = 0; j < s; j++) 132 { 133 recomposableElements.addElement(included.getTemplate(j)); 134 } 135 136 138 s = included.getVariableOrParamCount(); 139 for (int j = 0; j < s; j++) 140 { 141 recomposableElements.addElement(included.getVariableOrParam(j)); 142 } 143 144 146 s = included.getStripSpaceCount(); 147 for (int j = 0; j < s; j++) 148 { 149 recomposableElements.addElement(included.getStripSpace(j)); 150 } 151 152 s = included.getPreserveSpaceCount(); 153 for (int j = 0; j < s; j++) 154 { 155 recomposableElements.addElement(included.getPreserveSpace(j)); 156 } 157 } 158 } 159 160 162 private int m_importNumber = -1; 163 164 169 private int m_importCountComposed; 170 171 172 private int m_endImportCountComposed; 173 174 179 void recomposeImports() 180 { 181 182 m_importNumber = getStylesheetRoot().getImportNumber(this); 183 184 StylesheetRoot root = getStylesheetRoot(); 185 int globalImportCount = root.getGlobalImportCount(); 186 187 m_importCountComposed = (globalImportCount - m_importNumber) - 1; 188 189 int count = getImportCount(); 191 if ( count > 0) 192 { 193 m_endImportCountComposed += count; 194 while (count > 0) 195 m_endImportCountComposed += this.getImport(--count).getEndImportCountComposed(); 196 } 197 198 count = getIncludeCountComposed(); 201 while (count>0) 202 { 203 int imports = getIncludeComposed(--count).getImportCount(); 204 m_endImportCountComposed += imports; 205 while (imports > 0) 206 m_endImportCountComposed +=getIncludeComposed(count).getImport(--imports).getEndImportCountComposed(); 207 208 } 209 } 210 211 221 public StylesheetComposed getImportComposed(int i) 222 throws ArrayIndexOutOfBoundsException 223 { 224 225 StylesheetRoot root = getStylesheetRoot(); 226 227 return root.getGlobalImport(1 + m_importNumber + i); 232 } 233 234 241 public int getImportCountComposed() 242 { 243 return m_importCountComposed; 244 } 245 246 251 public int getEndImportCountComposed() 252 { 253 return m_endImportCountComposed; 254 } 255 256 257 261 private transient Vector m_includesComposed; 262 263 269 void recomposeIncludes(Stylesheet including) 270 { 271 272 int n = including.getIncludeCount(); 273 274 if (n > 0) 275 { 276 if (null == m_includesComposed) 277 m_includesComposed = new Vector (); 278 279 for (int i = 0; i < n; i++) 280 { 281 Stylesheet included = including.getInclude(i); 282 m_includesComposed.addElement(included); 283 recomposeIncludes(included); 284 } 285 } 286 } 287 288 298 public Stylesheet getIncludeComposed(int i) 299 throws ArrayIndexOutOfBoundsException 300 { 301 302 if (-1 == i) 303 return this; 304 305 if (null == m_includesComposed) 306 throw new ArrayIndexOutOfBoundsException (); 307 308 return (Stylesheet) m_includesComposed.elementAt(i); 309 } 310 311 317 public int getIncludeCountComposed() 318 { 319 return (null != m_includesComposed) ? m_includesComposed.size() : 0; 320 } 321 322 337 public void recomposeTemplates(boolean flushFirst) throws TransformerException 338 { 339 345 } 346 } 347 | Popular Tags |