1 /* |
1 /* |
2 * reserved comment block |
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT REMOVE OR ALTER! |
|
4 */ |
3 */ |
5 /* |
4 /* |
6 * Copyright 2001-2004 The Apache Software Foundation. |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * |
6 * contributor license agreements. See the NOTICE file distributed with |
8 * Licensed under the Apache License, Version 2.0 (the "License"); |
7 * this work for additional information regarding copyright ownership. |
9 * you may not use this file except in compliance with the License. |
8 * The ASF licenses this file to You under the Apache License, Version 2.0 |
10 * You may obtain a copy of the License at |
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 * |
11 * |
12 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * http://www.apache.org/licenses/LICENSE-2.0 |
13 * |
13 * |
14 * Unless required by applicable law or agreed to in writing, software |
14 * Unless required by applicable law or agreed to in writing, software |
15 * distributed under the License is distributed on an "AS IS" BASIS, |
15 * distributed under the License is distributed on an "AS IS" BASIS, |
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 * See the License for the specific language governing permissions and |
17 * See the License for the specific language governing permissions and |
18 * limitations under the License. |
18 * limitations under the License. |
19 */ |
19 */ |
20 /* |
|
21 * $Id: TemplatesHandlerImpl.java,v 1.2.4.1 2005/09/06 12:09:03 pvedula Exp $ |
|
22 */ |
|
23 |
20 |
24 package com.sun.org.apache.xalan.internal.xsltc.trax; |
21 package com.sun.org.apache.xalan.internal.xsltc.trax; |
25 |
22 |
26 import javax.xml.XMLConstants; |
|
27 import javax.xml.transform.Source; |
|
28 import javax.xml.transform.Templates; |
|
29 import javax.xml.transform.TransformerException; |
|
30 import javax.xml.transform.URIResolver; |
|
31 import javax.xml.transform.sax.TemplatesHandler; |
|
32 import com.sun.org.apache.xalan.internal.XalanConstants; |
23 import com.sun.org.apache.xalan.internal.XalanConstants; |
33 import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException; |
24 import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException; |
34 import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser; |
25 import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser; |
35 import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; |
26 import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; |
36 import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet; |
27 import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet; |
37 import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode; |
28 import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode; |
38 import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; |
29 import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; |
39 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; |
30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; |
40 |
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; |
41 import org.xml.sax.ContentHandler; |
42 import org.xml.sax.InputSource; |
42 import org.xml.sax.InputSource; |
43 import org.xml.sax.Locator; |
43 import org.xml.sax.Locator; |
44 import org.xml.sax.SAXException; |
44 import org.xml.sax.SAXException; |
45 import org.xml.sax.Attributes; |
|
46 |
|
47 import java.util.Vector; |
|
48 |
45 |
49 /** |
46 /** |
50 * Implementation of a JAXP1.1 TemplatesHandler |
47 * Implementation of a JAXP1.1 TemplatesHandler |
51 * @author Morten Jorgensen |
48 * @author Morten Jorgensen |
52 * @author Santiago Pericas-Geertsen |
49 * @author Santiago Pericas-Geertsen |
83 /** |
80 /** |
84 * The created Templates object. |
81 * The created Templates object. |
85 */ |
82 */ |
86 private TemplatesImpl _templates = null; |
83 private TemplatesImpl _templates = null; |
87 |
84 |
|
85 // Catalog features |
|
86 CatalogFeatures _catalogFeatures; |
|
87 |
|
88 // Catalog is enabled by default |
|
89 boolean _useCatalog = true; |
|
90 |
88 /** |
91 /** |
89 * Default constructor |
92 * Default constructor |
90 */ |
93 */ |
91 protected TemplatesHandlerImpl(int indentNumber, |
94 protected TemplatesHandlerImpl(int indentNumber, |
92 TransformerFactoryImpl tfactory) |
95 TransformerFactoryImpl tfactory) |
93 { |
96 { |
94 _indentNumber = indentNumber; |
97 _indentNumber = indentNumber; |
95 _tfactory = tfactory; |
98 _tfactory = tfactory; |
96 |
99 |
97 // Instantiate XSLTC and get reference to parser object |
100 // Instantiate XSLTC and get reference to parser object |
98 XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism(), tfactory.getFeatureManager()); |
101 XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism(), tfactory.getJdkXmlFeatures()); |
99 if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) |
102 if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) |
100 xsltc.setSecureProcessing(true); |
103 xsltc.setSecureProcessing(true); |
101 |
104 |
102 xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, |
105 xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, |
103 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)); |
106 (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)); |
266 _templates.setURIResolver(_uriResolver); |
274 _templates.setURIResolver(_uriResolver); |
267 } |
275 } |
268 } |
276 } |
269 } |
277 } |
270 else { |
278 else { |
271 StringBuffer errorMessage = new StringBuffer(); |
279 StringBuilder errorMessage = new StringBuilder(); |
272 Vector errors = _parser.getErrors(); |
280 ArrayList<ErrorMsg> errors = _parser.getErrors(); |
273 final int count = errors.size(); |
281 final int count = errors.size(); |
274 for (int i = 0; i < count; i++) { |
282 for (int i = 0; i < count; i++) { |
275 if (errorMessage.length() > 0) |
283 if (errorMessage.length() > 0) |
276 errorMessage.append('\n'); |
284 errorMessage.append('\n'); |
277 errorMessage.append(errors.elementAt(i).toString()); |
285 errorMessage.append(errors.get(i).toString()); |
278 } |
286 } |
279 throw new SAXException(ErrorMsg.JAXP_COMPILE_ERR, new TransformerException(errorMessage.toString())); |
287 throw new SAXException(ErrorMsg.JAXP_COMPILE_ERR, new TransformerException(errorMessage.toString())); |
280 } |
288 } |
281 } |
289 } |
282 catch (CompilerException e) { |
290 catch (CompilerException e) { |