src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58022 12885822f0c5
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
55742
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
     2
 * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
/*
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
     5
 * Licensed to the Apache Software Foundation (ASF) under one or more
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
     6
 * contributor license agreements.  See the NOTICE file distributed with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
     7
 * this work for additional information regarding copyright ownership.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
     8
 * The ASF licenses this file to You under the Apache License, Version 2.0
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
     9
 * (the "License"); you may not use this file except in compliance with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
    10
 * the License.  You may obtain a copy of the License at
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 *     http://www.apache.org/licenses/LICENSE-2.0
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * limitations under the License.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
package com.sun.org.apache.xalan.internal.xsltc.trax;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    23
import com.sun.org.apache.xalan.internal.XalanConstants;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
    24
import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    25
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
    26
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    27
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
    28
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    29
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    30
import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    31
import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    32
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    33
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    34
import com.sun.org.apache.xml.internal.utils.StopParseException;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    35
import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    36
import java.io.File;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    37
import java.io.FileInputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
import java.io.FileNotFoundException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
import java.io.FilenameFilter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
import java.io.IOException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
import java.io.InputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
import java.net.MalformedURLException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
import java.net.URL;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    44
import java.util.ArrayList;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
import java.util.Enumeration;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
    46
import java.util.List;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
    47
import java.util.Map;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
import java.util.Properties;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
import java.util.zip.ZipEntry;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
import java.util.zip.ZipFile;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
import javax.xml.XMLConstants;
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
    52
import javax.xml.catalog.CatalogException;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    53
import javax.xml.catalog.CatalogFeatures.Feature;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    54
import javax.xml.catalog.CatalogFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    55
import javax.xml.catalog.CatalogManager;
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
    56
import javax.xml.catalog.CatalogResolver;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
import javax.xml.transform.ErrorListener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    58
import javax.xml.transform.Source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
import javax.xml.transform.Templates;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    60
import javax.xml.transform.Transformer;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
import javax.xml.transform.TransformerConfigurationException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
import javax.xml.transform.TransformerException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    63
import javax.xml.transform.URIResolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
import javax.xml.transform.dom.DOMResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    65
import javax.xml.transform.dom.DOMSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    66
import javax.xml.transform.sax.SAXResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
import javax.xml.transform.sax.SAXSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
import javax.xml.transform.sax.SAXTransformerFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
import javax.xml.transform.sax.TemplatesHandler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
import javax.xml.transform.sax.TransformerHandler;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    71
import javax.xml.transform.stax.*;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
import javax.xml.transform.stream.StreamResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
import javax.xml.transform.stream.StreamSource;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    74
import jdk.xml.internal.JdkXmlFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    75
import jdk.xml.internal.JdkXmlUtils;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    76
import jdk.xml.internal.SecuritySupport;
58022
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
    77
import jdk.xml.internal.TransformErrorListener;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
import org.xml.sax.InputSource;
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
    79
import org.xml.sax.SAXException;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
import org.xml.sax.XMLFilter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
import org.xml.sax.XMLReader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
/**
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
    84
 * Implementation of a JAXP TransformerFactory for Translets.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
 * @author G. Todd Miller
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
 * @author Morten Jorgensen
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
 * @author Santiago Pericas-Geertsen
58022
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
    88
 * @LastModified: Aug 2019
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
public class TransformerFactoryImpl
58022
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
    91
    extends SAXTransformerFactory implements SourceLoader
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    92
{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
    // Public constants for attributes supported by the XSLTC TransformerFactory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
    public final static String TRANSLET_NAME = "translet-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
    public final static String DESTINATION_DIRECTORY = "destination-directory";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    96
    public final static String PACKAGE_NAME = "package-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    97
    public final static String JAR_NAME = "jar-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
    public final static String GENERATE_TRANSLET = "generate-translet";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    public final static String AUTO_TRANSLET = "auto-translet";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
    public final static String USE_CLASSPATH = "use-classpath";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
    public final static String DEBUG = "debug";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
    public final static String ENABLE_INLINING = "enable-inlining";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
    public final static String INDENT_NUMBER = "indent-number";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
    /**
58022
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   106
     * Default error listener
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   107
     */
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   108
    private final ErrorListener _defaultListener = new TransformErrorListener();
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   109
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   110
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
     * This error listener is used only for this factory and is not passed to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
     * the Templates or Transformer objects that we create.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
     */
58022
12885822f0c5 8228854: Default ErrorListener reports warnings and errors to the console
joehw
parents: 55742
diff changeset
   114
    private ErrorListener _errorListener = _defaultListener;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
55742
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
   116
    // flag indicating whether there's an user's ErrorListener
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
   117
    private boolean _hasUserErrListener;
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
   118
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
     * This URIResolver is passed to all created Templates and Transformers
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
    private URIResolver _uriResolver = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
     * As Gregor Samsa awoke one morning from uneasy dreams he found himself
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
     * transformed in his bed into a gigantic insect. He was lying on his hard,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
     * as it were armour plated, back, and if he lifted his head a little he
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
     * could see his big, brown belly divided into stiff, arched segments, on
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
     * top of which the bed quilt could hardly keep in position and was about
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
     * to slide off completely. His numerous legs, which were pitifully thin
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
     * compared to the rest of his bulk, waved helplessly before his eyes.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   132
     * "What has happened to me?", he thought. It was no dream....
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   134
    protected final static String DEFAULT_TRANSLET_NAME = "GregorSamsa";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   135
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   136
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
     * The class name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
    private String _transletName = DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
     * The destination directory for the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   143
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
    private String _destinationDirectory = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   146
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
     * The package name prefix for all generated translet classes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
     */
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   149
    private static final String DEFAULT_TRANSLATE_PACKAGE = "die.verwandlung";
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   150
    private String _packageName = DEFAULT_TRANSLATE_PACKAGE;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
     * The jar file name which the translet classes are packaged into
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
    private String _jarFileName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   158
     * This Map is used to store parameters for locating
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     * <?xml-stylesheet ...?> processing instructions in XML docs.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
     */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   161
    private Map<Source, PIParamWrapper> _piParams = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   164
     * The above Map stores objects of this class.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
    private static class PIParamWrapper {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
        public String _media = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
        public String _title = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
        public String _charset = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
        public PIParamWrapper(String media, String title, String charset) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
            _media = media;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
            _title = title;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
            _charset = charset;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
     * Set to <code>true</code> when debugging is enabled.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
    private boolean _debug = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
     * Set to <code>true</code> when templates are inlined.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
    private boolean _enableInlining = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
     * Set to <code>true</code> when we want to generate
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
     * translet classes from the stylesheet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
    private boolean _generateTranslet = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
     * If this is set to <code>true</code>, we attempt to use translet classes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
     * for transformation if possible without compiling the stylesheet. The
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
     * translet class is only used if its timestamp is newer than the timestamp
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
     * of the stylesheet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
    private boolean _autoTranslet = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   201
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   203
     * If this is set to <code>true</code>, we attempt to load the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
     * from the CLASSPATH.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
    private boolean _useClasspath = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
     * Number of indent spaces when indentation is turned on.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    private int _indentNumber = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
     * <p>State of secure processing feature.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
    private boolean _isNotSecureProcessing = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   217
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
     * <p>State of secure mode.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   219
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   220
    private boolean _isSecureMode = false;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   221
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   222
    /**
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   223
     * Indicates whether 3rd party parser may be used to override the system-default
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   224
     * Note the default value (false) is the safe option.
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   225
     * Note same as the old property useServicesMechanism
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   226
     */
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   227
    private boolean _overrideDefaultParser;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   228
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   229
    /**
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   230
     * protocols allowed for external references set by the stylesheet
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   231
     * processing instruction, Import and Include element.
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   232
     */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   233
    private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   234
     /**
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   235
     * protocols allowed for external DTD references in source file and/or stylesheet.
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   236
     */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   237
    private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   238
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   239
    private XMLSecurityPropertyManager _xmlSecurityPropertyMgr;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   240
    private XMLSecurityManager _xmlSecurityManager;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   241
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   242
    private final JdkXmlFeatures _xmlFeatures;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   243
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   244
    private ClassLoader _extensionClassLoader = null;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   245
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   246
    // Unmodifiable view of external extension function from xslt compiler
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   247
    // It will be populated by user-specified extension functions during the
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   248
    // type checking
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   249
    private Map<String, Class<?>> _xsltcExtensionFunctions;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   250
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
   251
    CatalogResolver _catalogUriResolver;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   252
    CatalogFeatures _catalogFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   253
    CatalogFeatures.Builder cfBuilder = CatalogFeatures.builder();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   254
    // Catalog features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   255
    String _catalogFiles = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   256
    String _catalogDefer = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   257
    String _catalogPrefer = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   258
    String _catalogResolve = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   259
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   260
    int _cdataChunkSize = JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT;
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   261
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   262
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   263
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   264
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   265
    public TransformerFactoryImpl() {
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   266
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   267
        if (System.getSecurityManager() != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   268
            _isSecureMode = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   269
            _isNotSecureProcessing = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   270
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   271
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   272
        _xmlFeatures = new JdkXmlFeatures(!_isNotSecureProcessing);
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   273
        _overrideDefaultParser = _xmlFeatures.getFeature(
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   274
                JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   275
        _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   276
        _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   277
                Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   278
        _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   279
                Property.ACCESS_EXTERNAL_STYLESHEET);
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   280
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   281
        //Parser's security manager
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   282
        _xmlSecurityManager = new XMLSecurityManager(true);
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   283
        //Unmodifiable hash map with loaded external extension functions
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   284
        _xsltcExtensionFunctions = null;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   285
    }
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   286
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   287
    public Map<String, Class<?>> getExternalExtensionsMap() {
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   288
        return _xsltcExtensionFunctions;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   290
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
     * Set the error event listener for the TransformerFactory, which is used
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
     * for the processing of transformation instructions, and not for the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
     * transformation itself.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
     * @param listener The error listener to use with the TransformerFactory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   298
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   300
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   301
    public void setErrorListener(ErrorListener listener)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
        if (listener == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
            ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
                                        "TransformerFactory");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   307
            throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
        }
55742
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
   309
        _hasUserErrListener = true;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
        _errorListener = listener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   311
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   312
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   313
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   314
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
     * Get the error event handler for the TransformerFactory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   316
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
     * @return The error listener used with the TransformerFactory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   319
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
    public ErrorListener getErrorListener() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
        return _errorListener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   323
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
    /**
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   325
     * Returns the package name.
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   326
     */
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   327
    String getPackageName() {
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   328
        return _packageName;
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   329
    }
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   330
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   331
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
     * Returns the value set for a TransformerFactory attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   334
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   335
     * @param name The attribute name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   336
     * @return An object representing the attribute value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   337
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   338
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   339
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   340
    public Object getAttribute(String name)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   341
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   342
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   343
        // Return value for attribute 'translet-name'
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   344
        if (name.equals(TRANSLET_NAME)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   345
            return _transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   346
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   347
        else if (name.equals(GENERATE_TRANSLET)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   348
            return _generateTranslet;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   349
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   350
        else if (name.equals(AUTO_TRANSLET)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   351
            return _autoTranslet;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   352
        }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   353
        else if (name.equals(ENABLE_INLINING)) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   354
            if (_enableInlining)
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   355
              return Boolean.TRUE;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   356
            else
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   357
              return Boolean.FALSE;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   358
        } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   359
            return _xmlSecurityManager;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   360
        } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   361
           return _extensionClassLoader;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   362
        } else if (JdkXmlUtils.CATALOG_FILES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   363
            return _catalogFiles;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   364
        } else if (JdkXmlUtils.CATALOG_DEFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   365
            return _catalogDefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   366
        } else if (JdkXmlUtils.CATALOG_PREFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   367
            return _catalogPrefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   368
        } else if (JdkXmlUtils.CATALOG_RESOLVE.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   369
            return _catalogResolve;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   370
        } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   371
            return buildCatalogFeatures();
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   372
        } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   373
            return _cdataChunkSize;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   374
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   375
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   376
        /** Check to see if the property is managed by the security manager **/
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   377
        String propertyValue = (_xmlSecurityManager != null) ?
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   378
                _xmlSecurityManager.getLimitAsString(name) : null;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   379
        if (propertyValue != null) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   380
            return propertyValue;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   381
        } else {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   382
            propertyValue = (_xmlSecurityPropertyMgr != null) ?
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   383
                _xmlSecurityPropertyMgr.getValue(name) : null;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   384
            if (propertyValue != null) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   385
                return propertyValue;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   386
            }
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   387
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   388
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   389
        // Throw an exception for all other attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   390
        ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   391
        throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   392
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   393
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   394
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   395
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   396
     * Sets the value for a TransformerFactory attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   397
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   398
     * @param name The attribute name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
     * @param value An object representing the attribute value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   400
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   401
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   402
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   403
    public void setAttribute(String name, Object value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   404
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   405
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   406
        // Set the default translet name (ie. class name), which will be used
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   407
        // for translets that cannot be given a name from their system-id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   408
        if (name.equals(TRANSLET_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   409
            _transletName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   410
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   411
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   412
        else if (name.equals(DESTINATION_DIRECTORY) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   413
            _destinationDirectory = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   414
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   415
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   416
        else if (name.equals(PACKAGE_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   417
            _packageName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   418
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   419
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   420
        else if (name.equals(JAR_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   421
            _jarFileName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   422
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   423
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   424
        else if (name.equals(GENERATE_TRANSLET)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   425
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   426
                _generateTranslet = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   427
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   428
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   429
            else if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   430
                _generateTranslet = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   431
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   432
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   433
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   434
        else if (name.equals(AUTO_TRANSLET)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   435
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   436
                _autoTranslet = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   437
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   438
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   439
            else if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   440
                _autoTranslet = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   441
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   442
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   443
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   444
        else if (name.equals(USE_CLASSPATH)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   445
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   446
                _useClasspath = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   447
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   448
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   449
            else if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
                _useClasspath = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   451
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   452
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   453
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   454
        else if (name.equals(DEBUG)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   455
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   456
                _debug = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   457
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   458
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   459
            else if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   460
                _debug = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   461
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   462
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   463
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   464
        else if (name.equals(ENABLE_INLINING)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   465
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   466
                _enableInlining = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   467
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   468
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   469
            else if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   470
                _enableInlining = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   471
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   472
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   473
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   474
        else if (name.equals(INDENT_NUMBER)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   475
            if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   476
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   477
                    _indentNumber = Integer.parseInt((String) value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   478
                    return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   479
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   480
                catch (NumberFormatException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   481
                    // Falls through
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   482
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   483
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   484
            else if (value instanceof Integer) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   485
                _indentNumber = ((Integer) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   486
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   487
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   488
        }
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   489
        else if ( name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   490
            if (value instanceof ClassLoader) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   491
                _extensionClassLoader = (ClassLoader) value;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   492
                return;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   493
            } else {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   494
                final ErrorMsg err
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   495
                    = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_VALUE_ERR, "Extension Functions ClassLoader");
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   496
                throw new IllegalArgumentException(err.toString());
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   497
            }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   498
        } else if (JdkXmlUtils.CATALOG_FILES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   499
            _catalogFiles = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   500
            cfBuilder = CatalogFeatures.builder().with(Feature.FILES, _catalogFiles);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   501
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   502
        } else if (JdkXmlUtils.CATALOG_DEFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   503
            _catalogDefer = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   504
            cfBuilder = CatalogFeatures.builder().with(Feature.DEFER, _catalogDefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   505
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   506
        } else if (JdkXmlUtils.CATALOG_PREFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   507
            _catalogPrefer = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   508
            cfBuilder = CatalogFeatures.builder().with(Feature.PREFER, _catalogPrefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   509
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   510
        } else if (JdkXmlUtils.CATALOG_RESOLVE.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   511
            _catalogResolve = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   512
            cfBuilder = CatalogFeatures.builder().with(Feature.RESOLVE, _catalogResolve);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   513
            return;
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   514
        } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   515
            _cdataChunkSize = JdkXmlUtils.getValue(value, _cdataChunkSize);
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   516
            return;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   517
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   518
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   519
        if (_xmlSecurityManager != null &&
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   520
                _xmlSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   521
            return;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   522
        }
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   523
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   524
        if (_xmlSecurityPropertyMgr != null &&
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   525
            _xmlSecurityPropertyMgr.setValue(name, XMLSecurityPropertyManager.State.APIPROPERTY, value)) {
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   526
            _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   527
                    Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   528
            _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   529
                    Property.ACCESS_EXTERNAL_STYLESHEET);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   530
            return;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   531
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   532
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   533
        // Throw an exception for all other attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   534
        final ErrorMsg err
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   535
            = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
        throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   537
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   539
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   540
     * <p>Set a feature for this <code>TransformerFactory</code> and <code>Transformer</code>s
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   541
     * or <code>Template</code>s created by this factory.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   542
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   543
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   544
     * Feature names are fully qualified {@link java.net.URI}s.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   545
     * Implementations may define their own features.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   546
     * An {@link TransformerConfigurationException} is thrown if this <code>TransformerFactory</code> or the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   547
     * <code>Transformer</code>s or <code>Template</code>s it creates cannot support the feature.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   548
     * It is possible for an <code>TransformerFactory</code> to expose a feature value but be unable to change its state.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   549
     * </p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   550
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   551
     * <p>See {@link javax.xml.transform.TransformerFactory} for full documentation of specific features.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   552
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   553
     * @param name Feature name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   554
     * @param value Is feature state <code>true</code> or <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   555
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   556
     * @throws TransformerConfigurationException if this <code>TransformerFactory</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   557
     *   or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   558
     * @throws NullPointerException If the <code>name</code> parameter is null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   559
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   560
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   561
    public void setFeature(String name, boolean value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   562
        throws TransformerConfigurationException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   563
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   564
        // feature name cannot be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   565
        if (name == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   566
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SET_FEATURE_NULL_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   567
            throw new NullPointerException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   568
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   569
        // secure processing?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   570
        else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   571
            if ((_isSecureMode) && (!value)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   572
                ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SECUREPROCESSING_FEATURE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   573
                throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   574
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   575
            _isNotSecureProcessing = !value;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   576
            _xmlSecurityManager.setSecureProcessing(value);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   577
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   578
            // set external access restriction when FSP is explicitly set
34463
c269a10aca11 8132091: Clean up JAXP code that has dependency on Java version string
joehw
parents: 33349
diff changeset
   579
            if (value) {
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   580
                _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   581
                        FeaturePropertyBase.State.FSP, XalanConstants.EXTERNAL_ACCESS_DEFAULT_FSP);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   582
                _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_STYLESHEET,
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   583
                        FeaturePropertyBase.State.FSP, XalanConstants.EXTERNAL_ACCESS_DEFAULT_FSP);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   584
                _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   585
                        Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   586
                _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   587
                        Property.ACCESS_EXTERNAL_STYLESHEET);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   588
            }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   589
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   590
            if (value && _xmlFeatures != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   591
                _xmlFeatures.setFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION,
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   592
                        JdkXmlFeatures.State.FSP, false);
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   593
            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   594
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   595
        else {
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   596
            if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   597
                // for compatibility, in secure mode, useServicesMechanism is determined by the constructor
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   598
                if (_isSecureMode) {
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   599
                    return;
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   600
                }
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   601
            }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   602
            if (_xmlFeatures != null &&
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   603
                    _xmlFeatures.setFeature(name, JdkXmlFeatures.State.APIPROPERTY, value)) {
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   604
                if (name.equals(JdkXmlUtils.OVERRIDE_PARSER) ||
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   605
                        name.equals(JdkXmlFeatures.ORACLE_FEATURE_SERVICE_MECHANISM)) {
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   606
                    _overrideDefaultParser = _xmlFeatures.getFeature(
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   607
                            JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER);
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   608
                }
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   609
                return;
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   610
            }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   611
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
            // unknown feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   613
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   614
            throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   615
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   616
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   617
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   618
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   619
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   620
     * Look up the value of a feature (to see if it is supported).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   621
     * This method must be updated as the various methods and features of this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   622
     * class are implemented.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   623
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   624
     * @param name The feature name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   625
     * @return 'true' if feature is supported, 'false' if not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   626
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   627
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
    public boolean getFeature(String name) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
        // All supported features should be listed here
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
        String[] features = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
            DOMSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
            DOMResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
            SAXSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   634
            SAXResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   635
            StAXSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   636
            StAXResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   637
            StreamSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   638
            StreamResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   639
            SAXTransformerFactory.FEATURE,
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   640
            SAXTransformerFactory.FEATURE_XMLFILTER,
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   641
            XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   642
        };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   643
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   644
        // feature name cannot be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   645
        if (name == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   646
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_GET_FEATURE_NULL_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   647
            throw new NullPointerException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   648
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   649
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   650
        // Inefficient, but array is small
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
   651
        for (int i =0; i < features.length; i++) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   652
            if (name.equals(features[i])) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   656
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   657
        if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   658
            return !_isNotSecureProcessing;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   659
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   660
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   661
        /** Check to see if the property is managed by the JdkXmlFeatues **/
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   662
        int index = _xmlFeatures.getIndex(name);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   663
        if (index > -1) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   664
            return _xmlFeatures.getFeature(index);
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   665
        }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   666
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   667
        // Feature not supported
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   668
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   669
    }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   670
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   671
     * Return the state of the services mechanism feature.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   672
     */
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   673
    public boolean overrideDefaultParser() {
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   674
        return _overrideDefaultParser;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   675
    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   676
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   677
     /**
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   678
     * @return the feature manager
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   679
     */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   680
    public JdkXmlFeatures getJdkXmlFeatures() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   681
        return _xmlFeatures;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   682
    }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   683
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   684
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   685
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   686
     * Get the object that is used by default during the transformation to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   687
     * resolve URIs used in document(), xsl:import, or xsl:include.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   688
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   689
     * @return The URLResolver used for this TransformerFactory and all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   690
     * Templates and Transformer objects created using this factory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   691
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   692
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   693
    public URIResolver getURIResolver() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   694
        return _uriResolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   695
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   696
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   697
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   698
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   699
     * Set the object that is used by default during the transformation to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   700
     * resolve URIs used in document(), xsl:import, or xsl:include. Note that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   701
     * this does not affect Templates and Transformers that are already
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   702
     * created with this factory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   703
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   704
     * @param resolver The URLResolver used for this TransformerFactory and all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   705
     * Templates and Transformer objects created using this factory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   706
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   707
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   708
    public void setURIResolver(URIResolver resolver) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   709
        _uriResolver = resolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   710
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   711
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   712
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   713
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   714
     * Get the stylesheet specification(s) associated via the xml-stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   715
     * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   716
     * the document document specified in the source parameter, and that match
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   717
     * the given criteria.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   718
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   719
     * @param source The XML source document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   720
     * @param media The media attribute to be matched. May be null, in which
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   721
     * case the prefered templates will be used (i.e. alternate = no).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   722
     * @param title The value of the title attribute to match. May be null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   723
     * @param charset The value of the charset attribute to match. May be null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   724
     * @return A Source object suitable for passing to the TransformerFactory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   725
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   726
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   727
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   728
    public Source  getAssociatedStylesheet(Source source, String media,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   729
                                          String title, String charset)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   730
        throws TransformerConfigurationException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   731
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   732
        String baseId;
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   733
        XMLReader reader = null;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   734
        InputSource isource;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   735
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   736
        /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   737
         * Fix for bugzilla bug 24187
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   738
         */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   739
        StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   740
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   742
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   743
            if (source instanceof DOMSource ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   744
                final DOMSource domsrc = (DOMSource) source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   745
                baseId = domsrc.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
                final org.w3c.dom.Node node = domsrc.getNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   747
                final DOM2SAX dom2sax = new DOM2SAX(node);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   748
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   749
                _stylesheetPIHandler.setBaseId(baseId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   750
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   751
                dom2sax.setContentHandler( _stylesheetPIHandler);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   752
                dom2sax.parse();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
            } else {
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   754
                if (source instanceof SAXSource) {
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   755
                    reader = ((SAXSource)source).getXMLReader();
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   756
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   757
                isource = SAXSource.sourceToInputSource(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
                baseId = isource.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   759
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   760
                if (reader == null) {
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   761
                    reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser,
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   762
                            !_isNotSecureProcessing);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   763
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   764
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   765
                _stylesheetPIHandler.setBaseId(baseId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   766
                reader.setContentHandler(_stylesheetPIHandler);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   767
                reader.parse(isource);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   768
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   769
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   770
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   771
            if (_uriResolver != null ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   772
                _stylesheetPIHandler.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   774
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   775
        } catch (StopParseException e ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   776
          // startElement encountered so do not parse further
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   777
48577
8dff65f1d611 8186080: Transform XML interfaces
joehw
parents: 48409
diff changeset
   778
        } catch (SAXException | IOException e) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   779
             throw new TransformerConfigurationException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   780
             "getAssociatedStylesheets failed", e);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   781
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   782
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   783
         return _stylesheetPIHandler.getAssociatedStylesheet();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   784
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   785
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   786
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   787
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   788
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   789
     * Create a Transformer object that copies the input document to the result.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   790
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   791
     * @return A Transformer object that simply copies the source to the result.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   792
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   793
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   794
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   795
    public Transformer newTransformer()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   796
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   797
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   798
        // create CatalogFeatures that is accessible by the Transformer
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   799
        // through the factory instance
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   800
        buildCatalogFeatures();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   801
        TransformerImpl result = new TransformerImpl(new Properties(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   802
            _indentNumber, this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   803
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   804
            result.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   805
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   806
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   807
        if (!_isNotSecureProcessing) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   808
            result.setSecureProcessing(true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   809
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   810
        return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   811
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   812
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   813
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   814
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   815
     * Process the Source into a Templates object, which is a a compiled
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   816
     * representation of the source. Note that this method should not be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   817
     * used with XSLTC, as the time-consuming compilation is done for each
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   818
     * and every transformation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   819
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   820
     * @return A Templates object that can be used to create Transformers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   821
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   822
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   823
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   824
    public Transformer newTransformer(Source source) throws
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   825
        TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   826
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   827
        final Templates templates = newTemplates(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   828
        final Transformer transformer = templates.newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   829
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   830
            transformer.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   831
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   832
        return(transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   833
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   834
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   835
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   836
     * Pass warning messages from the compiler to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   837
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   838
    private void passWarningsToListener(List<ErrorMsg> messages)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   839
        throws TransformerException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   840
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   841
        if (_errorListener == null || messages == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   842
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   843
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   844
        // Pass messages to listener, one by one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   845
        final int count = messages.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   846
        for (int pos = 0; pos < count; pos++) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   847
            ErrorMsg msg = messages.get(pos);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   848
            // Workaround for the TCK failure ErrorListener.errorTests.error001.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   849
            if (msg.isWarningError())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   850
                _errorListener.error(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   851
                    new TransformerConfigurationException(msg.toString()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   852
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   853
                _errorListener.warning(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   854
                    new TransformerConfigurationException(msg.toString()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   855
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   856
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   857
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   858
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   859
     * Pass error messages from the compiler to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   860
     */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
   861
    private void passErrorsToListener(List<ErrorMsg> messages) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   862
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   863
            if (_errorListener == null || messages == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   864
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   865
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   866
            // Pass messages to listener, one by one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   867
            final int count = messages.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   868
            for (int pos = 0; pos < count; pos++) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   869
                String message = messages.get(pos).toString();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   870
                _errorListener.error(new TransformerException(message));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   871
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   872
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   873
        catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   874
            // nada
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   875
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   876
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   877
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   878
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   879
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   880
     * Process the Source into a Templates object, which is a a compiled
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   881
     * representation of the source.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   882
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   883
     * @param source The input stylesheet - DOMSource not supported!!!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   884
     * @return A Templates object that can be used to create Transformers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   885
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   886
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   887
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   888
    public Templates newTemplates(Source source)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   889
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   890
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   891
        TemplatesImpl templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   892
        // If the _useClasspath attribute is true, try to load the translet from
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   893
        // the CLASSPATH and create a template object using the loaded
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   894
        // translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   895
        if (_useClasspath) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   896
            String transletName = getTransletBaseName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   897
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   898
            if (_packageName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   899
                transletName = _packageName + "." + transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   900
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   901
            try {
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   902
                final Class<?> clazz = ObjectFactory.findProviderClass(transletName, true);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   903
                resetTransientAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   904
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 40582
diff changeset
   905
                templates = new TemplatesImpl(new Class<?>[]{clazz}, transletName, null, _indentNumber, this);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   906
                if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   907
                    templates.setURIResolver(_uriResolver);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   908
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   909
                return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   910
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   911
            catch (ClassNotFoundException cnfe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   912
                ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, transletName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   913
                throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   914
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   915
            catch (Exception e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   916
                ErrorMsg err = new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   917
                                     new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   918
                                     + e.getMessage());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   919
                throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   920
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   921
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   922
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   923
        // If _autoTranslet is true, we will try to load the bytecodes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   924
        // from the translet classes without compiling the stylesheet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   925
        if (_autoTranslet)  {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   926
            byte[][] bytecodes;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   927
            String transletClassName = getTransletBaseName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   928
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   929
            if (_packageName != null)
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
   930
               transletClassName = _packageName + "." + transletClassName;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   931
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   932
            if (_jarFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   933
                bytecodes = getBytecodesFromJar(source, transletClassName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   934
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
                bytecodes = getBytecodesFromClasses(source, transletClassName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   936
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   937
            if (bytecodes != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   938
                if (_debug) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   939
                    if (_jarFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   940
                        System.err.println(new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   941
                            ErrorMsg.TRANSFORM_WITH_JAR_STR, transletClassName, _jarFileName));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   942
                    else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   943
                        System.err.println(new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
                            ErrorMsg.TRANSFORM_WITH_TRANSLET_STR, transletClassName));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   945
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   946
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   947
                // Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   948
                // after each newTemplates() call.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   949
                resetTransientAttributes();
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   950
                templates = new TemplatesImpl(bytecodes, transletClassName, null, _indentNumber, this);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   951
                if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   952
                    templates.setURIResolver(_uriResolver);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   953
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   954
                return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   955
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   956
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   957
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   958
        // Create and initialize a stylesheet compiler
55742
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
   959
        final XSLTC xsltc = new XSLTC(_xmlFeatures, _hasUserErrListener);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   960
        if (_debug) xsltc.setDebug(true);
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   961
        if (_enableInlining)
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   962
                xsltc.setTemplateInlining(true);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   963
        else
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   964
                xsltc.setTemplateInlining(false);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   965
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   966
        if (!_isNotSecureProcessing) xsltc.setSecureProcessing(true);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   967
        xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, _accessExternalStylesheet);
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   968
        xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   969
        xsltc.setProperty(XalanConstants.SECURITY_MANAGER, _xmlSecurityManager);
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   970
        xsltc.setProperty(XalanConstants.JDK_EXTENSION_CLASSLOADER, _extensionClassLoader);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   971
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   972
        // set Catalog features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   973
        buildCatalogFeatures();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   974
        xsltc.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   975
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   976
        xsltc.init();
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   977
        if (!_isNotSecureProcessing)
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   978
            _xsltcExtensionFunctions = xsltc.getExternalExtensionFunctions();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   979
        // Set a document loader (for xsl:include/import) if defined
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   980
        if (_uriResolver != null || ( _catalogFiles != null
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   981
                && _xmlFeatures.getFeature(JdkXmlFeatures.XmlFeature.USE_CATALOG))) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   982
            xsltc.setSourceLoader(this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   983
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   984
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   985
        // Pass parameters to the Parser to make sure it locates the correct
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   986
        // <?xml-stylesheet ...?> PI in an XML input document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   987
        if ((_piParams != null) && (_piParams.get(source) != null)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   988
            // Get the parameters for this Source object
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   989
            PIParamWrapper p = _piParams.get(source);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   990
            // Pass them on to the compiler (which will pass then to the parser)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   991
            if (p != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   992
                xsltc.setPIParameters(p._media, p._title, p._charset);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   993
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   994
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   995
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   996
        // Set the attributes for translet generation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   997
        int outputType = XSLTC.BYTEARRAY_OUTPUT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   998
        if (_generateTranslet || _autoTranslet) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   999
            // Set the translet name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1000
            xsltc.setClassName(getTransletBaseName(source));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1001
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1002
            if (_destinationDirectory != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1003
                xsltc.setDestDirectory(_destinationDirectory);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1004
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1005
                String xslName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1006
                if (xslName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1007
                    File xslFile = new File(xslName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1008
                    String xslDir = xslFile.getParent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1009
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1010
                    if (xslDir != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1011
                        xsltc.setDestDirectory(xslDir);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1012
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1013
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1014
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1015
            if (_packageName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1016
                xsltc.setPackageName(_packageName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1017
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1018
            if (_jarFileName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1019
                xsltc.setJarFileName(_jarFileName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1020
                outputType = XSLTC.BYTEARRAY_AND_JAR_OUTPUT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1021
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1022
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1023
                outputType = XSLTC.BYTEARRAY_AND_FILE_OUTPUT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1024
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1025
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1026
        // Compile the stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1027
        final InputSource input = Util.getInputSource(xsltc, source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1028
        byte[][] bytecodes = xsltc.compile(null, input, outputType);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1029
        final String transletName = xsltc.getClassName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1030
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1031
        // Output to the jar file if the jar file name is set.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1032
        if ((_generateTranslet || _autoTranslet)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1033
                && bytecodes != null && _jarFileName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1034
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1035
                xsltc.outputToJar();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1036
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1037
            catch (java.io.IOException e) { }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1038
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1039
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1040
        // Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1041
        // after each newTemplates() call.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1042
        resetTransientAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1043
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1044
        // Pass compiler warnings to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1045
        if (_errorListener != this) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1046
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1047
                passWarningsToListener(xsltc.getWarnings());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1048
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1049
            catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1050
                throw new TransformerConfigurationException(e);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1051
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1052
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1053
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1054
            xsltc.printWarnings();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1055
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1056
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1057
        // Check that the transformation went well before returning
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1058
        if (bytecodes == null) {
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1059
            List<ErrorMsg> errs = xsltc.getErrors();
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1060
            ErrorMsg err;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1061
            if (errs != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1062
                err = errs.get(errs.size()-1);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1063
            } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1064
                err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1065
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1066
            Throwable cause = err.getCause();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1067
            TransformerConfigurationException exc;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1068
            if (cause != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1069
                exc =  new TransformerConfigurationException(cause.getMessage(), cause);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1070
            } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1071
                exc =  new TransformerConfigurationException(err.toString());
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1072
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1073
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1074
            // Pass compiler errors to the error listener
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1075
            if (_errorListener != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1076
                passErrorsToListener(xsltc.getErrors());
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1077
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1078
                // As required by TCK 1.2, send a fatalError to the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1079
                // error listener because compilation of the stylesheet
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1080
                // failed and no further processing will be possible.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1081
                try {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1082
                    _errorListener.fatalError(exc);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1083
                } catch (TransformerException te) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1084
                    // well, we tried.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1085
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1086
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1087
            else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1088
                xsltc.printErrors();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1089
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1090
            throw exc;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
  1091
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1092
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1093
        templates = new TemplatesImpl(bytecodes, transletName, xsltc.getOutputProperties(),
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1094
                _indentNumber, this);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1095
        if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1096
            templates.setURIResolver(_uriResolver);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1097
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1098
        return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1099
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1100
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1101
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1102
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1103
     * Get a TemplatesHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1104
     * events into a Templates object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1105
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1106
     * @return A TemplatesHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1107
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1108
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1109
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1110
    public TemplatesHandler newTemplatesHandler()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1111
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1112
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1113
        // create CatalogFeatures that is accessible by the Handler
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1114
        // through the factory instance
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1115
        buildCatalogFeatures();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1116
        final TemplatesHandlerImpl handler =
55742
6e1161923897 8157830: Errors in XSLT stylesheet are not dispatched correctly to ErrorListener
joehw
parents: 50947
diff changeset
  1117
            new TemplatesHandlerImpl(_indentNumber, this, _hasUserErrListener);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1118
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1119
            handler.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1120
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1121
        return handler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1122
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1123
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1124
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1125
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1126
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1127
     * events into a Result. This method will return a pure copy transformer.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1128
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1129
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1130
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1131
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1132
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1133
    public TransformerHandler newTransformerHandler()
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1134
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1135
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1136
        final Transformer transformer = newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1137
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1138
            transformer.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1139
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1140
        return new TransformerHandlerImpl((TransformerImpl) transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1141
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1142
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1143
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1144
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1145
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1146
     * events into a Result, based on the transformation instructions
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1147
     * specified by the argument.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1148
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1149
     * @param src The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1150
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1151
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1152
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1153
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1154
    public TransformerHandler newTransformerHandler(Source src)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1155
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1156
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1157
        final Transformer transformer = newTransformer(src);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1158
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1159
            transformer.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1160
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1161
        return new TransformerHandlerImpl((TransformerImpl) transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1162
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1163
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1164
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1165
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1166
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1167
     * events into a Result, based on the transformation instructions
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1168
     * specified by the argument.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1169
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1170
     * @param templates Represents a pre-processed stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1171
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1172
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1173
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1174
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1175
    public TransformerHandler newTransformerHandler(Templates templates)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1176
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1177
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1178
        final Transformer transformer = templates.newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1179
        final TransformerImpl internal = (TransformerImpl)transformer;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1180
        return new TransformerHandlerImpl(internal);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1181
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1182
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1183
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1184
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1185
     * Create an XMLFilter that uses the given source as the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1186
     * transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1187
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1188
     * @param src The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1189
     * @return An XMLFilter object, or null if this feature is not supported.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1190
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1191
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1192
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1193
    public XMLFilter newXMLFilter(Source src)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1194
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1195
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1196
        Templates templates = newTemplates(src);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1197
        if (templates == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1198
        return newXMLFilter(templates);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1199
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1200
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1201
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1202
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1203
     * Create an XMLFilter that uses the given source as the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1204
     * transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1205
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1206
     * @param templates The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1207
     * @return An XMLFilter object, or null if this feature is not supported.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1208
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1209
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1210
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1211
    public XMLFilter newXMLFilter(Templates templates)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1212
        throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1213
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1214
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1215
            return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1216
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1217
        catch (TransformerConfigurationException e1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1218
            if (_errorListener != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1219
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1220
                    _errorListener.fatalError(e1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1221
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1222
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1223
                catch (TransformerException e2) {
50947
fb46a7d38d6b 8206164: forgot to "throw" TransformerConfigurationException
joehw
parents: 48577
diff changeset
  1224
                    throw new TransformerConfigurationException(e2);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1225
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1226
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1227
            throw e1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1228
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1229
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1230
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1231
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1232
     * This method implements XSLTC's SourceLoader interface. It is used to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1233
     * glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1234
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1235
     * @param href The URI of the document to load
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1236
     * @param context The URI of the currently loaded document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1237
     * @param xsltc The compiler that resuests the document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1238
     * @return An InputSource with the loaded document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1239
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1240
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1241
    public InputSource loadSource(String href, String context, XSLTC xsltc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1242
        try {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1243
            Source source = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1244
            if (_uriResolver != null) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1245
                source = _uriResolver.resolve(href, context);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1246
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1247
            if (source == null && _catalogFiles != null &&
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1248
                    _xmlFeatures.getFeature(JdkXmlFeatures.XmlFeature.USE_CATALOG)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1249
                if (_catalogUriResolver == null) {
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
  1250
                    _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1251
                }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1252
                source = _catalogUriResolver.resolve(href, context);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1253
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1254
            if (source != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1255
                return Util.getInputSource(xsltc, source);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1256
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1257
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1258
        catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1259
            // should catch it when the resolver explicitly throws the exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1260
            final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1261
            xsltc.getParser().reportError(Constants.FATAL, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1262
        }
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
  1263
        catch (CatalogException e) {
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
  1264
            final ErrorMsg msg = new ErrorMsg(ErrorMsg.CATALOG_EXCEPTION, href + "\n" + e.getMessage(), this);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
  1265
            xsltc.getParser().reportError(Constants.FATAL, msg);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 39909
diff changeset
  1266
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1267
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1268
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1269
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1270
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1271
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1272
     * Build the CatalogFeatures object when a newTemplates or newTransformer is
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1273
     * created. This will read any System Properties for the CatalogFeatures that
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1274
     * may have been set.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1275
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1276
    private CatalogFeatures buildCatalogFeatures() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1277
        // build will cause the CatalogFeatures to read SPs for those not set through the API
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1278
        if (_catalogFeatures == null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1279
            _catalogFeatures = cfBuilder.build();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1280
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1281
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1282
        // update fields
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1283
        _catalogFiles = _catalogFeatures.get(Feature.FILES);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1284
        _catalogDefer = _catalogFeatures.get(Feature.DEFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1285
        _catalogPrefer = _catalogFeatures.get(Feature.PREFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1286
        _catalogResolve = _catalogFeatures.get(Feature.RESOLVE);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1287
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1288
        return _catalogFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1289
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1290
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1291
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1292
     * Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1293
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1294
    private void resetTransientAttributes() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1295
        _transletName = DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1296
        _destinationDirectory = null;
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
  1297
        _packageName = DEFAULT_TRANSLATE_PACKAGE;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1298
        _jarFileName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1299
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1300
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1301
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1302
     * Load the translet classes from local .class files and return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1303
     * the bytecode array.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1304
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1305
     * @param source The xsl source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1306
     * @param fullClassName The full name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1307
     * @return The bytecode array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1308
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1309
    private byte[][] getBytecodesFromClasses(Source source, String fullClassName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1310
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1311
        if (fullClassName == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1312
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1313
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1314
        String xslFileName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1315
        File xslFile = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1316
        if (xslFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1317
            xslFile = new File(xslFileName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1318
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1319
        // Find the base name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1320
        final String transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1321
        int lastDotIndex = fullClassName.lastIndexOf('.');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1322
        if (lastDotIndex > 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1323
            transletName = fullClassName.substring(lastDotIndex+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1324
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1325
            transletName = fullClassName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1326
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1327
        // Construct the path name for the translet class file
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1328
        String transletPath = fullClassName.replace('.', '/');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1329
        if (_destinationDirectory != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1330
            transletPath = _destinationDirectory + "/" + transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1331
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1332
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1333
            if (xslFile != null && xslFile.getParent() != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1334
                transletPath = xslFile.getParent() + "/" + transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1335
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1336
                transletPath = transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1337
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1338
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1339
        // Return null if the translet class file does not exist.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1340
        File transletFile = new File(transletPath);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1341
        if (!transletFile.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1342
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1343
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1344
        // Compare the timestamps of the translet and the xsl file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1345
        // If the translet is older than the xsl file, return null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1346
        // so that the xsl file is used for the transformation and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1347
        // the translet is regenerated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1348
        if (xslFile != null && xslFile.exists()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1349
            long xslTimestamp = xslFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1350
            long transletTimestamp = transletFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1351
            if (transletTimestamp < xslTimestamp)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1352
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1353
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1354
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1355
        // Load the translet into a bytecode array.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1356
        List<byte[]> bytecodes = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1357
        int fileLength = (int)transletFile.length();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1358
        if (fileLength > 0) {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1359
            FileInputStream input;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1360
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1361
                input = new FileInputStream(transletFile);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1362
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1363
            catch (FileNotFoundException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1364
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1365
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1366
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1367
            byte[] bytes = new byte[fileLength];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1368
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1369
                readFromInputStream(bytes, input, fileLength);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1370
                input.close();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1371
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1372
            catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1373
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1374
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1375
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1376
            bytecodes.add(bytes);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1377
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1378
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1379
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1380
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1381
        // Find the parent directory of the translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1382
        String transletParentDir = transletFile.getParent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1383
        if (transletParentDir == null)
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
  1384
            transletParentDir = SecuritySupport.getSystemProperty("user.dir");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1385
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1386
        File transletParentFile = new File(transletParentDir);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1387
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1388
        // Find all the auxiliary files which have a name pattern of "transletClass$nnn.class".
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1389
        final String transletAuxPrefix = transletName + "$";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1390
        File[] auxfiles = transletParentFile.listFiles(new FilenameFilter() {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1391
                @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1392
                public boolean accept(File dir, String name)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1393
                {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1394
                    return (name.endsWith(".class") && name.startsWith(transletAuxPrefix));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1395
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1396
              });
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1397
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1398
        // Load the auxiliary class files and add them to the bytecode array.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1399
        for (int i = 0; i < auxfiles.length; i++)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1400
        {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1401
            File auxfile = auxfiles[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1402
            int auxlength = (int)auxfile.length();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1403
            if (auxlength > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1404
                FileInputStream auxinput = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1405
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1406
                    auxinput = new FileInputStream(auxfile);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1407
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1408
                catch (FileNotFoundException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1409
                    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1410
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1411
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1412
                byte[] bytes = new byte[auxlength];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1413
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1414
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1415
                    readFromInputStream(bytes, auxinput, auxlength);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1416
                    auxinput.close();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1417
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1418
                catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1419
                    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1420
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1421
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1422
                bytecodes.add(bytes);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1423
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1424
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1425
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1426
        // Convert the ArrayList of byte[] to byte[][].
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1427
        final int count = bytecodes.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1428
        if ( count > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1429
            final byte[][] result = new byte[count][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1430
            for (int i = 0; i < count; i++) {
47712
bde0215f1f70 8181151: Fix lint warnings in JAXP repo: cast
joehw
parents: 47359
diff changeset
  1431
                result[i] = bytecodes.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1432
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1433
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1434
            return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1435
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1436
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1437
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1438
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1439
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1440
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1441
     * Load the translet classes from the jar file and return the bytecode.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1442
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1443
     * @param source The xsl source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1444
     * @param fullClassName The full name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1445
     * @return The bytecode array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1446
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1447
    private byte[][] getBytecodesFromJar(Source source, String fullClassName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1448
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1449
        String xslFileName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1450
        File xslFile = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1451
        if (xslFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1452
            xslFile = new File(xslFileName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1453
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1454
        // Construct the path for the jar file
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1455
        String jarPath;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1456
        if (_destinationDirectory != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1457
            jarPath = _destinationDirectory + "/" + _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1458
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1459
            if (xslFile != null && xslFile.getParent() != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1460
                jarPath = xslFile.getParent() + "/" + _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1461
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1462
                jarPath = _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1463
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1464
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1465
        // Return null if the jar file does not exist.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1466
        File file = new File(jarPath);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1467
        if (!file.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1468
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1469
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1470
        // Compare the timestamps of the jar file and the xsl file. Return null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1471
        // if the xsl file is newer than the jar file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1472
        if (xslFile != null && xslFile.exists()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1473
            long xslTimestamp = xslFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1474
            long transletTimestamp = file.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1475
            if (transletTimestamp < xslTimestamp)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1476
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1477
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1478
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1479
        // Create a ZipFile object for the jar file
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1480
        ZipFile jarFile;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1481
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1482
            jarFile = new ZipFile(file);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1483
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1484
        catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1485
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1486
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1487
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1488
        String transletPath = fullClassName.replace('.', '/');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1489
        String transletAuxPrefix = transletPath + "$";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1490
        String transletFullName = transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1491
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1492
        List<byte[]> bytecodes = new ArrayList<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1493
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1494
        // Iterate through all entries in the jar file to find the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1495
        // translet and auxiliary classes.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1496
        Enumeration<? extends ZipEntry> entries = jarFile.entries();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1497
        while (entries.hasMoreElements())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1498
        {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1499
            ZipEntry entry = (ZipEntry)entries.nextElement();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1500
            String entryName = entry.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1501
            if (entry.getSize() > 0 &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1502
                  (entryName.equals(transletFullName) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1503
                  (entryName.endsWith(".class") &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1504
                      entryName.startsWith(transletAuxPrefix))))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1505
            {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1506
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1507
                    InputStream input = jarFile.getInputStream(entry);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1508
                    int size = (int)entry.getSize();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1509
                    byte[] bytes = new byte[size];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1510
                    readFromInputStream(bytes, input, size);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1511
                    input.close();
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1512
                    bytecodes.add(bytes);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1513
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1514
                catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1515
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1516
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1517
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1518
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1519
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47312
diff changeset
  1520
        // Convert the ArrayList of byte[] to byte[][].
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1521
        final int count = bytecodes.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1522
        if (count > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1523
            final byte[][] result = new byte[count][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1524
            for (int i = 0; i < count; i++) {
47712
bde0215f1f70 8181151: Fix lint warnings in JAXP repo: cast
joehw
parents: 47359
diff changeset
  1525
                result[i] = bytecodes.get(i);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1526
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1527
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1528
            return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1529
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1530
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1531
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1532
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1533
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1534
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1535
     * Read a given number of bytes from the InputStream into a byte array.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1536
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1537
     * @param bytes The byte array to store the input content.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1538
     * @param input The input stream.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1539
     * @param size The number of bytes to read.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1540
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1541
    private void readFromInputStream(byte[] bytes, InputStream input, int size)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1542
        throws IOException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1543
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1544
      int n = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1545
      int offset = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1546
      int length = size;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1547
      while (length > 0 && (n = input.read(bytes, offset, length)) > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1548
          offset = offset + n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1549
          length = length - n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1550
      }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1551
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1552
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1553
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1554
     * Return the base class name of the translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1555
     * The translet name is resolved using the following rules:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1556
     * 1. if the _transletName attribute is set and its value is not "GregorSamsa",
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1557
     *    then _transletName is returned.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1558
     * 2. otherwise get the translet name from the base name of the system ID
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1559
     * 3. return "GregorSamsa" if the result from step 2 is null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1560
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1561
     * @param source The input Source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1562
     * @return The name of the translet class
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1563
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1564
    private String getTransletBaseName(Source source)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1565
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1566
        String transletBaseName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1567
        if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1568
            return _transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1569
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1570
            String systemId = source.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1571
            if (systemId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1572
                String baseName = Util.baseName(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1573
                if (baseName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1574
                    baseName = Util.noExtName(baseName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1575
                    transletBaseName = Util.toJavaName(baseName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1576
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1577
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1578
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1579
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1580
        return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1581
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1582
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1583
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1584
     *  Return the local file name from the systemId of the Source object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1585
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1586
     * @param source The Source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1587
     * @return The file name in the local filesystem, or null if the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1588
     * systemId does not represent a local file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1589
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1590
    private String getStylesheetFileName(Source source)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1591
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1592
        String systemId = source.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1593
        if (systemId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1594
            File file = new File(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1595
            if (file.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1596
                return systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1597
            else {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1598
                URL url;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1599
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1600
                    url = new URL(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1601
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1602
                catch (MalformedURLException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1603
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1604
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1605
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1606
                if ("file".equals(url.getProtocol()))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1607
                    return url.getFile();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1608
                else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1609
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1610
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1611
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1612
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1613
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1614
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1615
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1616
    /**
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1617
     * Returns a new instance of the XSLTC DTM Manager service.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1618
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1619
    protected final XSLTCDTMManager createNewDTMManagerInstance() {
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1620
        return XSLTCDTMManager.createNewDTMManagerInstance();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1621
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1622
}