< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *     http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xalan.internal.xsltc.trax;
  22 


  30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
  31 import java.util.ArrayList;
  32 import javax.xml.XMLConstants;
  33 import javax.xml.catalog.CatalogFeatures;
  34 import javax.xml.transform.Source;
  35 import javax.xml.transform.Templates;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.URIResolver;
  38 import javax.xml.transform.sax.TemplatesHandler;
  39 import jdk.xml.internal.JdkXmlFeatures;
  40 import org.xml.sax.Attributes;
  41 import org.xml.sax.ContentHandler;
  42 import org.xml.sax.InputSource;
  43 import org.xml.sax.Locator;
  44 import org.xml.sax.SAXException;
  45 
  46 /**
  47  * Implementation of a JAXP1.1 TemplatesHandler
  48  * @author Morten Jorgensen
  49  * @author Santiago Pericas-Geertsen

  50  */
  51 public class TemplatesHandlerImpl
  52     implements ContentHandler, TemplatesHandler, SourceLoader
  53 {
  54     /**
  55      * System ID for this stylesheet.
  56      */
  57     private String _systemId;
  58 
  59     /**
  60      * Number of spaces to add for output indentation.
  61      */
  62     private int _indentNumber;
  63 
  64     /**
  65      * This URIResolver is passed to all Transformers.
  66      */
  67     private URIResolver _uriResolver = null;
  68 
  69     /**


  74 
  75     /**
  76      * A reference to XSLTC's parser object.
  77      */
  78     private Parser _parser = null;
  79 
  80     /**
  81      * The created Templates object.
  82      */
  83     private TemplatesImpl _templates = null;
  84 
  85     // Catalog features
  86     CatalogFeatures _catalogFeatures;
  87 
  88     // Catalog is enabled by default
  89     boolean _useCatalog = true;
  90 
  91     /**
  92      * Default constructor
  93      */
  94     protected TemplatesHandlerImpl(int indentNumber,
  95         TransformerFactoryImpl tfactory)
  96     {
  97         _indentNumber = indentNumber;
  98         _tfactory = tfactory;
  99 
 100         // Instantiate XSLTC and get reference to parser object
 101         XSLTC xsltc = new XSLTC(tfactory.getJdkXmlFeatures());
 102         if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING))
 103             xsltc.setSecureProcessing(true);
 104 
 105         xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET,
 106                 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET));
 107         xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
 108                 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD));
 109         xsltc.setProperty(XalanConstants.SECURITY_MANAGER,
 110                 tfactory.getAttribute(XalanConstants.SECURITY_MANAGER));
 111 
 112 
 113         if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING)))
 114             xsltc.setTemplateInlining(true);
 115         else
 116             xsltc.setTemplateInlining(false);
 117 
 118         _useCatalog = tfactory.getFeature(XMLConstants.USE_CATALOG);
 119         _catalogFeatures = (CatalogFeatures)tfactory.getAttribute(JdkXmlFeatures.CATALOG_FEATURES);
 120         xsltc.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures);
 121 


   1 /*
   2  * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *     http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xalan.internal.xsltc.trax;
  22 


  30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
  31 import java.util.ArrayList;
  32 import javax.xml.XMLConstants;
  33 import javax.xml.catalog.CatalogFeatures;
  34 import javax.xml.transform.Source;
  35 import javax.xml.transform.Templates;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.URIResolver;
  38 import javax.xml.transform.sax.TemplatesHandler;
  39 import jdk.xml.internal.JdkXmlFeatures;
  40 import org.xml.sax.Attributes;
  41 import org.xml.sax.ContentHandler;
  42 import org.xml.sax.InputSource;
  43 import org.xml.sax.Locator;
  44 import org.xml.sax.SAXException;
  45 
  46 /**
  47  * Implementation of a JAXP1.1 TemplatesHandler
  48  * @author Morten Jorgensen
  49  * @author Santiago Pericas-Geertsen
  50  * @LastModified: July 2019
  51  */
  52 public class TemplatesHandlerImpl
  53     implements ContentHandler, TemplatesHandler, SourceLoader
  54 {
  55     /**
  56      * System ID for this stylesheet.
  57      */
  58     private String _systemId;
  59 
  60     /**
  61      * Number of spaces to add for output indentation.
  62      */
  63     private int _indentNumber;
  64 
  65     /**
  66      * This URIResolver is passed to all Transformers.
  67      */
  68     private URIResolver _uriResolver = null;
  69 
  70     /**


  75 
  76     /**
  77      * A reference to XSLTC's parser object.
  78      */
  79     private Parser _parser = null;
  80 
  81     /**
  82      * The created Templates object.
  83      */
  84     private TemplatesImpl _templates = null;
  85 
  86     // Catalog features
  87     CatalogFeatures _catalogFeatures;
  88 
  89     // Catalog is enabled by default
  90     boolean _useCatalog = true;
  91 
  92     /**
  93      * Default constructor
  94      */
  95     protected TemplatesHandlerImpl(int indentNumber, TransformerFactoryImpl tfactory,
  96             boolean hasUserErrListener)
  97     {
  98         _indentNumber = indentNumber;
  99         _tfactory = tfactory;
 100 
 101         // Instantiate XSLTC and get reference to parser object
 102         XSLTC xsltc = new XSLTC(tfactory.getJdkXmlFeatures(), hasUserErrListener);
 103         if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING))
 104             xsltc.setSecureProcessing(true);
 105 
 106         xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET,
 107                 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET));
 108         xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
 109                 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD));
 110         xsltc.setProperty(XalanConstants.SECURITY_MANAGER,
 111                 tfactory.getAttribute(XalanConstants.SECURITY_MANAGER));
 112 
 113 
 114         if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING)))
 115             xsltc.setTemplateInlining(true);
 116         else
 117             xsltc.setTemplateInlining(false);
 118 
 119         _useCatalog = tfactory.getFeature(XMLConstants.USE_CATALOG);
 120         _catalogFeatures = (CatalogFeatures)tfactory.getAttribute(JdkXmlFeatures.CATALOG_FEATURES);
 121         xsltc.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures);
 122 


< prev index next >