aboutsummaryrefslogtreecommitdiff
path: root/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java')
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
index 46866fd..b37c8f4 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -27,12 +27,12 @@ import com.sun.org.apache.xalan.internal.XalanConstants;
import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
import com.sun.org.apache.xalan.internal.utils.FeatureManager;
import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase;
+import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.State;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
-import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.State;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
@@ -49,7 +49,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.Map;
import java.util.Properties;
import java.util.Vector;
import java.util.zip.ZipEntry;
@@ -57,7 +57,6 @@ import java.util.zip.ZipFile;
import javax.xml.XMLConstants;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
@@ -73,7 +72,8 @@ import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stax.*;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.InputSource;
@@ -146,13 +146,13 @@ public class TransformerFactoryImpl
private String _jarFileName = null;
/**
- * This Hashtable is used to store parameters for locating
+ * This Map is used to store parameters for locating
* <?xml-stylesheet ...?> processing instructions in XML docs.
*/
- private Hashtable _piParams = null;
+ private Map<Source, PIParamWrapper> _piParams = null;
/**
- * The above hashtable stores objects of this class.
+ * The above Map stores objects of this class.
*/
private static class PIParamWrapper {
public String _media = null;
@@ -231,6 +231,13 @@ public class TransformerFactoryImpl
private final FeatureManager _featureManager;
+ private ClassLoader _extensionClassLoader = null;
+
+ // Unmodifiable view of external extension function from xslt compiler
+ // It will be populated by user-specified extension functions during the
+ // type checking
+ private Map<String, Class> _xsltcExtensionFunctions;
+
/**
* javax.xml.transform.sax.TransformerFactory implementation.
*/
@@ -261,6 +268,12 @@ public class TransformerFactoryImpl
//Parser's security manager
_xmlSecurityManager = new XMLSecurityManager(true);
+ //Unmodifiable hash map with loaded external extension functions
+ _xsltcExtensionFunctions = null;
+ }
+
+ public Map<String,Class> getExternalExtensionsMap() {
+ return _xsltcExtensionFunctions;
}
/**
@@ -324,6 +337,8 @@ public class TransformerFactoryImpl
return Boolean.FALSE;
} else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
return _xmlSecurityManager;
+ } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
+ return _extensionClassLoader;
}
/** Check to see if the property is managed by the security manager **/
@@ -439,6 +454,16 @@ public class TransformerFactoryImpl
return;
}
}
+ else if ( name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
+ if (value instanceof ClassLoader) {
+ _extensionClassLoader = (ClassLoader) value;
+ return;
+ } else {
+ final ErrorMsg err
+ = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_VALUE_ERR, "Extension Functions ClassLoader");
+ throw new IllegalArgumentException(err.toString());
+ }
+ }
if (_xmlSecurityManager != null &&
_xmlSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
@@ -881,7 +906,6 @@ public class TransformerFactoryImpl
// Reset the per-session attributes to their default values
// after each newTemplates() call.
resetTransientAttributes();
-
return new TemplatesImpl(bytecodes, transletClassName, null, _indentNumber, this);
}
}
@@ -898,8 +922,10 @@ public class TransformerFactoryImpl
xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, _accessExternalStylesheet);
xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
xsltc.setProperty(XalanConstants.SECURITY_MANAGER, _xmlSecurityManager);
+ xsltc.setProperty(XalanConstants.JDK_EXTENSION_CLASSLOADER, _extensionClassLoader);
xsltc.init();
-
+ if (!_isNotSecureProcessing)
+ _xsltcExtensionFunctions = xsltc.getExternalExtensionFunctions();
// Set a document loader (for xsl:include/import) if defined
if (_uriResolver != null) {
xsltc.setSourceLoader(this);
@@ -909,7 +935,7 @@ public class TransformerFactoryImpl
// <?xml-stylesheet ...?> PI in an XML input document
if ((_piParams != null) && (_piParams.get(source) != null)) {
// Get the parameters for this Source object
- PIParamWrapper p = (PIParamWrapper)_piParams.get(source);
+ PIParamWrapper p = _piParams.get(source);
// Pass them on to the compiler (which will pass then to the parser)
if (p != null) {
xsltc.setPIParameters(p._media, p._title, p._charset);