aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclanger <none@none>2016-07-31 23:14:27 +0200
committerclanger <none@none>2016-07-31 23:14:27 +0200
commitc1898d22d2e0d553419bb3a473ca6be28e591603 (patch)
treec6f4d5344813552c1f2c9cdb3430f64502b76aaa
parent2ddee008ec27ad84763a6aad8e02ffb0a9b9755b (diff)
downloadjdk8u_jaxp-c1898d22d2e0d553419bb3a473ca6be28e591603.tar.gz
8162598: XSLTC transformer swallows empty namespace declaration which is needed to undeclare default namespace
Reviewed-by: joehw, dfuchs
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java46
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java82
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java4
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java20
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java14
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java39
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java75
7 files changed, 113 insertions, 167 deletions
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java
index e136357..c392cbe 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/LiteralElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -9,7 +9,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: LiteralElement.java,v 1.2.4.1 2005/09/13 12:38:33 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -58,8 +55,6 @@ final class LiteralElement extends Instruction {
// names are not known at compile time.
private boolean _allAttributesUnique = false;
- private final static String XMLNS_STRING = "xmlns";
-
/**
* Returns the QName for this literal element
*/
@@ -140,8 +135,8 @@ final class LiteralElement extends Instruction {
// Treat default namespace as "" and not null
if (prefix == null)
prefix = Constants.EMPTYSTRING;
- else if (prefix.equals(XMLNS_STRING))
- return(XMLNS_STRING);
+ else if (prefix.equals(XMLNS_PREFIX))
+ return(XMLNS_PREFIX);
// Check if we must translate the prefix
final String alternative = stable.lookupPrefixAlias(prefix);
@@ -266,7 +261,7 @@ final class LiteralElement extends Instruction {
// Ignore special attributes (e.g. xmlns:prefix and xmlns)
final String prefix = qname.getPrefix();
if (prefix != null && prefix.equals(XMLNS_PREFIX) ||
- prefix == null && qname.getLocalPart().equals("xmlns") ||
+ prefix == null && qname.getLocalPart().equals(XMLNS_PREFIX) ||
uri != null && uri.equals(XSLT_URI))
{
continue;
@@ -339,9 +334,9 @@ final class LiteralElement extends Instruction {
il.append(methodGen.startElement());
// The value of an attribute may depend on a (sibling) variable
- int j=0;
+ int j = 0;
while (j < elementCount()) {
- final SyntaxTreeNode item = (SyntaxTreeNode) elementAt(j);
+ final SyntaxTreeNode item = elementAt(j);
if (item instanceof Variable) {
item.translate(classGen, methodGen);
}
@@ -350,35 +345,12 @@ final class LiteralElement extends Instruction {
// Compile code to emit namespace attributes
if (_accessedPrefixes != null) {
- boolean declaresDefaultNS = false;
-
for (Map.Entry<String, String> entry : _accessedPrefixes.entrySet()) {
final String prefix = entry.getKey();
final String uri = entry.getValue();
-
- if (uri != Constants.EMPTYSTRING ||
- prefix != Constants.EMPTYSTRING)
- {
- if (prefix == Constants.EMPTYSTRING) {
- declaresDefaultNS = true;
- }
- il.append(methodGen.loadHandler());
- il.append(new PUSH(cpg,prefix));
- il.append(new PUSH(cpg,uri));
- il.append(methodGen.namespace());
- }
- }
-
- /*
- * If our XslElement parent redeclares the default NS, and this
- * element doesn't, it must be redeclared one more time.
- */
- if (!declaresDefaultNS && (_parent instanceof XslElement)
- && ((XslElement) _parent).declaresDefaultNS())
- {
il.append(methodGen.loadHandler());
- il.append(new PUSH(cpg, Constants.EMPTYSTRING));
- il.append(new PUSH(cpg, Constants.EMPTYSTRING));
+ il.append(new PUSH(cpg, prefix));
+ il.append(new PUSH(cpg, uri));
il.append(methodGen.namespace());
}
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
index d15d90e..7088850 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: Parser.java,v 1.2.4.1 2005/09/13 12:14:32 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -37,6 +34,7 @@ import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -44,7 +42,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Stack;
import java.util.StringTokenizer;
-import java.util.Vector;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
@@ -68,20 +65,20 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class Parser implements Constants, ContentHandler {
- private static final String XSL = "xsl"; // standard prefix
+ private static final String XSL = "xsl"; // standard prefix
private static final String TRANSLET = "translet"; // extension prefix
private Locator _locator = null;
- private XSLTC _xsltc; // Reference to the compiler object.
- private XPathParser _xpathParser; // Reference to the XPath parser.
- private Vector _errors; // Contains all compilation errors
- private Vector _warnings; // Contains all compilation errors
+ private XSLTC _xsltc; // Reference to the compiler object.
+ private XPathParser _xpathParser; // Reference to the XPath parser.
+ private ArrayList<ErrorMsg> _errors; // Contains all compilation errors
+ private ArrayList<ErrorMsg> _warnings; // Contains all compilation warnings
private Map<String, String> _instructionClasses; // Maps instructions to classes
private Map<String, String[]> _instructionAttrs; // reqd and opt attrs
- private Map<String, QName> _qNames;
- private Map<String, Map> _namespaces;
+ private Map<String, QName> _qNames;
+ private Map<String, Map<String, QName>> _namespaces;
private QName _useAttributeSets;
private QName _excludeResultPrefixes;
private QName _extensionElementPrefixes;
@@ -113,8 +110,8 @@ public class Parser implements Constants, ContentHandler {
_instructionAttrs = new HashMap<>();
_variableScope = new HashMap<>();
_template = null;
- _errors = new Vector();
- _warnings = new Vector();
+ _errors = new ArrayList<>();
+ _warnings = new ArrayList<>();
_symbolTable = new SymbolTable();
_xpathParser = new XPathParser(this);
_currentStylesheet = null;
@@ -139,7 +136,6 @@ public class Parser implements Constants, ContentHandler {
public void setOutput(Output output) {
if (_output != null) {
if (_output.getImportPrecedence() <= output.getImportPrecedence()) {
- String cdata = _output.getCdata();
output.mergeOutput(_output);
_output.disable();
_output = output;
@@ -173,12 +169,13 @@ public class Parser implements Constants, ContentHandler {
Object existing = _variableScope.get(var.getName().getStringRep());
if (existing != null) {
if (existing instanceof Stack) {
- Stack stack = (Stack)existing;
+ @SuppressWarnings("unchecked")
+ Stack<VariableBase> stack = (Stack<VariableBase>)existing;
stack.push(var);
}
else if (existing instanceof VariableBase) {
- Stack stack = new Stack();
- stack.push(existing);
+ Stack<VariableBase> stack = new Stack<>();
+ stack.push((VariableBase)existing);
stack.push(var);
_variableScope.put(var.getName().getStringRep(), stack);
}
@@ -191,7 +188,8 @@ public class Parser implements Constants, ContentHandler {
public void removeVariable(QName name) {
Object existing = _variableScope.get(name.getStringRep());
if (existing instanceof Stack) {
- Stack stack = (Stack)existing;
+ @SuppressWarnings("unchecked")
+ Stack<VariableBase> stack = (Stack<VariableBase>)existing;
if (!stack.isEmpty()) stack.pop();
if (!stack.isEmpty()) return;
}
@@ -201,13 +199,14 @@ public class Parser implements Constants, ContentHandler {
public VariableBase lookupVariable(QName name) {
Object existing = _variableScope.get(name.getStringRep());
if (existing instanceof VariableBase) {
- return((VariableBase)existing);
+ return (VariableBase)existing;
}
else if (existing instanceof Stack) {
- Stack stack = (Stack)existing;
- return((VariableBase)stack.peek());
+ @SuppressWarnings("unchecked")
+ Stack<VariableBase> stack = (Stack<VariableBase>)existing;
+ return stack.peek();
}
- return(null);
+ return null;
}
public void setXSLTC(XSLTC xsltc) {
@@ -397,7 +396,6 @@ public class Parser implements Constants, ContentHandler {
try {
if (stylesheet != null) {
stylesheet.parseContents(this);
- final int precedence = stylesheet.getImportPrecedence();
final Iterator<SyntaxTreeNode> elements = stylesheet.elements();
while (elements.hasNext()) {
SyntaxTreeNode child = elements.next();
@@ -704,8 +702,6 @@ public class Parser implements Constants, ContentHandler {
new String[] {"stylesheet-prefix", "result-prefix"});
}
-
-
/**
* Initialize the _instructionClasses map, which maps XSL element
* names to Java classes in this package.
@@ -779,6 +775,7 @@ public class Parser implements Constants, ContentHandler {
/**
* Add primops and base functions to the symbol table.
*/
+ @SuppressWarnings("unused")
private void initSymbolTable() {
MethodType I_V = new MethodType(Type.Int, Type.Void);
MethodType I_R = new MethodType(Type.Int, Type.Real);
@@ -971,12 +968,12 @@ public class Parser implements Constants, ContentHandler {
String local, Attributes attributes)
{
SyntaxTreeNode node = null;
- QName qname = getQName(uri, prefix, local);
+ QName qname = getQName(uri, prefix, local);
String className = _instructionClasses.get(qname.getStringRep());
if (className != null) {
try {
- final Class clazz = ObjectFactory.findProviderClass(className, true);
+ final Class<?> clazz = ObjectFactory.findProviderClass(className, true);
node = (SyntaxTreeNode)clazz.newInstance();
node.setQName(qname);
node.setParser(this);
@@ -1023,7 +1020,7 @@ public class Parser implements Constants, ContentHandler {
else {
Stylesheet sheet = _xsltc.getStylesheet();
if ((sheet != null) && (sheet.isExtension(uri))) {
- if (sheet != (SyntaxTreeNode)_parentStack.peek()) {
+ if (sheet != _parentStack.peek()) {
node = new UnsupportedElement(uri, prefix, local, true);
UnsupportedElement elem = (UnsupportedElement)node;
ErrorMsg msg =
@@ -1156,7 +1153,6 @@ public class Parser implements Constants, ContentHandler {
node.setParser(this);
node.setParent(parent);
node.setLineNumber(line);
-// System.out.println("e = " + text + " " + node);
return node;
}
}
@@ -1191,7 +1187,7 @@ public class Parser implements Constants, ContentHandler {
if (size > 0) {
System.err.println(new ErrorMsg(ErrorMsg.COMPILER_ERROR_KEY));
for (int i = 0; i < size; i++) {
- System.err.println(" " + _errors.elementAt(i));
+ System.err.println(" " + _errors.get(i));
}
}
}
@@ -1204,7 +1200,7 @@ public class Parser implements Constants, ContentHandler {
if (size > 0) {
System.err.println(new ErrorMsg(ErrorMsg.COMPILER_WARNING_KEY));
for (int i = 0; i < size; i++) {
- System.err.println(" " + _warnings.elementAt(i));
+ System.err.println(" " + _warnings.get(i));
}
}
}
@@ -1217,42 +1213,42 @@ public class Parser implements Constants, ContentHandler {
case Constants.INTERNAL:
// Unexpected internal errors, such as null-ptr exceptions, etc.
// Immediately terminates compilation, no translet produced
- _errors.addElement(error);
+ _errors.add(error);
break;
case Constants.UNSUPPORTED:
// XSLT elements that are not implemented and unsupported ext.
// Immediately terminates compilation, no translet produced
- _errors.addElement(error);
+ _errors.add(error);
break;
case Constants.FATAL:
// Fatal error in the stylesheet input (parsing or content)
// Immediately terminates compilation, no translet produced
- _errors.addElement(error);
+ _errors.add(error);
break;
case Constants.ERROR:
// Other error in the stylesheet input (parsing or content)
// Does not terminate compilation, no translet produced
- _errors.addElement(error);
+ _errors.add(error);
break;
case Constants.WARNING:
// Other error in the stylesheet input (content errors only)
// Does not terminate compilation, a translet is produced
- _warnings.addElement(error);
+ _warnings.add(error);
break;
}
}
- public Vector getErrors() {
+ public ArrayList<ErrorMsg> getErrors() {
return _errors;
}
- public Vector getWarnings() {
+ public ArrayList<ErrorMsg> getWarnings() {
return _warnings;
}
/************************ SAX2 ContentHandler INTERFACE *****************/
- private Stack _parentStack = null;
+ private Stack<SyntaxTreeNode> _parentStack = null;
private Map<String, String> _prefixMapping = null;
/**
@@ -1262,7 +1258,7 @@ public class Parser implements Constants, ContentHandler {
_root = null;
_target = null;
_prefixMapping = null;
- _parentStack = new Stack();
+ _parentStack = new Stack<>();
}
/**
@@ -1318,7 +1314,7 @@ public class Parser implements Constants, ContentHandler {
_root = element;
}
else {
- SyntaxTreeNode parent = (SyntaxTreeNode)_parentStack.peek();
+ SyntaxTreeNode parent = _parentStack.peek();
parent.addElement(element);
element.setParent(parent);
}
@@ -1349,7 +1345,7 @@ public class Parser implements Constants, ContentHandler {
*/
public void characters(char[] ch, int start, int length) {
String string = new String(ch, start, length);
- SyntaxTreeNode parent = (SyntaxTreeNode)_parentStack.peek();
+ SyntaxTreeNode parent = _parentStack.peek();
if (string.length() == 0) return;
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
index 1e8ad86..01ef38b 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
@@ -73,7 +73,7 @@ public abstract class SyntaxTreeNode implements Constants {
protected QName _qname; // The element QName
private int _line; // Source file line number
protected AttributesImpl _attributes = null; // Attributes of this element
- private Map<String, String> _prefixMapping = null; // Namespace declarations
+ private Map<String, String> _prefixMapping = null; // Namespace declarations
// Sentinel - used to denote unrecognised syntaxt tree nodes.
protected static final SyntaxTreeNode Dummy = new AbsolutePathPattern(null);
@@ -829,7 +829,7 @@ public abstract class SyntaxTreeNode implements Constants {
* @param pos The child node's position.
* @return The child node.
*/
- protected final Object elementAt(int pos) {
+ protected final SyntaxTreeNode elementAt(int pos) {
return _contents.get(pos);
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
index 3218181..631edbd 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: XSLTC.java,v 1.2.4.1 2005/09/05 09:51:38 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -39,6 +36,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
@@ -283,7 +281,7 @@ public final class XSLTC {
}
/*
- * Function loads an external extension functions.
+ * Function loads an external extension function.
* The filtering of function types (external,internal) takes place in FunctionCall class
*
*/
@@ -598,18 +596,18 @@ public final class XSLTC {
}
/**
- * Get a Vector containing all compile error messages
- * @return A Vector containing all compile error messages
+ * Get a list of all compile error messages
+ * @return A List containing all compile error messages
*/
- public Vector getErrors() {
+ public ArrayList<ErrorMsg> getErrors() {
return _parser.getErrors();
}
/**
- * Get a Vector containing all compile warning messages
- * @return A Vector containing all compile error messages
+ * Get a list of all compile warning messages
+ * @return A List containing all compile error messages
*/
- public Vector getWarnings() {
+ public ArrayList<ErrorMsg> getWarnings() {
return _parser.getWarnings();
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java
index e04bab7..e94ebb1 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: XslElement.java,v 1.2.4.1 2005/09/12 11:39:55 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -60,14 +57,6 @@ final class XslElement extends Instruction {
displayContents(indent + IndentIncrement);
}
- /**
- * This method is now deprecated. The new implemation of this class
- * never declares the default NS.
- */
- public boolean declaresDefaultNS() {
- return false;
- }
-
public void parseContents(Parser parser) {
final SymbolTable stable = parser.getSymbolTable();
@@ -210,7 +199,6 @@ final class XslElement extends Instruction {
* on the handler (vii) evaluates the contents (viii) calls endElement().
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
- LocalVariableGen local = null;
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java
index 8bbc541..bce2c3a 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,18 +17,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: TemplatesHandlerImpl.java,v 1.2.4.1 2005/09/06 12:09:03 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.trax;
-import javax.xml.XMLConstants;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.sax.TemplatesHandler;
import com.sun.org.apache.xalan.internal.XalanConstants;
import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser;
@@ -37,15 +28,19 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet;
import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-
+import java.util.ArrayList;
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.sax.TemplatesHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
-import java.util.Vector;
-
/**
* Implementation of a JAXP1.1 TemplatesHandler
* @author Morten Jorgensen
@@ -268,13 +263,13 @@ public class TemplatesHandlerImpl
}
}
else {
- StringBuffer errorMessage = new StringBuffer();
- Vector errors = _parser.getErrors();
+ StringBuilder errorMessage = new StringBuilder();
+ ArrayList<ErrorMsg> errors = _parser.getErrors();
final int count = errors.size();
for (int i = 0; i < count; i++) {
if (errorMessage.length() > 0)
errorMessage.append('\n');
- errorMessage.append(errors.elementAt(i).toString());
+ errorMessage.append(errors.get(i).toString());
}
throw new SAXException(ErrorMsg.JAXP_COMPILE_ERR, new TransformerException(errorMessage.toString()));
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
index b37c8f4..e30fffd 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: TransformerFactoryImpl.java,v 1.8 2007/04/09 21:30:41 joehw Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.trax;
@@ -48,6 +45,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
@@ -592,7 +590,7 @@ public class TransformerFactoryImpl
}
// Inefficient, but array is small
- for (int i =0; i < features.length; i++) {
+ for (int i = 0; i < features.length; i++) {
if (name.equals(features[i])) {
return true;
}
@@ -799,7 +797,7 @@ public class TransformerFactoryImpl
/**
* Pass warning messages from the compiler to the error listener
*/
- private void passWarningsToListener(Vector messages)
+ private void passWarningsToListener(ArrayList<ErrorMsg> messages)
throws TransformerException
{
if (_errorListener == null || messages == null) {
@@ -808,7 +806,7 @@ public class TransformerFactoryImpl
// Pass messages to listener, one by one
final int count = messages.size();
for (int pos = 0; pos < count; pos++) {
- ErrorMsg msg = (ErrorMsg)messages.elementAt(pos);
+ ErrorMsg msg = messages.get(pos);
// Workaround for the TCK failure ErrorListener.errorTests.error001.
if (msg.isWarningError())
_errorListener.error(
@@ -822,7 +820,7 @@ public class TransformerFactoryImpl
/**
* Pass error messages from the compiler to the error listener
*/
- private void passErrorsToListener(Vector messages) {
+ private void passErrorsToListener(ArrayList<ErrorMsg> messages) {
try {
if (_errorListener == null || messages == null) {
return;
@@ -830,7 +828,7 @@ public class TransformerFactoryImpl
// Pass messages to listener, one by one
final int count = messages.size();
for (int pos = 0; pos < count; pos++) {
- String message = messages.elementAt(pos).toString();
+ String message = messages.get(pos).toString();
_errorListener.error(new TransformerException(message));
}
}
@@ -1004,40 +1002,39 @@ public class TransformerFactoryImpl
}
// Check that the transformation went well before returning
- if (bytecodes == null) {
- Vector errs = xsltc.getErrors();
- ErrorMsg err;
- if (errs != null) {
- err = (ErrorMsg)errs.elementAt(errs.size()-1);
- } else {
- err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
- }
- Throwable cause = err.getCause();
- TransformerConfigurationException exc;
- if (cause != null) {
- exc = new TransformerConfigurationException(cause.getMessage(), cause);
- } else {
- exc = new TransformerConfigurationException(err.toString());
- }
+ if (bytecodes == null) {
+ ArrayList<ErrorMsg> errs = xsltc.getErrors();
+ ErrorMsg err;
+ if (errs != null) {
+ err = errs.get(errs.size() - 1);
+ } else {
+ err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
+ }
+ Throwable cause = err.getCause();
+ TransformerConfigurationException exc;
+ if (cause != null) {
+ exc = new TransformerConfigurationException(cause.getMessage(), cause);
+ } else {
+ exc = new TransformerConfigurationException(err.toString());
+ }
- // Pass compiler errors to the error listener
- if (_errorListener != null) {
- passErrorsToListener(xsltc.getErrors());
+ // Pass compiler errors to the error listener
+ if (_errorListener != null) {
+ passErrorsToListener(xsltc.getErrors());
- // As required by TCK 1.2, send a fatalError to the
- // error listener because compilation of the stylesheet
- // failed and no further processing will be possible.
- try {
- _errorListener.fatalError(exc);
- } catch (TransformerException te) {
- // well, we tried.
+ // As required by TCK 1.2, send a fatalError to the
+ // error listener because compilation of the stylesheet
+ // failed and no further processing will be possible.
+ try {
+ _errorListener.fatalError(exc);
+ } catch (TransformerException te) {
+ // well, we tried.
+ }
+ } else {
+ xsltc.printErrors();
}
+ throw exc;
}
- else {
- xsltc.printErrors();
- }
- throw exc;
- }
return new TemplatesImpl(bytecodes, transletName,
xsltc.getOutputProperties(), _indentNumber, this);