jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
author clanger
Sun, 31 Jul 2016 23:14:27 +0200
changeset 39909 00e4298ae168
parent 39907 db51759e3695
child 40582 1dddef49982c
permissions -rw-r--r--
8162598: XSLTC transformer swallows empty namespace declaration which is needed to undeclare default namespace Reviewed-by: joehw, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
     2
 * Copyright (c) 2007, 2016, 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;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    24
import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
    25
import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    26
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    27
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
    28
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
    29
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager;
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
    30
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    31
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    32
import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    33
import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    34
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
    35
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    36
import com.sun.org.apache.xml.internal.utils.StopParseException;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    37
import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
import java.io.File;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
import java.io.FileInputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
import java.io.FileNotFoundException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
import java.io.FilenameFilter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
import java.io.IOException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
import java.io.InputStream;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
import java.net.MalformedURLException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
import java.net.URL;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    46
import java.util.ArrayList;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
import java.util.Enumeration;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
    48
import java.util.Map;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
import java.util.Properties;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
import java.util.Vector;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
import java.util.zip.ZipEntry;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
import java.util.zip.ZipFile;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
import javax.xml.XMLConstants;
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.CatalogFeatures.Feature;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    56
import javax.xml.catalog.CatalogManager;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    57
import javax.xml.catalog.CatalogUriResolver;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    58
import javax.xml.parsers.SAXParser;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
import javax.xml.parsers.SAXParserFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    60
import javax.xml.transform.ErrorListener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
import javax.xml.transform.Source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
import javax.xml.transform.Templates;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    63
import javax.xml.transform.Transformer;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
import javax.xml.transform.TransformerConfigurationException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    65
import javax.xml.transform.TransformerException;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
    66
import javax.xml.transform.TransformerFactory;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
import javax.xml.transform.URIResolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
import javax.xml.transform.dom.DOMResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
import javax.xml.transform.dom.DOMSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
import javax.xml.transform.sax.SAXResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
import javax.xml.transform.sax.SAXSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
import javax.xml.transform.sax.SAXTransformerFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
import javax.xml.transform.sax.TemplatesHandler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
import javax.xml.transform.sax.TransformerHandler;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
    75
import javax.xml.transform.stax.*;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
import javax.xml.transform.stream.StreamResult;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
import javax.xml.transform.stream.StreamSource;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    78
import jdk.xml.internal.JdkXmlFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    79
import jdk.xml.internal.JdkXmlUtils;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
import org.xml.sax.InputSource;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
import org.xml.sax.XMLFilter;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
import org.xml.sax.XMLReader;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
import org.xml.sax.helpers.XMLReaderFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
/**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
 * Implementation of a JAXP1.1 TransformerFactory for Translets.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
 * @author G. Todd Miller
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
 * @author Morten Jorgensen
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
 * @author Santiago Pericas-Geertsen
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
 */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
    91
@SuppressWarnings("deprecation") //org.xml.sax.helpers.XMLReaderFactory
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    92
public class TransformerFactoryImpl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
    extends SAXTransformerFactory implements SourceLoader, ErrorListener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
    // Public constants for attributes supported by the XSLTC TransformerFactory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    96
    public final static String TRANSLET_NAME = "translet-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    97
    public final static String DESTINATION_DIRECTORY = "destination-directory";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
    public final static String PACKAGE_NAME = "package-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    public final static String JAR_NAME = "jar-name";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
    public final static String GENERATE_TRANSLET = "generate-translet";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
    public final static String AUTO_TRANSLET = "auto-translet";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
    public final static String USE_CLASSPATH = "use-classpath";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
    public final static String DEBUG = "debug";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
    public final static String ENABLE_INLINING = "enable-inlining";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
    public final static String INDENT_NUMBER = "indent-number";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   108
     * 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
   109
     * the Templates or Transformer objects that we create.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   110
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
    private ErrorListener _errorListener = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
     * This URIResolver is passed to all created Templates and Transformers
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
    private URIResolver _uriResolver = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
     * As Gregor Samsa awoke one morning from uneasy dreams he found himself
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
     * 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
   121
     * 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
   122
     * could see his big, brown belly divided into stiff, arched segments, on
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
     * 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
   124
     * to slide off completely. His numerous legs, which were pitifully thin
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
     * compared to the rest of his bulk, waved helplessly before his eyes.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
     * "What has happened to me?", he thought. It was no dream....
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
    protected final static String DEFAULT_TRANSLET_NAME = "GregorSamsa";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
     * The class name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   132
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
    private String _transletName = DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   134
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
     * The destination directory for the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
    private String _destinationDirectory = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
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
     * The package name prefix for all generated translet classes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
     */
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   143
    private static final String DEFAULT_TRANSLATE_PACKAGE = "die.verwandlung";
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   144
    private String _packageName = DEFAULT_TRANSLATE_PACKAGE;
12005
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 jar file name which the translet classes are packaged into
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
    private String _jarFileName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   152
     * This Map is used to store parameters for locating
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
     * <?xml-stylesheet ...?> processing instructions in XML docs.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
     */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   155
    private Map<Source, PIParamWrapper> _piParams = null;
12005
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
     * The above Map stores objects of this class.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
    private static class PIParamWrapper {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
        public String _media = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
        public String _title = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
        public String _charset = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   164
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
        public PIParamWrapper(String media, String title, String charset) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
            _media = media;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
            _title = title;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
            _charset = charset;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
        }
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
     * Set to <code>true</code> when debugging is enabled.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
    private boolean _debug = false;
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
     * Set to <code>true</code> when templates are inlined.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
    private boolean _enableInlining = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
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
     * Set to <code>true</code> when we want to generate
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
     * translet classes from the stylesheet.
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 _generateTranslet = 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
     * 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
   190
     * for transformation if possible without compiling the stylesheet. The
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
     * 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
   192
     * of the stylesheet.
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
    private boolean _autoTranslet = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
     * 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
   198
     * from the CLASSPATH.
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 _useClasspath = 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
     * Number of indent spaces when indentation is turned on.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
    private int _indentNumber = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
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
     * <p>State of secure processing feature.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
    private boolean _isNotSecureProcessing = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
     * <p>State of secure mode.</p>
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
    private boolean _isSecureMode = false;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   215
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   216
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   217
     * Indicates whether implementation parts should use
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   218
     *   service loader (or similar).
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   219
     * Note the default value (false) is the safe option..
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   220
     */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   221
    private boolean _useServicesMechanism;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   222
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
    /**
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   224
     * protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   225
     */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   226
    private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   227
     /**
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   228
     * 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
   229
     */
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   230
    private String _accessExternalDTD = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   231
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   232
    private XMLSecurityPropertyManager _xmlSecurityPropertyMgr;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   233
    private XMLSecurityManager _xmlSecurityManager;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   234
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   235
    private final JdkXmlFeatures _xmlFeatures;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   236
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   237
    private ClassLoader _extensionClassLoader = null;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   238
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   239
    // 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
   240
    // 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
   241
    // type checking
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   242
    private Map<String, Class> _xsltcExtensionFunctions;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   243
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   244
    CatalogUriResolver _catalogUriResolver;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   245
    CatalogFeatures _catalogFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   246
    CatalogFeatures.Builder cfBuilder = CatalogFeatures.builder();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   247
    // Catalog features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   248
    String _catalogFiles = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   249
    String _catalogDefer = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   250
    String _catalogPrefer = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   251
    String _catalogResolve = null;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   252
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   253
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   254
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   255
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   256
    public TransformerFactoryImpl() {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   257
        this(true);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   258
    }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   259
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   260
    public static TransformerFactory newTransformerFactoryNoServiceLoader() {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   261
        return new TransformerFactoryImpl(false);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   262
    }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   263
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   264
    private TransformerFactoryImpl(boolean useServicesMechanism) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   265
        this._useServicesMechanism = useServicesMechanism;
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);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   273
        _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager();
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   274
        _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   275
                Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   276
        _accessExternalStylesheet = _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_STYLESHEET);
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   278
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   279
        //Parser's security manager
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   280
        _xmlSecurityManager = new XMLSecurityManager(true);
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   281
        //Unmodifiable hash map with loaded external extension functions
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   282
        _xsltcExtensionFunctions = null;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   283
    }
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   284
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   285
    public Map<String,Class> getExternalExtensionsMap() {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   286
        return _xsltcExtensionFunctions;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   287
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
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
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
     * Set the error event listener for the TransformerFactory, which is used
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
     * for the processing of transformation instructions, and not for the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
     * transformation itself.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
     * @param listener The error listener to use with the TransformerFactory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   298
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
    public void setErrorListener(ErrorListener listener)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   300
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   301
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
        if (listener == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
            ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
                                        "TransformerFactory");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
            throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   307
        _errorListener = listener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   309
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   311
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   312
     * Get the error event handler for the TransformerFactory.
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
     * @return The error listener used with the TransformerFactory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   316
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
    public ErrorListener getErrorListener() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
        return _errorListener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
    /**
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   322
     * Returns the package name.
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   323
     */
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   324
    String getPackageName() {
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   325
        return _packageName;
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   326
    }
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   327
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
   328
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   329
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   330
     * Returns the value set for a TransformerFactory attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   331
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
     * @param name The attribute name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
     * @return An object representing the attribute value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   334
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   335
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   336
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   337
    public Object getAttribute(String name)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   338
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   339
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   340
        // Return value for attribute 'translet-name'
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   341
        if (name.equals(TRANSLET_NAME)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   342
            return _transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   343
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   344
        else if (name.equals(GENERATE_TRANSLET)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   345
            return _generateTranslet;
12005
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(AUTO_TRANSLET)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   348
            return _autoTranslet;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   349
        }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   350
        else if (name.equals(ENABLE_INLINING)) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   351
            if (_enableInlining)
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   352
              return Boolean.TRUE;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   353
            else
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   354
              return Boolean.FALSE;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   355
        } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   356
            return _xmlSecurityManager;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   357
        } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   358
           return _extensionClassLoader;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   359
        } else if (JdkXmlUtils.CATALOG_FILES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   360
            return _catalogFiles;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   361
        } else if (JdkXmlUtils.CATALOG_DEFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   362
            return _catalogDefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   363
        } else if (JdkXmlUtils.CATALOG_PREFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   364
            return _catalogPrefer;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   365
        } else if (JdkXmlUtils.CATALOG_RESOLVE.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   366
            return _catalogResolve;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   367
        } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   368
            return buildCatalogFeatures();
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   369
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   370
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   371
        /** Check to see if the property is managed by the security manager **/
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   372
        String propertyValue = (_xmlSecurityManager != null) ?
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   373
                _xmlSecurityManager.getLimitAsString(name) : null;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   374
        if (propertyValue != null) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   375
            return propertyValue;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   376
        } else {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   377
            propertyValue = (_xmlSecurityPropertyMgr != null) ?
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   378
                _xmlSecurityPropertyMgr.getValue(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
            }
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   382
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   383
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   384
        // Throw an exception for all other attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   385
        ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   386
        throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   387
    }
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
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   390
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   391
     * Sets the value for a TransformerFactory attribute.
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
     * @param name The attribute name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   394
     * @param value An object representing the attribute value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   395
     * @throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   396
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   397
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   398
    public void setAttribute(String name, Object value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
        throws IllegalArgumentException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   400
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   401
        // Set the default translet name (ie. class name), which will be used
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   402
        // for translets that cannot be given a name from their system-id.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   403
        if (name.equals(TRANSLET_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   404
            _transletName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   405
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   406
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   407
        else if (name.equals(DESTINATION_DIRECTORY) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   408
            _destinationDirectory = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   409
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   410
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   411
        else if (name.equals(PACKAGE_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   412
            _packageName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   413
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   414
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   415
        else if (name.equals(JAR_NAME) && value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   416
            _jarFileName = (String) value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   417
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   418
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   419
        else if (name.equals(GENERATE_TRANSLET)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   420
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   421
                _generateTranslet = ((Boolean) value);
12005
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 (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   425
                _generateTranslet = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   426
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   427
            }
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 (name.equals(AUTO_TRANSLET)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   430
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   431
                _autoTranslet = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   432
                return;
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 (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   435
                _autoTranslet = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   436
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   437
            }
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 (name.equals(USE_CLASSPATH)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   440
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   441
                _useClasspath = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   442
                return;
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 (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   445
                _useClasspath = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   446
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   447
            }
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 (name.equals(DEBUG)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   451
                _debug = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   452
                return;
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 (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   455
                _debug = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   456
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   457
            }
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 (name.equals(ENABLE_INLINING)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   460
            if (value instanceof Boolean) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   461
                _enableInlining = ((Boolean) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   462
                return;
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 (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   465
                _enableInlining = ((String) value).equalsIgnoreCase("true");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   466
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   467
            }
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 (name.equals(INDENT_NUMBER)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   470
            if (value instanceof String) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   471
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   472
                    _indentNumber = Integer.parseInt((String) value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   473
                    return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   474
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   475
                catch (NumberFormatException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   476
                    // Falls through
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   477
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   478
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   479
            else if (value instanceof Integer) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   480
                _indentNumber = ((Integer) value);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   481
                return;
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
        }
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   484
        else if ( name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   485
            if (value instanceof ClassLoader) {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   486
                _extensionClassLoader = (ClassLoader) value;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   487
                return;
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   488
            } else {
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   489
                final ErrorMsg err
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   490
                    = 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
   491
                throw new IllegalArgumentException(err.toString());
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   492
            }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   493
        } else if (JdkXmlUtils.CATALOG_FILES.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   494
            _catalogFiles = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   495
            cfBuilder = CatalogFeatures.builder().with(Feature.FILES, _catalogFiles);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   496
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   497
        } else if (JdkXmlUtils.CATALOG_DEFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   498
            _catalogDefer = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   499
            cfBuilder = CatalogFeatures.builder().with(Feature.DEFER, _catalogDefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   500
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   501
        } else if (JdkXmlUtils.CATALOG_PREFER.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   502
            _catalogPrefer = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   503
            cfBuilder = CatalogFeatures.builder().with(Feature.PREFER, _catalogPrefer);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   504
            return;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   505
        } else if (JdkXmlUtils.CATALOG_RESOLVE.equals(name)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   506
            _catalogResolve = (String) value;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   507
            cfBuilder = CatalogFeatures.builder().with(Feature.RESOLVE, _catalogResolve);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   508
            return;
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   509
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   510
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   511
        if (_xmlSecurityManager != null &&
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   512
                _xmlSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   513
            return;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   514
        }
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   515
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   516
        if (_xmlSecurityPropertyMgr != null &&
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   517
            _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
   518
            _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   519
                    Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   520
            _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   521
                    Property.ACCESS_EXTERNAL_STYLESHEET);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   522
            return;
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   523
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   524
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   525
        // Throw an exception for all other attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   526
        final ErrorMsg err
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   527
            = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   528
        throw new IllegalArgumentException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   529
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   530
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   531
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   532
     * <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
   533
     * or <code>Template</code>s created by this factory.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   534
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   535
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
     * Feature names are fully qualified {@link java.net.URI}s.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   537
     * Implementations may define their own features.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
     * An {@link TransformerConfigurationException} is thrown if this <code>TransformerFactory</code> or the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   539
     * <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
   540
     * 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
   541
     * </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>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
   544
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   545
     * @param name Feature name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   546
     * @param value Is feature state <code>true</code> or <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   547
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   548
     * @throws TransformerConfigurationException if this <code>TransformerFactory</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   549
     *   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
   550
     * @throws NullPointerException If the <code>name</code> parameter is null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   551
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   552
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   553
    public void setFeature(String name, boolean value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   554
        throws TransformerConfigurationException {
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
        // feature name cannot be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   557
        if (name == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   558
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SET_FEATURE_NULL_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   559
            throw new NullPointerException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   560
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   561
        // secure processing?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   562
        else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   563
            if ((_isSecureMode) && (!value)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   564
                ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SECUREPROCESSING_FEATURE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   565
                throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   566
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   567
            _isNotSecureProcessing = !value;
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   568
            _xmlSecurityManager.setSecureProcessing(value);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   569
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   570
            // 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
   571
            if (value) {
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   572
                _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   573
                        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
   574
                _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_STYLESHEET,
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   575
                        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
   576
                _accessExternalDTD = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   577
                        Property.ACCESS_EXTERNAL_DTD);
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   578
                _accessExternalStylesheet = _xmlSecurityPropertyMgr.getValue(
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   579
                        Property.ACCESS_EXTERNAL_STYLESHEET);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   580
            }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 18352
diff changeset
   581
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   582
            if (value && _xmlFeatures != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   583
                _xmlFeatures.setFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION,
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   584
                        JdkXmlFeatures.State.FSP, false);
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   585
            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   586
        }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   587
        else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   588
            //in secure mode, let _useServicesMechanism be determined by the constructor
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   589
            if (!_isSecureMode)
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   590
                _useServicesMechanism = value;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   591
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   592
        else {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   593
            if (_xmlFeatures != null &&
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   594
                    _xmlFeatures.setFeature(name, JdkXmlFeatures.State.APIPROPERTY, value)) {
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   595
                return;
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   596
            }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   597
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   598
            // unknown feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   599
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   600
            throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   601
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   602
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   603
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   604
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   605
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   606
     * 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
   607
     * 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
   608
     * class are implemented.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   609
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   610
     * @param name The feature name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   611
     * @return 'true' if feature is supported, 'false' if not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   613
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   614
    public boolean getFeature(String name) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   615
        // All supported features should be listed here
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   616
        String[] features = {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   617
            DOMSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   618
            DOMResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   619
            SAXSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   620
            SAXResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   621
            StAXSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   622
            StAXResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   623
            StreamSource.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   624
            StreamResult.FEATURE,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   625
            SAXTransformerFactory.FEATURE,
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   626
            SAXTransformerFactory.FEATURE_XMLFILTER,
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   627
            XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
        };
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
        // feature name cannot be null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
        if (name == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
            ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_GET_FEATURE_NULL_NAME);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
            throw new NullPointerException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   634
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   635
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   636
        // Inefficient, but array is small
39909
00e4298ae168 8162598: XSLTC transformer swallows empty namespace declaration which is needed to undeclare default namespace
clanger
parents: 39907
diff changeset
   637
        for (int i = 0; i < features.length; i++) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   638
            if (name.equals(features[i])) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   639
                return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   640
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   641
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   642
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   643
        if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   644
            return !_isNotSecureProcessing;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   645
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   646
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   647
        /** Check to see if the property is managed by the JdkXmlFeatues **/
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   648
        int index = _xmlFeatures.getIndex(name);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   649
        if (index > -1) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   650
            return _xmlFeatures.getFeature(index);
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   651
        }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   652
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
        // Feature not supported
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
    }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   656
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   657
     * Return the state of the services mechanism feature.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   658
     */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   659
    public boolean useServicesMechnism() {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   660
        return _useServicesMechanism;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   661
    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   662
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   663
     /**
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   664
     * @return the feature manager
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   665
     */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   666
    public JdkXmlFeatures getJdkXmlFeatures() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   667
        return _xmlFeatures;
21467
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   668
    }
ed77f0ff062c 8004476: XSLT Extension Functions Don't Work in WebStart
joehw
parents: 20968
diff changeset
   669
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   670
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   671
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   672
     * Get the object that is used by default during the transformation to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   673
     * resolve URIs used in document(), xsl:import, or xsl:include.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   674
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   675
     * @return The URLResolver used for this TransformerFactory and all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   676
     * Templates and Transformer objects created using this factory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   677
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   678
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   679
    public URIResolver getURIResolver() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   680
        return _uriResolver;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   681
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   682
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   683
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   684
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   685
     * Set the object that is used by default during the transformation to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   686
     * resolve URIs used in document(), xsl:import, or xsl:include. Note that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   687
     * this does not affect Templates and Transformers that are already
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   688
     * created with this factory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   689
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   690
     * @param resolver The URLResolver used for this TransformerFactory and all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   691
     * Templates and Transformer objects created using this factory
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   692
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   693
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   694
    public void setURIResolver(URIResolver resolver) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   695
        _uriResolver = resolver;
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
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   699
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   700
     * Get the stylesheet specification(s) associated via the xml-stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   701
     * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   702
     * the document document specified in the source parameter, and that match
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   703
     * the given criteria.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   704
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   705
     * @param source The XML source document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   706
     * @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
   707
     * case the prefered templates will be used (i.e. alternate = no).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   708
     * @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
   709
     * @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
   710
     * @return A Source object suitable for passing to the TransformerFactory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   711
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   712
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   713
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   714
    public Source  getAssociatedStylesheet(Source source, String media,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   715
                                          String title, String charset)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   716
        throws TransformerConfigurationException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   717
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   718
        String baseId;
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   719
        XMLReader reader;
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   720
        InputSource isource;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   721
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   722
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   723
        /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   724
         * Fix for bugzilla bug 24187
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   725
         */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   726
        StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   727
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   728
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   729
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   730
            if (source instanceof DOMSource ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   731
                final DOMSource domsrc = (DOMSource) source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   732
                baseId = domsrc.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   733
                final org.w3c.dom.Node node = domsrc.getNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   734
                final DOM2SAX dom2sax = new DOM2SAX(node);
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
                _stylesheetPIHandler.setBaseId(baseId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   737
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   738
                dom2sax.setContentHandler( _stylesheetPIHandler);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   739
                dom2sax.parse();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   740
            } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
                isource = SAXSource.sourceToInputSource(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   742
                baseId = isource.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   743
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   744
                SAXParserFactory factory = FactoryImpl.getSAXFactory(_useServicesMechanism);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   745
                factory.setNamespaceAware(true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   747
                if (!_isNotSecureProcessing) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   748
                    try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   749
                        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
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
                    catch (org.xml.sax.SAXException e) {}
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   752
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   754
                SAXParser jaxpParser = factory.newSAXParser();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   755
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   756
                reader = jaxpParser.getXMLReader();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   757
                if (reader == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
                    reader = XMLReaderFactory.createXMLReader();
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   761
                _stylesheetPIHandler.setBaseId(baseId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   762
                reader.setContentHandler(_stylesheetPIHandler);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   763
                reader.parse(isource);
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
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   766
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   767
            if (_uriResolver != null ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   768
                _stylesheetPIHandler.setURIResolver(_uriResolver);
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
        } catch (StopParseException e ) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   772
          // startElement encountered so do not parse further
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   774
        } catch (javax.xml.parsers.ParserConfigurationException | org.xml.sax.SAXException | IOException e) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   775
             throw new TransformerConfigurationException(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   776
             "getAssociatedStylesheets failed", e);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   777
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   778
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   779
         return _stylesheetPIHandler.getAssociatedStylesheet();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   780
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
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   784
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   785
     * Create a Transformer object that copies the input document to the result.
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
     * @return A Transformer object that simply copies the source to the result.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   788
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   789
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   790
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   791
    public Transformer newTransformer()
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
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   794
        // create CatalogFeatures that is accessible by the Transformer
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   795
        // through the factory instance
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   796
        buildCatalogFeatures();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   797
        TransformerImpl result = new TransformerImpl(new Properties(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   798
            _indentNumber, this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   799
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   800
            result.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   801
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   802
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   803
        if (!_isNotSecureProcessing) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   804
            result.setSecureProcessing(true);
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
        return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   807
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   808
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
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   811
     * Process the Source into a Templates object, which is a a compiled
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   812
     * representation of the source. Note that this method should not be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   813
     * used with XSLTC, as the time-consuming compilation is done for each
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   814
     * and every transformation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   815
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   816
     * @return A Templates object that can be used to create Transformers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   817
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   818
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   819
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   820
    public Transformer newTransformer(Source source) throws
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   821
        TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   822
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   823
        final Templates templates = newTemplates(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   824
        final Transformer transformer = templates.newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   825
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   826
            transformer.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   827
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   828
        return(transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   829
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   830
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
     * Pass warning messages from the compiler to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   833
     */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   834
    private void passWarningsToListener(ArrayList<ErrorMsg> messages)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   835
        throws TransformerException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   836
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   837
        if (_errorListener == null || messages == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   838
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   839
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   840
        // Pass messages to listener, one by one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   841
        final int count = messages.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   842
        for (int pos = 0; pos < count; pos++) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   843
            ErrorMsg msg = messages.get(pos);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   844
            // Workaround for the TCK failure ErrorListener.errorTests.error001.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   845
            if (msg.isWarningError())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   846
                _errorListener.error(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   847
                    new TransformerConfigurationException(msg.toString()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   848
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   849
                _errorListener.warning(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   850
                    new TransformerConfigurationException(msg.toString()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   851
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   852
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   853
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   854
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   855
     * Pass error messages from the compiler to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   856
     */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   857
    private void passErrorsToListener(ArrayList<ErrorMsg> messages) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   858
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   859
            if (_errorListener == null || messages == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   860
                return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   861
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   862
            // Pass messages to listener, one by one
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   863
            final int count = messages.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   864
            for (int pos = 0; pos < count; pos++) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   865
                String message = messages.get(pos).toString();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   866
                _errorListener.error(new TransformerException(message));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   867
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   868
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   869
        catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   870
            // nada
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   874
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   875
     * javax.xml.transform.sax.TransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   876
     * Process the Source into a Templates object, which is a a compiled
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   877
     * representation of the source.
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
     * @param source The input stylesheet - DOMSource not supported!!!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   880
     * @return A Templates object that can be used to create Transformers.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   881
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   882
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   883
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   884
    public Templates newTemplates(Source source)
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
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   887
        TemplatesImpl templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   888
        // If the _useClasspath attribute is true, try to load the translet from
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   889
        // the CLASSPATH and create a template object using the loaded
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   890
        // translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   891
        if (_useClasspath) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   892
            String transletName = getTransletBaseName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   893
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   894
            if (_packageName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   895
                transletName = _packageName + "." + transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   896
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   897
            try {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   898
                final Class clazz = ObjectFactory.findProviderClass(transletName, true);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   899
                resetTransientAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   900
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   901
                templates = new TemplatesImpl(new Class[]{clazz}, transletName, null, _indentNumber, this);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   902
                if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   903
                    templates.setURIResolver(_uriResolver);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   904
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   905
                return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   906
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   907
            catch (ClassNotFoundException cnfe) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   908
                ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, transletName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   909
                throw new TransformerConfigurationException(err.toString());
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 (Exception e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   912
                ErrorMsg err = new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   913
                                     new ErrorMsg(ErrorMsg.RUNTIME_ERROR_KEY)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   914
                                     + e.getMessage());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   915
                throw new TransformerConfigurationException(err.toString());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   916
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   917
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   918
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   919
        // If _autoTranslet is true, we will try to load the bytecodes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   920
        // from the translet classes without compiling the stylesheet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   921
        if (_autoTranslet)  {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
   922
            byte[][] bytecodes;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   923
            String transletClassName = getTransletBaseName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   924
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   925
            if (_packageName != null)
39909
00e4298ae168 8162598: XSLTC transformer swallows empty namespace declaration which is needed to undeclare default namespace
clanger
parents: 39907
diff changeset
   926
                transletClassName = _packageName + "." + transletClassName;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   927
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   928
            if (_jarFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   929
                bytecodes = getBytecodesFromJar(source, transletClassName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   930
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   931
                bytecodes = getBytecodesFromClasses(source, transletClassName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   932
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   933
            if (bytecodes != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   934
                if (_debug) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
                    if (_jarFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   936
                        System.err.println(new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   937
                            ErrorMsg.TRANSFORM_WITH_JAR_STR, transletClassName, _jarFileName));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   938
                    else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   939
                        System.err.println(new ErrorMsg(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   940
                            ErrorMsg.TRANSFORM_WITH_TRANSLET_STR, transletClassName));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   941
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   942
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   943
                // Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
                // after each newTemplates() call.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   945
                resetTransientAttributes();
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   946
                templates = new TemplatesImpl(bytecodes, transletClassName, null, _indentNumber, this);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   947
                if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   948
                    templates.setURIResolver(_uriResolver);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   949
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   950
                return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   951
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   952
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   953
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   954
        // Create and initialize a stylesheet compiler
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   955
        final XSLTC xsltc = new XSLTC(_useServicesMechanism, _xmlFeatures);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   956
        if (_debug) xsltc.setDebug(true);
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   957
        if (_enableInlining)
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   958
                xsltc.setTemplateInlining(true);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   959
        else
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   960
                xsltc.setTemplateInlining(false);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   961
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   962
        if (!_isNotSecureProcessing) xsltc.setSecureProcessing(true);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   963
        xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, _accessExternalStylesheet);
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
   964
        xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18890
diff changeset
   965
        xsltc.setProperty(XalanConstants.SECURITY_MANAGER, _xmlSecurityManager);
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   966
        xsltc.setProperty(XalanConstants.JDK_EXTENSION_CLASSLOADER, _extensionClassLoader);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   967
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   968
        // set Catalog features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   969
        buildCatalogFeatures();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   970
        xsltc.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   971
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   972
        xsltc.init();
29945
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   973
        if (!_isNotSecureProcessing)
4912169d22d3 8040228: TransformerConfigurationException occurs with security manager, FSP and XSLT Ext
aefimov
parents: 25868
diff changeset
   974
            _xsltcExtensionFunctions = xsltc.getExternalExtensionFunctions();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   975
        // Set a document loader (for xsl:include/import) if defined
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   976
        if (_uriResolver != null || ( _catalogFiles != null
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
   977
                && _xmlFeatures.getFeature(JdkXmlFeatures.XmlFeature.USE_CATALOG))) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   978
            xsltc.setSourceLoader(this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   979
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   980
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   981
        // Pass parameters to the Parser to make sure it locates the correct
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   982
        // <?xml-stylesheet ...?> PI in an XML input document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   983
        if ((_piParams != null) && (_piParams.get(source) != null)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   984
            // Get the parameters for this Source object
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29945
diff changeset
   985
            PIParamWrapper p = _piParams.get(source);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   986
            // 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
   987
            if (p != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   988
                xsltc.setPIParameters(p._media, p._title, p._charset);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   989
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   990
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   991
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   992
        // Set the attributes for translet generation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   993
        int outputType = XSLTC.BYTEARRAY_OUTPUT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   994
        if (_generateTranslet || _autoTranslet) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   995
            // Set the translet name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   996
            xsltc.setClassName(getTransletBaseName(source));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   997
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   998
            if (_destinationDirectory != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   999
                xsltc.setDestDirectory(_destinationDirectory);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1000
            else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1001
                String xslName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1002
                if (xslName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1003
                    File xslFile = new File(xslName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1004
                    String xslDir = xslFile.getParent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1006
                    if (xslDir != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1007
                        xsltc.setDestDirectory(xslDir);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1008
                }
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1011
            if (_packageName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1012
                xsltc.setPackageName(_packageName);
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
            if (_jarFileName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1015
                xsltc.setJarFileName(_jarFileName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1016
                outputType = XSLTC.BYTEARRAY_AND_JAR_OUTPUT;
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
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1019
                outputType = XSLTC.BYTEARRAY_AND_FILE_OUTPUT;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1020
        }
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
        // Compile the stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1023
        final InputSource input = Util.getInputSource(xsltc, source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1024
        byte[][] bytecodes = xsltc.compile(null, input, outputType);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1025
        final String transletName = xsltc.getClassName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1026
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1027
        // Output to the jar file if the jar file name is set.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1028
        if ((_generateTranslet || _autoTranslet)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1029
                && bytecodes != null && _jarFileName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1030
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1031
                xsltc.outputToJar();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1032
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1033
            catch (java.io.IOException e) { }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1034
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1035
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1036
        // Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1037
        // after each newTemplates() call.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1038
        resetTransientAttributes();
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
        // Pass compiler warnings to the error listener
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1041
        if (_errorListener != this) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1042
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1043
                passWarningsToListener(xsltc.getWarnings());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1044
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1045
            catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1046
                throw new TransformerConfigurationException(e);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1047
            }
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
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1050
            xsltc.printWarnings();
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
        // Check that the transformation went well before returning
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1054
        if (bytecodes == null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1055
            ArrayList<ErrorMsg> errs = xsltc.getErrors();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1056
            ErrorMsg err;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1057
            if (errs != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1058
                err = errs.get(errs.size()-1);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1059
            } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1060
                err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1061
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1062
            Throwable cause = err.getCause();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1063
            TransformerConfigurationException exc;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1064
            if (cause != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1065
                exc =  new TransformerConfigurationException(cause.getMessage(), cause);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1066
            } else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1067
                exc =  new TransformerConfigurationException(err.toString());
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1068
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1069
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1070
            // Pass compiler errors to the error listener
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1071
            if (_errorListener != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1072
                passErrorsToListener(xsltc.getErrors());
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
                // As required by TCK 1.2, send a fatalError to the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1075
                // error listener because compilation of the stylesheet
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1076
                // failed and no further processing will be possible.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1077
                try {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1078
                    _errorListener.fatalError(exc);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1079
                } catch (TransformerException te) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1080
                    // well, we tried.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1081
                }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1082
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1083
            else {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1084
                xsltc.printErrors();
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
            throw exc;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 16953
diff changeset
  1087
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1088
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1089
        templates = new TemplatesImpl(bytecodes, transletName, xsltc.getOutputProperties(),
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1090
                _indentNumber, this);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1091
        if (_uriResolver != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1092
            templates.setURIResolver(_uriResolver);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1093
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1094
        return templates;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1095
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1096
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1097
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1098
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1099
     * Get a TemplatesHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1100
     * events into a Templates object.
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
     * @return A TemplatesHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1103
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1104
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1105
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1106
    public TemplatesHandler newTemplatesHandler()
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
    {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1109
        // create CatalogFeatures that is accessible by the Handler
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1110
        // through the factory instance
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1111
        buildCatalogFeatures();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1112
        final TemplatesHandlerImpl handler =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1113
            new TemplatesHandlerImpl(_indentNumber, this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1114
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1115
            handler.setURIResolver(_uriResolver);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1116
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1117
        return handler;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1118
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1119
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
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1122
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1123
     * events into a Result. This method will return a pure copy transformer.
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
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1126
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1127
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1128
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1129
    public TransformerHandler newTransformerHandler()
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
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1132
        final Transformer transformer = newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1133
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1134
            transformer.setURIResolver(_uriResolver);
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
        return new TransformerHandlerImpl((TransformerImpl) transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1137
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1138
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
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1141
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1142
     * events into a Result, based on the transformation instructions
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1143
     * specified by the argument.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1144
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1145
     * @param src The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1146
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1147
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1148
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1149
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1150
    public TransformerHandler newTransformerHandler(Source src)
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
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1153
        final Transformer transformer = newTransformer(src);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1154
        if (_uriResolver != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1155
            transformer.setURIResolver(_uriResolver);
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
        return new TransformerHandlerImpl((TransformerImpl) transformer);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1158
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1159
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
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1162
     * Get a TransformerHandler object that can process SAX ContentHandler
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1163
     * events into a Result, based on the transformation instructions
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1164
     * specified by the argument.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1165
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1166
     * @param templates Represents a pre-processed stylesheet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1167
     * @return A TransformerHandler object that can handle SAX events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1168
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1169
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1170
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1171
    public TransformerHandler newTransformerHandler(Templates templates)
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
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1174
        final Transformer transformer = templates.newTransformer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1175
        final TransformerImpl internal = (TransformerImpl)transformer;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1176
        return new TransformerHandlerImpl(internal);
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1179
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1180
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1181
     * Create an XMLFilter that uses the given source as the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1182
     * transformation instructions.
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
     * @param src The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1185
     * @return An XMLFilter object, or null if this feature is not supported.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1186
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1187
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1188
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1189
    public XMLFilter newXMLFilter(Source src)
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
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1192
        Templates templates = newTemplates(src);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1193
        if (templates == null) return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1194
        return newXMLFilter(templates);
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1197
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1198
     * javax.xml.transform.sax.SAXTransformerFactory implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1199
     * Create an XMLFilter that uses the given source as the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1200
     * transformation instructions.
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
     * @param templates The source of the transformation instructions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1203
     * @return An XMLFilter object, or null if this feature is not supported.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1204
     * @throws TransformerConfigurationException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1205
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1206
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1207
    public XMLFilter newXMLFilter(Templates templates)
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
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1210
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1211
            return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1212
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1213
        catch (TransformerConfigurationException e1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1214
            if (_errorListener != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1215
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1216
                    _errorListener.fatalError(e1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1217
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1218
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1219
                catch (TransformerException e2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1220
                    new TransformerConfigurationException(e2);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1221
                }
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
            throw e1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1224
        }
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
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1228
     * Receive notification of a recoverable error.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1229
     * The transformer must continue to provide normal parsing events after
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1230
     * invoking this method. It should still be possible for the application
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1231
     * to process the document through to the end.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1232
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1233
     * @param e The warning information encapsulated in a transformer
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1234
     * exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1235
     * @throws TransformerException if the application chooses to discontinue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1236
     * the transformation (always does in our case).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1237
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1238
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1239
    public void error(TransformerException e)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1240
        throws TransformerException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1241
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1242
        Throwable wrapped = e.getException();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1243
        if (wrapped != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1244
            System.err.println(new ErrorMsg(ErrorMsg.ERROR_PLUS_WRAPPED_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1245
                                            e.getMessageAndLocation(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1246
                                            wrapped.getMessage()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1247
        } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1248
            System.err.println(new ErrorMsg(ErrorMsg.ERROR_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1249
                                            e.getMessageAndLocation()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1250
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1251
        throw e;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1252
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1253
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1254
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1255
     * Receive notification of a non-recoverable error.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1256
     * The application must assume that the transformation cannot continue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1257
     * after the Transformer has invoked this method, and should continue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1258
     * (if at all) only to collect addition error messages. In fact,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1259
     * Transformers are free to stop reporting events once this method has
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1260
     * been invoked.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1261
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1262
     * @param e warning information encapsulated in a transformer
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1263
     * exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1264
     * @throws TransformerException if the application chooses to discontinue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1265
     * the transformation (always does in our case).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1266
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1267
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1268
    public void fatalError(TransformerException e)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1269
        throws TransformerException
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
        Throwable wrapped = e.getException();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1272
        if (wrapped != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1273
            System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_PLUS_WRAPPED_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1274
                                            e.getMessageAndLocation(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1275
                                            wrapped.getMessage()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1276
        } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1277
            System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1278
                                            e.getMessageAndLocation()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1279
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1280
        throw e;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1281
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1282
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1283
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1284
     * Receive notification of a warning.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1285
     * Transformers can use this method to report conditions that are not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1286
     * errors or fatal errors. The default behaviour is to take no action.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1287
     * After invoking this method, the Transformer must continue with the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1288
     * transformation. It should still be possible for the application to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1289
     * process the document through to the end.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1290
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1291
     * @param e The warning information encapsulated in a transformer
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1292
     * exception.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1293
     * @throws TransformerException if the application chooses to discontinue
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1294
     * the transformation (never does in our case).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1295
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1296
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1297
    public void warning(TransformerException e)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1298
        throws TransformerException
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
        Throwable wrapped = e.getException();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1301
        if (wrapped != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1302
            System.err.println(new ErrorMsg(ErrorMsg.WARNING_PLUS_WRAPPED_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1303
                                            e.getMessageAndLocation(),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1304
                                            wrapped.getMessage()));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1305
        } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1306
            System.err.println(new ErrorMsg(ErrorMsg.WARNING_MSG,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1307
                                            e.getMessageAndLocation()));
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
    }
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
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1312
     * This method implements XSLTC's SourceLoader interface. It is used to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1313
     * 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
  1314
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1315
     * @param href The URI of the document to load
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1316
     * @param context The URI of the currently loaded document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1317
     * @param xsltc The compiler that resuests the document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1318
     * @return An InputSource with the loaded document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1319
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1320
    @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1321
    public InputSource loadSource(String href, String context, XSLTC xsltc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1322
        try {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1323
            Source source = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1324
            if (_uriResolver != null) {
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1325
                source = _uriResolver.resolve(href, context);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1326
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1327
            if (source == null && _catalogFiles != null &&
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1328
                    _xmlFeatures.getFeature(JdkXmlFeatures.XmlFeature.USE_CATALOG)) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1329
                if (_catalogUriResolver == null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1330
                    _catalogUriResolver = CatalogManager.catalogUriResolver(_catalogFeatures);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1331
                }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1332
                source = _catalogUriResolver.resolve(href, context);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1333
            }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1334
            if (source != null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1335
                return Util.getInputSource(xsltc, source);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1336
            }
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
        catch (TransformerException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1339
            // should catch it when the resolver explicitly throws the exception
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1340
            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
  1341
            xsltc.getParser().reportError(Constants.FATAL, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1342
        }
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
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1345
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1346
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1347
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1348
     * Build the CatalogFeatures object when a newTemplates or newTransformer is
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1349
     * created. This will read any System Properties for the CatalogFeatures that
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1350
     * may have been set.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1351
     */
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1352
    private CatalogFeatures buildCatalogFeatures() {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1353
        // 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
  1354
        if (_catalogFeatures == null) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1355
            _catalogFeatures = cfBuilder.build();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1356
        }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1357
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1358
        // update fields
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1359
        _catalogFiles = _catalogFeatures.get(Feature.FILES);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1360
        _catalogDefer = _catalogFeatures.get(Feature.DEFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1361
        _catalogPrefer = _catalogFeatures.get(Feature.PREFER);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1362
        _catalogResolve = _catalogFeatures.get(Feature.RESOLVE);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1363
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1364
        return _catalogFeatures;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1365
    }
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1366
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 36520
diff changeset
  1367
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1368
     * Reset the per-session attributes to their default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1369
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1370
    private void resetTransientAttributes() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1371
        _transletName = DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1372
        _destinationDirectory = null;
36520
cb52aa47ff0a 8142968: Module System implementation
alanb
parents: 34463
diff changeset
  1373
        _packageName = DEFAULT_TRANSLATE_PACKAGE;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1374
        _jarFileName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1375
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1376
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
     * Load the translet classes from local .class files and return
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1379
     * the bytecode array.
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
     * @param source The xsl source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1382
     * @param fullClassName The full name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1383
     * @return The bytecode array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1384
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1385
    private byte[][] getBytecodesFromClasses(Source source, String fullClassName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1386
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1387
        if (fullClassName == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1388
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1389
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1390
        String xslFileName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1391
        File xslFile = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1392
        if (xslFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1393
            xslFile = new File(xslFileName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1394
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1395
        // Find the base name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1396
        final String transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1397
        int lastDotIndex = fullClassName.lastIndexOf('.');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1398
        if (lastDotIndex > 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1399
            transletName = fullClassName.substring(lastDotIndex+1);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1400
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1401
            transletName = fullClassName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1402
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1403
        // Construct the path name for the translet class file
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1404
        String transletPath = fullClassName.replace('.', '/');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1405
        if (_destinationDirectory != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1406
            transletPath = _destinationDirectory + "/" + transletPath + ".class";
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
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1409
            if (xslFile != null && xslFile.getParent() != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1410
                transletPath = xslFile.getParent() + "/" + transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1411
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1412
                transletPath = transletPath + ".class";
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1415
        // Return null if the translet class file does not exist.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1416
        File transletFile = new File(transletPath);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1417
        if (!transletFile.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1418
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1419
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1420
        // Compare the timestamps of the translet and the xsl file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1421
        // If the translet is older than the xsl file, return null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1422
        // so that the xsl file is used for the transformation and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1423
        // the translet is regenerated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1424
        if (xslFile != null && xslFile.exists()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1425
            long xslTimestamp = xslFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1426
            long transletTimestamp = transletFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1427
            if (transletTimestamp < xslTimestamp)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1428
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1429
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1430
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1431
        // Load the translet into a bytecode array.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1432
        Vector bytecodes = new Vector();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1433
        int fileLength = (int)transletFile.length();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1434
        if (fileLength > 0) {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1435
            FileInputStream input;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1436
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1437
                input = new FileInputStream(transletFile);
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
            catch (FileNotFoundException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1440
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1441
            }
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
            byte[] bytes = new byte[fileLength];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1444
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1445
                readFromInputStream(bytes, input, fileLength);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1446
                input.close();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1447
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1448
            catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1449
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1450
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1451
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1452
            bytecodes.addElement(bytes);
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
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1455
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1456
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1457
        // Find the parent directory of the translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1458
        String transletParentDir = transletFile.getParent();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1459
        if (transletParentDir == null)
16953
a44e04deb948 6657673: Issues with JAXP
joehw
parents: 12458
diff changeset
  1460
            transletParentDir = SecuritySupport.getSystemProperty("user.dir");
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1461
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1462
        File transletParentFile = new File(transletParentDir);
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
        // 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
  1465
        final String transletAuxPrefix = transletName + "$";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1466
        File[] auxfiles = transletParentFile.listFiles(new FilenameFilter() {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1467
                @Override
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1468
                public boolean accept(File dir, String name)
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
                    return (name.endsWith(".class") && name.startsWith(transletAuxPrefix));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1471
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1472
              });
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1473
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1474
        // Load the auxiliary class files and add them to the bytecode array.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1475
        for (int i = 0; i < auxfiles.length; i++)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1476
        {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1477
            File auxfile = auxfiles[i];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1478
            int auxlength = (int)auxfile.length();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1479
            if (auxlength > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1480
                FileInputStream auxinput = null;
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
                    auxinput = new FileInputStream(auxfile);
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 (FileNotFoundException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1485
                    continue;
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
                byte[] bytes = new byte[auxlength];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1489
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1490
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1491
                    readFromInputStream(bytes, auxinput, auxlength);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1492
                    auxinput.close();
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
                catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1495
                    continue;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1496
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1497
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1498
                bytecodes.addElement(bytes);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1499
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1500
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1501
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1502
        // Convert the Vector of byte[] to byte[][].
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1503
        final int count = bytecodes.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1504
        if ( count > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1505
            final byte[][] result = new byte[count][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1506
            for (int i = 0; i < count; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1507
                result[i] = (byte[])bytecodes.elementAt(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1508
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1509
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1510
            return result;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1511
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1512
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1513
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1514
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1515
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
     * Load the translet classes from the jar file and return the bytecode.
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
     * @param source The xsl source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1520
     * @param fullClassName The full name of the translet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1521
     * @return The bytecode array
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1522
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1523
    private byte[][] getBytecodesFromJar(Source source, String fullClassName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1524
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1525
        String xslFileName = getStylesheetFileName(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1526
        File xslFile = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1527
        if (xslFileName != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1528
            xslFile = new File(xslFileName);
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
        // Construct the path for the jar file
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1531
        String jarPath;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1532
        if (_destinationDirectory != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1533
            jarPath = _destinationDirectory + "/" + _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1534
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1535
            if (xslFile != null && xslFile.getParent() != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1536
                jarPath = xslFile.getParent() + "/" + _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1537
            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1538
                jarPath = _jarFileName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1539
        }
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
        // Return null if the jar file does not exist.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1542
        File file = new File(jarPath);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1543
        if (!file.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1544
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1545
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1546
        // 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
  1547
        // if the xsl file is newer than the jar file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1548
        if (xslFile != null && xslFile.exists()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1549
            long xslTimestamp = xslFile.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1550
            long transletTimestamp = file.lastModified();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1551
            if (transletTimestamp < xslTimestamp)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1552
                return null;
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
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1555
        // Create a ZipFile object for the jar file
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1556
        ZipFile jarFile;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1557
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1558
            jarFile = new ZipFile(file);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1559
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1560
        catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1561
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1562
        }
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
        String transletPath = fullClassName.replace('.', '/');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1565
        String transletAuxPrefix = transletPath + "$";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1566
        String transletFullName = transletPath + ".class";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1567
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1568
        Vector bytecodes = new Vector();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1569
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1570
        // Iterate through all entries in the jar file to find the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1571
        // translet and auxiliary classes.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1572
        Enumeration entries = jarFile.entries();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1573
        while (entries.hasMoreElements())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1574
        {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1575
            ZipEntry entry = (ZipEntry)entries.nextElement();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1576
            String entryName = entry.getName();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1577
            if (entry.getSize() > 0 &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1578
                  (entryName.equals(transletFullName) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1579
                  (entryName.endsWith(".class") &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1580
                      entryName.startsWith(transletAuxPrefix))))
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
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1583
                    InputStream input = jarFile.getInputStream(entry);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1584
                    int size = (int)entry.getSize();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1585
                    byte[] bytes = new byte[size];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1586
                    readFromInputStream(bytes, input, size);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1587
                    input.close();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1588
                    bytecodes.addElement(bytes);
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
                catch (IOException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1591
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1592
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1593
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1594
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1595
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1596
        // Convert the Vector of byte[] to byte[][].
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1597
        final int count = bytecodes.size();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1598
        if (count > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1599
            final byte[][] result = new byte[count][1];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1600
            for (int i = 0; i < count; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1601
                result[i] = (byte[])bytecodes.elementAt(i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1602
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1603
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1604
            return result;
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
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1607
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1608
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1609
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
     * 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
  1612
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1613
     * @param bytes The byte array to store the input content.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1614
     * @param input The input stream.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1615
     * @param size The number of bytes to read.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1616
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1617
    private void readFromInputStream(byte[] bytes, InputStream input, int size)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1618
        throws IOException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1619
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1620
      int n = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1621
      int offset = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1622
      int length = size;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1623
      while (length > 0 && (n = input.read(bytes, offset, length)) > 0) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1624
          offset = offset + n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1625
          length = length - n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1626
      }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1627
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1628
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1629
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1630
     * Return the base class name of the translet.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1631
     * The translet name is resolved using the following rules:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1632
     * 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
  1633
     *    then _transletName is returned.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1634
     * 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
  1635
     * 3. return "GregorSamsa" if the result from step 2 is null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1636
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1637
     * @param source The input Source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1638
     * @return The name of the translet class
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1639
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1640
    private String getTransletBaseName(Source source)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1641
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1642
        String transletBaseName = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1643
        if (!_transletName.equals(DEFAULT_TRANSLET_NAME))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1644
            return _transletName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1645
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1646
            String systemId = source.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1647
            if (systemId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1648
                String baseName = Util.baseName(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1649
                if (baseName != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1650
                    baseName = Util.noExtName(baseName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1651
                    transletBaseName = Util.toJavaName(baseName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1652
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1653
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1654
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1655
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1656
        return (transletBaseName != null) ? transletBaseName : DEFAULT_TRANSLET_NAME;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1657
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1658
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1659
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1660
     *  Return the local file name from the systemId of the Source object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1661
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1662
     * @param source The Source
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1663
     * @return The file name in the local filesystem, or null if the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1664
     * systemId does not represent a local file.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1665
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1666
    private String getStylesheetFileName(Source source)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1667
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1668
        String systemId = source.getSystemId();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1669
        if (systemId != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1670
            File file = new File(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1671
            if (file.exists())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1672
                return systemId;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1673
            else {
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1674
                URL url;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1675
                try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1676
                    url = new URL(systemId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1677
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1678
                catch (MalformedURLException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1679
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1680
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1681
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1682
                if ("file".equals(url.getProtocol()))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1683
                    return url.getFile();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1684
                else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1685
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1686
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1687
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1688
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1689
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1690
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1691
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1692
    /**
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1693
     * Returns a new instance of the XSLTC DTM Manager service.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1694
     */
18352
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1695
    protected final XSLTCDTMManager createNewDTMManagerInstance() {
a1e183c996d6 8013434: Xalan and Xerces internal ObjectFactory need rework
dfuchs
parents: 17991
diff changeset
  1696
        return XSLTCDTMManager.createNewDTMManagerInstance();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1697
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1698
}