137
138 private boolean _useServicesMechanism = true;
139
140 /**
141 * protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
142 */
143 private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
144 /**
145 * protocols allowed for external DTD references in source file and/or stylesheet.
146 */
147 private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
148
149 private XMLSecurityManager _xmlSecurityManager;
150
151 private final JdkXmlFeatures _xmlFeatures;
152
153 /**
154 * Extension function class loader variables
155 */
156
157 /* Class loader reference that will be used to external extension functions loading */
158 private ClassLoader _extensionClassLoader;
159
160 /**
161 * HashSet with the loaded classes
162 */
163 private final Map<String, Class> _externalExtensionFunctions;
164
165 /**
166 * Catalog features
167 */
168 CatalogFeatures _catalogFeatures;
169
170 /**
171 * XSLTC compiler constructor
172 */
173 public XSLTC(boolean useServicesMechanism, JdkXmlFeatures featureManager) {
174 _parser = new Parser(this, useServicesMechanism);
175 _xmlFeatures = featureManager;
176 _extensionClassLoader = null;
177 _externalExtensionFunctions = new HashMap<>();
178 }
179
180 /**
181 * Set the state of the secure processing feature.
278 return _parser.getOutputProperties();
279 }
280
281 /**
282 * Initializes the compiler to compile a new stylesheet
283 */
284 public void init() {
285 reset();
286 _reader = null;
287 _classes = new Vector();
288 _bcelClasses = new Vector();
289 }
290
291 private void setExternalExtensionFunctions(String name, Class clazz) {
292 if (_isSecureProcessing && clazz != null && !_externalExtensionFunctions.containsKey(name)) {
293 _externalExtensionFunctions.put(name, clazz);
294 }
295 }
296
297 /*
298 * Function loads an external external extension functions.
299 * The filtering of function types (external,internal) takes place in FunctionCall class
300 *
301 */
302 Class loadExternalFunction(String name) throws ClassNotFoundException {
303 Class loaded = null;
304 //Check if the function is not loaded already
305 if (_externalExtensionFunctions.containsKey(name)) {
306 loaded = _externalExtensionFunctions.get(name);
307 } else if (_extensionClassLoader != null) {
308 loaded = Class.forName(name, true, _extensionClassLoader);
309 setExternalExtensionFunctions(name, loaded);
310 }
311 if (loaded == null) {
312 throw new ClassNotFoundException(name);
313 }
314 //Return loaded class
315 return (Class) loaded;
316 }
317
318 /*
|
137
138 private boolean _useServicesMechanism = true;
139
140 /**
141 * protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
142 */
143 private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
144 /**
145 * protocols allowed for external DTD references in source file and/or stylesheet.
146 */
147 private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
148
149 private XMLSecurityManager _xmlSecurityManager;
150
151 private final JdkXmlFeatures _xmlFeatures;
152
153 /**
154 * Extension function class loader variables
155 */
156
157 /* Class loader reference that will be used for external extension functions loading */
158 private ClassLoader _extensionClassLoader;
159
160 /**
161 * HashMap with the loaded classes
162 */
163 private final Map<String, Class> _externalExtensionFunctions;
164
165 /**
166 * Catalog features
167 */
168 CatalogFeatures _catalogFeatures;
169
170 /**
171 * XSLTC compiler constructor
172 */
173 public XSLTC(boolean useServicesMechanism, JdkXmlFeatures featureManager) {
174 _parser = new Parser(this, useServicesMechanism);
175 _xmlFeatures = featureManager;
176 _extensionClassLoader = null;
177 _externalExtensionFunctions = new HashMap<>();
178 }
179
180 /**
181 * Set the state of the secure processing feature.
278 return _parser.getOutputProperties();
279 }
280
281 /**
282 * Initializes the compiler to compile a new stylesheet
283 */
284 public void init() {
285 reset();
286 _reader = null;
287 _classes = new Vector();
288 _bcelClasses = new Vector();
289 }
290
291 private void setExternalExtensionFunctions(String name, Class clazz) {
292 if (_isSecureProcessing && clazz != null && !_externalExtensionFunctions.containsKey(name)) {
293 _externalExtensionFunctions.put(name, clazz);
294 }
295 }
296
297 /*
298 * Function loads an external extension function.
299 * The filtering of function types (external,internal) takes place in FunctionCall class
300 *
301 */
302 Class loadExternalFunction(String name) throws ClassNotFoundException {
303 Class loaded = null;
304 //Check if the function is not loaded already
305 if (_externalExtensionFunctions.containsKey(name)) {
306 loaded = _externalExtensionFunctions.get(name);
307 } else if (_extensionClassLoader != null) {
308 loaded = Class.forName(name, true, _extensionClassLoader);
309 setExternalExtensionFunctions(name, loaded);
310 }
311 if (loaded == null) {
312 throw new ClassNotFoundException(name);
313 }
314 //Return loaded class
315 return (Class) loaded;
316 }
317
318 /*
|