src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
3 */ |
3 */ |
4 /* |
4 /* |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * contributor license agreements. See the NOTICE file distributed with |
6 * contributor license agreements. See the NOTICE file distributed with |
7 * this work for additional information regarding copyright ownership. |
7 * this work for additional information regarding copyright ownership. |
40 import java.util.Properties; |
40 import java.util.Properties; |
41 import java.util.Stack; |
41 import java.util.Stack; |
42 import java.util.StringTokenizer; |
42 import java.util.StringTokenizer; |
43 import javax.xml.XMLConstants; |
43 import javax.xml.XMLConstants; |
44 import javax.xml.catalog.CatalogFeatures; |
44 import javax.xml.catalog.CatalogFeatures; |
|
45 import jdk.xml.internal.ErrorHandlerProxy; |
45 import jdk.xml.internal.JdkXmlFeatures; |
46 import jdk.xml.internal.JdkXmlFeatures; |
46 import jdk.xml.internal.JdkXmlUtils; |
47 import jdk.xml.internal.JdkXmlUtils; |
47 import jdk.xml.internal.SecuritySupport; |
48 import jdk.xml.internal.SecuritySupport; |
48 import org.xml.sax.Attributes; |
49 import org.xml.sax.Attributes; |
49 import org.xml.sax.ContentHandler; |
50 import org.xml.sax.ContentHandler; |
59 * @author Jacek Ambroziak |
60 * @author Jacek Ambroziak |
60 * @author Santiago Pericas-Geertsen |
61 * @author Santiago Pericas-Geertsen |
61 * @author G. Todd Miller |
62 * @author G. Todd Miller |
62 * @author Morten Jorgensen |
63 * @author Morten Jorgensen |
63 * @author Erwin Bolwidt <ejb@klomp.org> |
64 * @author Erwin Bolwidt <ejb@klomp.org> |
64 * @LastModified: Nov 2017 |
65 * @LastModified: July 2019 |
65 */ |
66 */ |
66 public class Parser implements Constants, ContentHandler { |
67 public class Parser implements Constants, ContentHandler { |
67 |
68 |
68 private static final String XSL = "xsl"; // standard prefix |
69 private static final String XSL = "xsl"; // standard prefix |
69 private static final String TRANSLET = "translet"; // extension prefix |
70 private static final String TRANSLET = "translet"; // extension prefix |
96 |
97 |
97 private int _currentImportPrecedence; |
98 private int _currentImportPrecedence; |
98 |
99 |
99 private boolean _overrideDefaultParser; |
100 private boolean _overrideDefaultParser; |
100 |
101 |
101 public Parser(XSLTC xsltc, boolean useOverrideDefaultParser) { |
102 // flag indicates whether there's an user's ErrorListener |
|
103 private boolean _hasUserErrListener; |
|
104 |
|
105 public Parser(XSLTC xsltc, boolean useOverrideDefaultParser, boolean hasUserErrListener) { |
102 _xsltc = xsltc; |
106 _xsltc = xsltc; |
103 _overrideDefaultParser = useOverrideDefaultParser; |
107 _overrideDefaultParser = useOverrideDefaultParser; |
|
108 _hasUserErrListener = hasUserErrListener; |
104 } |
109 } |
105 |
110 |
106 public void init() { |
111 public void init() { |
107 _qNames = new HashMap<>(512); |
112 _qNames = new HashMap<>(512); |
108 _namespaces = new HashMap<>(); |
113 _namespaces = new HashMap<>(); |
424 */ |
429 */ |
425 public SyntaxTreeNode parse(XMLReader reader, InputSource input) { |
430 public SyntaxTreeNode parse(XMLReader reader, InputSource input) { |
426 try { |
431 try { |
427 // Parse the input document and build the abstract syntax tree |
432 // Parse the input document and build the abstract syntax tree |
428 reader.setContentHandler(this); |
433 reader.setContentHandler(this); |
|
434 if (_hasUserErrListener) { |
|
435 // Set a ErrorHandler proxy to pass any parsing error on to be handled |
|
436 // by the user's ErrorListener |
|
437 reader.setErrorHandler(new ErrorHandlerProxy()); |
|
438 } |
429 reader.parse(input); |
439 reader.parse(input); |
430 // Find the start of the stylesheet within the tree |
440 // Find the start of the stylesheet within the tree |
431 return getStylesheet(_root); |
441 return getStylesheet(_root); |
432 } |
442 } |
433 catch (IOException e) { |
443 catch (IOException e) { |