You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/10/30 15:57:54 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TemplatesImpl.java TransformerFactoryImpl.java TransformerHandlerImpl.java TransformerImpl.java XSLTCSource.java
morten 01/10/30 06:57:54
Modified: java/src/org/apache/xalan/xsltc/cmdline Compile.java
Transform.java
java/src/org/apache/xalan/xsltc/compiler/util ErrorMsg.java
SlotAllocator.java
java/src/org/apache/xalan/xsltc/dom LoadDocument.java
NodeSortRecordFactory.java
java/src/org/apache/xalan/xsltc/runtime
AbstractTranslet.java BasisLibrary.java
SAXAdapter.java TextOutput.java
java/src/org/apache/xalan/xsltc/trax TemplatesImpl.java
TransformerFactoryImpl.java
TransformerHandlerImpl.java TransformerImpl.java
XSLTCSource.java
Added: java/src/org/apache/xalan/xsltc/compiler/util
ErrorMessages.java ErrorMessages_en.java
ErrorMessages_no.java
Log:
A first stab at i18n'ing XSLTC. Error and warning messages from the compiler
and TrAX are handled by the compiler/util/ErrorMsg class, while messages
from the DOM and runtime/translet are handled by the Basis Library class.
Only the ErrorMsg class has so far been updated to dynamically read its
messages from a ResourceBundle. Bundles for British English and Norwegian
are implemented.
PR: n/a
Obtained from: n/a
Submitted by: morten@xml.apache.org
Reviewed by: morten@xml.apache.org
Revision Changes Path
1.8 +4 -19 xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java
Index: Compile.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Compile.java 2001/10/19 09:34:36 1.7
+++ Compile.java 2001/10/30 14:57:53 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Compile.java,v 1.7 2001/10/19 09:34:36 morten Exp $
+ * @(#)$Id: Compile.java,v 1.8 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -75,6 +75,7 @@
import org.apache.xalan.xsltc.compiler.XSLTC;
import org.apache.xalan.xsltc.compiler.util.Util;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
import org.apache.xalan.xsltc.cmdline.getopt.*;
public final class Compile {
@@ -85,24 +86,8 @@
// this class being used in other ways as well.
private static boolean _allowExit = true;
- private final static String USAGE_STRING =
- "Usage:\n" +
- " xsltc [-o <output>] [-d <directory>] [-j <jarfile>]\n"+
- " [-p <package name>] [-x] [-s] [-u] <stylesheet>|-i\n\n"+
- " Where <output> is the name to give the the generated translet.\n"+
- " <stylesheet> is one or more stylesheet file names, or if,\n"+
- " the -u options is specified, one or more stylesheet URLs.\n"+
- " <directory> is the output directory.\n"+
- " <jarfile> is the name of a JAR-file to put all generated classes in.\n"+
- " <package-name> is a package name to prefix all class names with.\n\n"+
- " Notes:\n"+
- " The -i options forces the compiler to read the stylsheet from stdin\n"+
- " The -o option is ignored when multiple stylesheets are specified.\n"+
- " The -x option switched on debug messages.\n"+
- " The -s option disables calling System.exit.";
-
public static void printUsage() {
- System.err.println(USAGE_STRING);
+ System.err.println(new ErrorMsg(ErrorMsg.COMPILE_USAGE_STR));
if (_allowExit) System.exit(-1);
}
@@ -164,7 +149,7 @@
if (useStdIn) {
if (!classNameSet) {
- System.err.println("The -i option must be used with the -o option.");
+ System.err.println(new ErrorMsg(ErrorMsg.COMPILE_STDIN_ERR));
if (_allowExit) System.exit(-1);
}
compileOK = xsltc.compile(System.in, xsltc.getClassName());
1.12 +28 -29 xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java
Index: Transform.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Transform.java 2001/10/16 10:44:54 1.11
+++ Transform.java 2001/10/30 14:57:53 1.12
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Transform.java,v 1.11 2001/10/16 10:44:54 morten Exp $
+ * @(#)$Id: Transform.java,v 1.12 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -90,6 +90,7 @@
import org.apache.xalan.xsltc.dom.DOMBuilder;
import org.apache.xalan.xsltc.dom.Axis;
import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
final public class Transform {
@@ -210,69 +211,67 @@
}
catch (TransletException e) {
if (_debug) e.printStackTrace();
- System.err.println("\nTranslet Error: " + e.getMessage());
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ e.getMessage());
if (_allowExit) System.exit(-1);
}
catch (RuntimeException e) {
if (_debug) e.printStackTrace();
- System.err.println("\nRuntime Error: " + e.getMessage());
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ e.getMessage());
if (_allowExit) System.exit(-1);
}
catch (FileNotFoundException e) {
if (_debug) e.printStackTrace();
- System.err.println("Error: File or URI '"+_fileName+"' not found.");
+ ErrorMsg err = new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, _fileName);
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ err.toString());
if (_allowExit) System.exit(-1);
}
catch (MalformedURLException e) {
if (_debug) e.printStackTrace();
- System.err.println("Error: Invalid URI '"+_fileName+"'.");
+ ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, _fileName);
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ err.toString());
if (_allowExit) System.exit(-1);
}
catch (ClassNotFoundException e) {
if (_debug) e.printStackTrace();
- System.err.println("Error: Cannot find class '"+_className+"'.");
+ ErrorMsg err= new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR,_className);
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ err.toString());
if (_allowExit) System.exit(-1);
}
catch (UnknownHostException e) {
if (_debug) e.printStackTrace();
- System.err.println("Error: Can't resolve URI specification '"+
- _fileName+"'.");
+ ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, _fileName);
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ err.toString());
if (_allowExit) System.exit(-1);
}
catch (SAXException e) {
- Exception i = e.getException();
+ Exception ex = e.getException();
if (_debug) {
- if (i != null)
- i.printStackTrace();
- else
- e.printStackTrace();
+ if (ex != null) ex.printStackTrace();
+ e.printStackTrace();
}
- if (i != null)
- System.err.println("Error: "+i.getMessage());
+ System.err.print(ErrorMsg.getTransletErrorMessage());
+ if (ex != null)
+ System.err.println(ex.getMessage());
else
- System.err.println("Error: "+e.getMessage());
+ System.err.println(e.getMessage());
if (_allowExit) System.exit(-1);
}
catch (Exception e) {
if (_debug) e.printStackTrace();
- System.err.println("Error: "+e.getMessage());
+ System.err.println(ErrorMsg.getTransletErrorMessage()+
+ e.getMessage());
if (_allowExit) System.exit(-1);
}
}
- private final static String USAGE_STRING =
- "Usage: \n" +
- " xslt [-j <jarfile>] {-u <document_url> | <document>} <class>\n"+
- " [<name1>=<value1> ...]\n\n" +
- " <document> is the xml document to be transformed, or\n" +
- " <document_url> is a url for the xml document,\n" +
- " <class> is the translet class which is either in\n" +
- " user's CLASSPATH or in the <jarfile> specified \n" +
- " with the -j option.\n" +
- " also: [-x] (debug), [-s] (don't allow System.exit)";
-
public static void printUsage() {
- System.err.println(USAGE_STRING);
+ System.err.println(new ErrorMsg(ErrorMsg.TRANSFORM_USAGE_STR));
if (_allowExit) System.exit(-1);
}
1.8 +61 -122 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java
Index: ErrorMsg.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ErrorMsg.java 2001/10/30 08:42:56 1.7
+++ ErrorMsg.java 2001/10/30 14:57:53 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ErrorMsg.java,v 1.7 2001/10/30 08:42:56 morten Exp $
+ * @(#)$Id: ErrorMsg.java,v 1.8 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -60,6 +60,7 @@
* @author Santiago Pericas-Geertsen
* @author G. Todd Miller
* @author Erwin Bolwidt <ej...@klomp.org>
+ * @author Morten Jorgensen
*
*/
@@ -69,6 +70,8 @@
import org.apache.xalan.xsltc.compiler.SyntaxTreeNode;
import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
import java.text.MessageFormat;
public final class ErrorMsg {
@@ -78,7 +81,8 @@
private String _message = null;
private String _url = null;
Object[] _params = null;
-
+
+ // Compiler error messages
public static final int MULTIPLE_STYLESHEET_ERR = 0;
public static final int TEMPLATE_REDEF_ERR = 1;
public static final int TEMPLATE_UNDEF_ERR = 2;
@@ -133,121 +137,52 @@
public static final int ATTRIBSET_UNDEF_ERR = 51;
public static final int ATTR_VAL_TEMPLATE_ERR = 52;
public static final int UNKNOWN_SIG_TYPE_ERR = 53;
-
- // These message should be read from a locale-specific resource bundle
- static final String messages_d[] = {
- // MULTIPLE_STYLESHEET_ERR
- "More than one stylesheet defined in the same file.",
- // TEMPLATE_REDEF_ERR
- "Template ''{0}'' already defined in this stylesheet.",
- // TEMPLATE_UNDEF_ERR
- "Template ''{0}'' not defined in this stylesheet.",
- // VARIABLE_REDEF_ERR
- "Variable ''{0}'' is multiply defined in the same scope.",
- // VARIABLE_UNDEF_ERR
- "Variable or parameter ''{0}'' is undefined.",
- // CLASS_NOT_FOUND_ERR
- "Cannot find class ''{0}''.",
- // METHOD_NOT_FOUND_ERR
- "Cannot find external method ''{0}'' (must be static and public).",
- // ARGUMENT_CONVERSION_ERR
- "Cannot convert argument/return type in call to method ''{1}''",
- // FILE_NOT_FOUND_ERR
- "File or URI ''{0}'' not found.",
- // INVALID_URI_ERR
- "Invalid URI ''{0}''.",
- // FILE_ACCESS_ERR
- "Cannot open file ''{0}''.",
- // MISSING_ROOT_ERR
- "<xsl:stylesheet> or <xsl:transform> element expected.",
- // NAMESPACE_UNDEF_ERR
- "Namespace prefix ''{0}'' is undeclared.",
- // FUNCTION_RESOLVE_ERR
- "Unable to resolve call to function ''{0}''.",
- // NEED_LITERAL_ERR
- "Argument to ''{0}'' must be a literal string.",
- // XPATH_PARSER_ERR
- "Error parsing XPath expression ''{0}''.",
- // REQUIRED_ATTR_ERR
- "Required attribute ''{0}'' is missing.",
- // ILLEGAL_CHAR_ERR
- "Illegal character ''{0}'' in XPath expression.",
- // ILLEGAL_PI_ERR
- "Illegal name ''{0}'' for processing instruction.",
- // STRAY_ATTRIBUTE_ERR
- "Attribute ''{0}'' outside of element.",
- // ILLEGAL_ATTRIBUTE_ERR
- "Illegal attribute ''{0}''.",
- // CIRCULAR_INCLUDE_ERR
- "Circular import/include. Stylesheet ''{0}'' already loaded.",
- // RESULT_TREE_SORT_ERR
- "Result-tree fragments cannot be supports (<xsl:sort> elements are "+
- "ignored). You must sort the nodes when creating the result tree.",
- // SYMBOLS_REDEF_ERR
- "Decimal formatting ''{0}'' is already defined.",
- // XSL_VERSION_ERR
- "XSL version ''{0}'' is not supported by XSLTC.",
- // CIRCULAR_VARIABLE_ERR
- "Circular variable/parameter references: ''{0}''.",
- // ILLEGAL_BINARY_OP_ERR
- "Unknown operator for binary expression.",
- // ILLEGAL_ARG_ERR
- "Illegal argument(s) for function call.",
- // DOCUMENT_ARG_ERR
- "Second argument to document() function must be a node-set.",
- // MISSING_WHEN_ERR
- "At least one <xsl:when> element required in <xsl:choose>.",
- // MULTIPLE_OTHERWISE_ERR
- "Only one <xsl:otherwise> element allowed in <xsl:choose>.",
- // STRAY_OTHERWISE_ERR
- "<xsl:otherwise> can only be used within <xsl:choose>.",
- // STRAY_WHEN_ERR
- "<xsl:when> can only be used within <xsl:choose>.",
- // WHEN_ELEMENT_ERR
- "Only <xsl:when> and <xsl:otherwise> elements allowed in <xsl:choose>.",
- // UNNAMED_ATTRIBSET_ERR
- "<xsl:attribute-set> is missing the 'name' attribute.",
- // ILLEGAL_CHILD_ERR
- "Illegal child element.",
- // ILLEGAL_ELEM_NAME_ERR
- "You cannot call an element ''{0}''",
- // ILLEGAL_ATTR_NAME_ERR
- "You cannot call an attribute ''{0}''",
- // ILLEGAL_TEXT_NODE_ERR
- "Text data outside of top-level <xsl:stylesheet> element.",
- // SAX_PARSER_CONFIG_ERR
- "JAXP parser not configured correctly",
- // INTERNAL_ERR
- "Unrecoverable XSLTC compilation error: ''{0}''",
- // UNSUPPORTED_XSL_ERR
- "Unsupported XSL element ''{0}''.",
- // UNSUPPORTED_EXT_ERR
- "Unrecognised XSLTC extension ''{0}''.",
- // MISSING_XSLT_URI_ERR
- "The input document is not a stylesheet "+
- "(the XSL namespace is not declared in the root element).",
- // MISSING_XSLT_TARGET_ERR
- "Could not find stylesheet target ''{0}''.",
- // NOT_IMPLEMENTED_ERR
- "Not implemented: ''{0}''.",
- // NOT_STYLESHEET_ERR
- "The input document does not contain an XSL stylesheet.",
- // ELEMENT_PARSE_ERR
- "Could not parse element ''{0}''",
- // KEY_USE_ATTR_ERR
- "The use-attribute of <key> must be node, node-set, string or number.",
- // OUTPUT_VERSION_ERR
- "Output XML document version should be 1.0",
- // ILLEGAL_RELAT_OP_ERR
- "Unknown operator for relational expression",
- // ATTRIBSET_UNDEF_ERR
- "Attempting to use non-existing attribute set ''{0}''.",
- // ATTR_VAL_TEMPLATE_ERR
- "Cannot parse attribute value template ''{0}''.",
- // UNKNOWN_SIG_TYPE_ERR
- "Unknown data-type in signature for class ''{0}''."
- };
+ // JAXP/TrAX error messages
+ public static final int NO_TRANSLET_CLASS_ERR = 54;
+ public static final int NO_MAIN_TRANSLET_ERR = 55;
+ public static final int TRANSLET_CLASS_ERR = 56;
+ public static final int TRANSLET_OBJECT_ERR = 57;
+ public static final int ERROR_LISTENER_NULL_ERR = 58;
+ public static final int JAXP_UNKNOWN_SOURCE_ERR = 59;
+ public static final int JAXP_NO_SOURCE_ERR = 60;
+ public static final int JAXP_COMPILE_ERR = 61;
+ public static final int JAXP_INVALID_ATTR_ERR = 62;
+ public static final int JAXP_SET_RESULT_ERR = 63;
+ public static final int JAXP_NO_TRANSLET_ERR = 64;
+ public static final int JAXP_NO_HANDLER_ERR = 65;
+ public static final int JAXP_NO_RESULT_ERR = 66;
+ public static final int JAXP_UNKNOWN_PROP_ERR = 67;
+ public static final int SAX2DOM_ADAPTER_ERR = 68;
+ public static final int XSLTC_SOURCE_ERR = 69;
+
+ // Command-line error messages
+ public static final int COMPILE_STDIN_ERR = 70;
+ public static final int COMPILE_USAGE_STR = 71;
+ public static final int TRANSFORM_USAGE_STR = 72;
+
+
+ // All error messages are localized and are stored in resource bundles.
+ // This array and the following 4 strings are read from that bundle.
+ private static String[] _errorMessages;
+ private static String _compileError;
+ private static String _compileWarning;
+ private static String _runtimeError;
+
+ public final static String ERROR_MESSAGES_KEY = "error-messages";
+ public final static String COMPILER_ERROR_KEY = "compile-error";
+ public final static String COMPILER_WARNING_KEY = "compile-warning";
+ public final static String RUNTIME_ERROR_KEY = "runtime-error";
+
+ static {
+ Locale locale = Locale.getDefault();
+ //Locale locale = new Locale("no","NO");
+ ResourceBundle bundle = ResourceBundle.getBundle("org.apache.xalan.xsltc.compiler.util.ErrorMessages", locale);
+ _errorMessages = bundle.getStringArray(ERROR_MESSAGES_KEY);
+ _compileError = bundle.getString(COMPILER_ERROR_KEY);
+ _compileWarning = bundle.getString(COMPILER_WARNING_KEY);
+ _runtimeError = bundle.getString(RUNTIME_ERROR_KEY);
+ }
public ErrorMsg(int code) {
_code = code;
@@ -310,11 +245,15 @@
}
public static String getCompileErrorMessage() {
- return "Compiler error(s):";
+ return _compileError;
}
public static String getCompileWarningMessage() {
- return "Compiler warning(s):";
+ return _compileWarning;
+ }
+
+ public static String getTransletErrorMessage() {
+ return _runtimeError;
}
private String getFileName(SyntaxTreeNode node) {
@@ -346,15 +285,15 @@
*/
public String toString() {
String suffix = (_params == null) ?
- (_code >= 0 ? new String(messages_d[_code]) : _message)
- : MessageFormat.format(messages_d[_code], _params);
+ (_code >= 0 ? new String(_errorMessages[_code]) : _message)
+ : MessageFormat.format(_errorMessages[_code], _params);
return formatLine() + suffix;
}
public String toString(Object obj) {
Object params[] = new Object[1];
params[0] = obj.toString();
- String suffix = MessageFormat.format(messages_d[_code], params);
+ String suffix = MessageFormat.format(_errorMessages[_code], params);
return formatLine() + suffix;
}
@@ -362,7 +301,7 @@
Object params[] = new Object[2];
params[0] = obj0.toString();
params[1] = obj1.toString();
- String suffix = MessageFormat.format(messages_d[_code], params);
+ String suffix = MessageFormat.format(_errorMessages[_code], params);
return formatLine() + suffix;
}
}
1.2 +14 -45 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/SlotAllocator.java
Index: SlotAllocator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/SlotAllocator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SlotAllocator.java 2001/04/17 18:52:20 1.1
+++ SlotAllocator.java 2001/10/30 14:57:53 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SlotAllocator.java,v 1.1 2001/04/17 18:52:20 sboag Exp $
+ * @(#)$Id: SlotAllocator.java,v 1.2 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,41 +66,22 @@
import de.fub.bytecode.generic.*;
final class SlotAllocator {
+
private int _firstAvailableSlot;
private int _size = 8;
private int _free = 0;
private int[] _slotsTaken = new int[_size];
-
- /*
- private static int Serial = 0;
- private final int _serial = Serial++;
-
- private void printState(String msg) {
- System.out.println("=========== " + _serial + " =========== " + msg);
- System.out.println("firstAvailableSlot = " + _firstAvailableSlot);
-
- for (int i = 0; i < _free; i++) {
- System.out.println("\tslotsTaken = " + _slotsTaken[i]);
- }
-
- System.out.println("========================");
- }
- */
-
public void initialize(LocalVariableGen[] vars) {
final int length = vars.length;
- //System.out.println(_serial + " initialize " + length);
- int slot = 0;
+ int slot = 0, size, index;
+
for (int i = 0; i < length; i++) {
- //System.out.println("index " + vars[i].getIndex());
- //System.out.println("all " + allocateSlot(vars[i].getType()));
- //allocateSlot(vars[i].getType());
- slot = Math.max(slot,
- vars[i].getIndex() + vars[i].getType().getSize());
+ size = vars[i].getType().getSize();
+ index = vars[i].getIndex();
+ slot = Math.max(slot, index + size);
}
_firstAvailableSlot = slot;
- //System.out.println("firstAvailableSlot = " + _firstAvailableSlot);
}
public int allocateSlot(Type type) {
@@ -108,22 +89,18 @@
final int limit = _free;
int slot = _firstAvailableSlot, where = 0;
- //printState("allocating");
-
if (_free + size > _size) {
final int[] array = new int[_size *= 2];
- for (int j = 0; j < limit; j++) {
+ for (int j = 0; j < limit; j++)
array[j] = _slotsTaken[j];
- }
_slotsTaken = array;
}
while (where < limit) {
if (slot + size <= _slotsTaken[where]) {
// insert
- for (int j = limit - 1; j >= where; j--) {
+ for (int j = limit - 1; j >= where; j--)
_slotsTaken[j + size] = _slotsTaken[j];
- }
break;
}
else {
@@ -131,13 +108,10 @@
}
}
- for (int j = 0; j < size; j++) {
+ for (int j = 0; j < size; j++)
_slotsTaken[where + j] = slot + j;
- }
_free += size;
- //System.out.println("allocated slot " + slot);
- //printState("done");
return slot;
}
@@ -146,7 +120,6 @@
final int slot = lvg.getIndex();
final int limit = _free;
- //printState("releasing " + slot);
for (int i = 0; i < limit; i++) {
if (_slotsTaken[i] == slot) {
int j = i + size;
@@ -154,16 +127,12 @@
_slotsTaken[i++] = _slotsTaken[j++];
}
_free -= size;
- //System.out.println("released slot " + slot);
-
- //printState("done");
return;
}
}
- System.err.println("size = " + size);
- System.err.println("slot = " + slot);
- System.err.println("limit = " + limit);
- //printState("error");
- throw new Error("releaseSlot");
+ String state = "Variable slot allocation error"+
+ "(size="+size+", slot="+slot+", limit="+limit+")";
+ ErrorMsg err = new ErrorMsg(ErrorMsg.INTERNAL_ERR, state);
+ throw new Error(err.toString());
}
}
1.1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMessages.java
Index: ErrorMessages.java
===================================================================
/*
* @(#)$Id: ErrorMessages.java,v 1.1 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, Sun
* Microsystems., http://www.sun.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
*
*/
package org.apache.xalan.xsltc.compiler.util;
import java.util.Vector;
import java.util.Enumeration;
import java.util.ResourceBundle;
public class ErrorMessages extends ResourceBundle {
// These message should be read from a locale-specific resource bundle
private static final String errorMessages[] = {
// MULTIPLE_STYLESHEET_ERR
"More than one stylesheet defined in the same file.",
// TEMPLATE_REDEF_ERR
"Template ''{0}'' already defined in this stylesheet.",
// TEMPLATE_UNDEF_ERR
"Template ''{0}'' not defined in this stylesheet.",
// VARIABLE_REDEF_ERR
"Variable ''{0}'' is multiply defined in the same scope.",
// VARIABLE_UNDEF_ERR
"Variable or parameter ''{0}'' is undefined.",
// CLASS_NOT_FOUND_ERR
"Cannot find class ''{0}''.",
// METHOD_NOT_FOUND_ERR
"Cannot find external method ''{0}'' (must be static and public).",
// ARGUMENT_CONVERSION_ERR
"Cannot convert argument/return type in call to method ''{0}''",
// FILE_NOT_FOUND_ERR
"File or URI ''{0}'' not found.",
// INVALID_URI_ERR
"Invalid URI ''{0}''.",
// FILE_ACCESS_ERR
"Cannot open file or URI ''{0}''.",
// MISSING_ROOT_ERR
"<xsl:stylesheet> or <xsl:transform> element expected.",
// NAMESPACE_UNDEF_ERR
"Namespace prefix ''{0}'' is undeclared.",
// FUNCTION_RESOLVE_ERR
"Unable to resolve call to function ''{0}''.",
// NEED_LITERAL_ERR
"Argument to ''{0}'' must be a literal string.",
// XPATH_PARSER_ERR
"Error parsing XPath expression ''{0}''.",
// REQUIRED_ATTR_ERR
"Required attribute ''{0}'' is missing.",
// ILLEGAL_CHAR_ERR
"Illegal character ''{0}'' in XPath expression.",
// ILLEGAL_PI_ERR
"Illegal name ''{0}'' for processing instruction.",
// STRAY_ATTRIBUTE_ERR
"Attribute ''{0}'' outside of element.",
// ILLEGAL_ATTRIBUTE_ERR
"Illegal attribute ''{0}''.",
// CIRCULAR_INCLUDE_ERR
"Circular import/include. Stylesheet ''{0}'' already loaded.",
// RESULT_TREE_SORT_ERR
"Result-tree fragments cannot be sorted (<xsl:sort> elements are "+
"ignored). You must sort the nodes when creating the result tree.",
// SYMBOLS_REDEF_ERR
"Decimal formatting ''{0}'' is already defined.",
// XSL_VERSION_ERR
"XSL version ''{0}'' is not supported by XSLTC.",
// CIRCULAR_VARIABLE_ERR
"Circular variable/parameter reference in ''{0}''.",
// ILLEGAL_BINARY_OP_ERR
"Unknown operator for binary expression.",
// ILLEGAL_ARG_ERR
"Illegal argument(s) for function call.",
// DOCUMENT_ARG_ERR
"Second argument to document() function must be a node-set.",
// MISSING_WHEN_ERR
"At least one <xsl:when> element required in <xsl:choose>.",
// MULTIPLE_OTHERWISE_ERR
"Only one <xsl:otherwise> element allowed in <xsl:choose>.",
// STRAY_OTHERWISE_ERR
"<xsl:otherwise> can only be used within <xsl:choose>.",
// STRAY_WHEN_ERR
"<xsl:when> can only be used within <xsl:choose>.",
// WHEN_ELEMENT_ERR
"Only <xsl:when> and <xsl:otherwise> elements allowed in <xsl:choose>.",
// UNNAMED_ATTRIBSET_ERR
"<xsl:attribute-set> is missing the 'name' attribute.",
// ILLEGAL_CHILD_ERR
"Illegal child element.",
// ILLEGAL_ELEM_NAME_ERR
"You cannot call an element ''{0}''",
// ILLEGAL_ATTR_NAME_ERR
"You cannot call an attribute ''{0}''",
// ILLEGAL_TEXT_NODE_ERR
"Text data outside of top-level <xsl:stylesheet> element.",
// SAX_PARSER_CONFIG_ERR
"JAXP parser not configured correctly",
// INTERNAL_ERR
"Unrecoverable XSLTC-internal error: ''{0}''",
// UNSUPPORTED_XSL_ERR
"Unsupported XSL element ''{0}''.",
// UNSUPPORTED_EXT_ERR
"Unrecognised XSLTC extension ''{0}''.",
// MISSING_XSLT_URI_ERR
"The input document is not a stylesheet "+
"(the XSL namespace is not declared in the root element).",
// MISSING_XSLT_TARGET_ERR
"Could not find stylesheet target ''{0}''.",
// NOT_IMPLEMENTED_ERR
"Not implemented: ''{0}''.",
// NOT_STYLESHEET_ERR
"The input document does not contain an XSL stylesheet.",
// ELEMENT_PARSE_ERR
"Could not parse element ''{0}''",
// KEY_USE_ATTR_ERR
"The use-attribute of <key> must be node, node-set, string or number.",
// OUTPUT_VERSION_ERR
"Output XML document version should be 1.0",
// ILLEGAL_RELAT_OP_ERR
"Unknown operator for relational expression",
// ATTRIBSET_UNDEF_ERR
"Attempting to use non-existing attribute set ''{0}''.",
// ATTR_VAL_TEMPLATE_ERR
"Cannot parse attribute value template ''{0}''.",
// UNKNOWN_SIG_TYPE_ERR
"Unknown data-type in signature for class ''{0}''.",
// NO_TRANSLET_CLASS_ERR
"This Templates does not contain a valid translet class definition.",
// NO_MAIN_TRANSLET_ERR
"This Templates does not contain a class with the name ''{0}''.",
// TRANSLET_CLASS_ERR
"Could not load the translet class ''{0}''.",
// TRANSLET_OBJECT_ERR
"Translet class loaded, but unable to create translet instance.",
// ERROR_LISTENER_NULL_ERR
"Attempting to set ErrorListener for ''{0}'' to null",
// JAXP_UNKNOWN_SOURCE_ERR
"Only StreamSource, SAXSource and DOMSOurce are supported by XSLTC",
// JAXP_NO_SOURCE_ERR
"Source object passed to ''{0}'' has no contents.",
// JAXP_COMPILE_ERR
"Could not compile stylesheet",
// JAXP_INVALID_ATTR_ERR
"TransformerFactory does not recognise attribute ''{0}''.",
// JAXP_SET_RESULT_ERROR
"setResult() must be called prior to startDocument().",
// JAXP_NO_TRANSLET_ERR
"The transformer has no encapsulated translet object.",
// JAXP_NO_HANDLER_ERR
"No defined output handler for transformation result.",
// JAXP_NO_RESULT_ERR
"Result object passed to ''{0}'' is invalid.",
// JAXP_UNKNOWN_PROP_ERR
"Attempting to access invalid Transformer property ''{0}''.",
// SAX2DOM_ADAPTER_ERR
"Could not crate SAX2DOM adapter: ''{0}''.",
// XSLTC_SOURCE_ERR
"XSLTCSource.build() called without systemId being set.",
// COMPILE_STDIN_ERR
"The -i option must be used with the -o option.",
// COMPILE_USAGE_STR
"Usage:\n" +
" xsltc [-o <output>] [-d <directory>] [-j <jarfile>]\n"+
" [-p <package name>] [-x] [-s] [-u] <stylesheet>|-i\n\n"+
" Where <output> is the name to give the the generated translet.\n"+
" <stylesheet> is one or more stylesheet file names, or if\n"+
" the -u options is specified, one or more stylesheet URLs.\n"+
" <directory> is the output directory.\n"+
" <jarfile> is the name of a JAR-file to put all classes in.\n"+
" <package-name> is used to prefix all class names.\n\n"+
" Notes:\n"+
" The -i options forces the compiler to read from stdin\n"+
" The -o option is ignored if compiling multiple stylesheets\n"+
" The -x option switched on debug messages.\n"+
" The -s option disables calling System.exit.",
// TRANSFORM_USAGE_STR
"Usage: \n" +
" xslt [-j <jarfile>] {-u <document_url> | <document>} <class>\n"+
" [<name1>=<value1> ...]\n\n" +
" Where <document> is the xml document to be transformed, or\n" +
" <document_url> is a url for the xml document,\n" +
" <class> is the translet class which is either in\n" +
" user's CLASSPATH or in the <jarfile> specified \n" +
" with the -j option.\n" +
" Notes:\n"+
" The -x option switched on debug messages.\n"+
" The -s option disables calling System.exit."
};
private static Vector _keys;
static {
_keys = new Vector();
_keys.addElement(ErrorMsg.ERROR_MESSAGES_KEY);
_keys.addElement(ErrorMsg.COMPILER_ERROR_KEY);
_keys.addElement(ErrorMsg.COMPILER_WARNING_KEY);
_keys.addElement(ErrorMsg.RUNTIME_ERROR_KEY);
}
public Enumeration getKeys() {
return _keys.elements();
}
public Object handleGetObject(String key) {
if (key == null) return null;
if (key.equals(ErrorMsg.ERROR_MESSAGES_KEY))
return errorMessages;
else if (key.equals(ErrorMsg.COMPILER_ERROR_KEY))
return "Compiler error(s): ";
else if (key.equals(ErrorMsg.COMPILER_WARNING_KEY))
return "Compiler warning(s): ";
else if (key.equals(ErrorMsg.RUNTIME_ERROR_KEY))
return "Translet error(s): ";
return(null);
}
}
1.1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMessages_en.java
Index: ErrorMessages_en.java
===================================================================
/*
* @(#)$Id: ErrorMessages_en.java,v 1.1 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, Sun
* Microsystems., http://www.sun.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
*
*/
package org.apache.xalan.xsltc.compiler.util;
import java.util.ResourceBundle;
public final class ErrorMessages_en extends ErrorMessages {
}
1.1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMessages_no.java
Index: ErrorMessages_no.java
===================================================================
/*
* @(#)$Id: ErrorMessages_no.java,v 1.1 2001/10/30 14:57:53 morten Exp $
*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, Sun
* Microsystems., http://www.sun.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Morten Jorgensen
*
*/
package org.apache.xalan.xsltc.compiler.util;
import java.util.Vector;
import java.util.Enumeration;
import java.util.ResourceBundle;
public final class ErrorMessages_no extends ErrorMessages {
// These message should be read from a locale-specific resource bundle
private static final String errorMessages[] = {
// MULTIPLE_STYLESHEET_ERR
"En fil kan bare innehold ett stilark.",
// TEMPLATE_REDEF_ERR
"<xsl:template> ''{0}'' er allerede definert i dette stilarket.",
// TEMPLATE_UNDEF_ERR
"<xsl:template> ''{0}'' er ikke definert i dette stilarket.",
// VARIABLE_REDEF_ERR
"Variabel ''{0}'' er allerede definert.",
// VARIABLE_UNDEF_ERR
"Variabel eller parameter ''{0}'' er ikke definert.",
// CLASS_NOT_FOUND_ERR
"Finner ikke klassen ''{0}''.",
// METHOD_NOT_FOUND_ERR
"Finner ikke ekstern funksjon ''{0}'' (m\u00e5 v\00e6re deklarert b\u00e5de 'static' og 'public').",
// ARGUMENT_CONVERSION_ERR
"Kan ikke konvertere argument/retur type i kall til funksjon ''{0}''",
// FILE_NOT_FOUND_ERR
"Finner ikke fil eller URI ''{0}''.",
// INVALID_URI_ERR
"Ugyldig URI ''{0}''.",
// FILE_ACCESS_ERR
"Kan ikke \u00e5pne fil eller URI ''{0}''.",
// MISSING_ROOT_ERR
"Forvented <xsl:stylesheet> eller <xsl:transform> element.",
// NAMESPACE_UNDEF_ERR
"Prefiks ''{0}'' er ikke deklarert.",
// FUNCTION_RESOLVE_ERR
"Kunne ikke resolvere kall til funksjon ''{0}''.",
// NEED_LITERAL_ERR
"Argument til ''{0}'' m\u00e5 v\00e6re ordrett tekst.",
// XPATH_PARSER_ERR
"Kunne ikke tolke XPath uttrykk ''{0}''.",
// REQUIRED_ATTR_ERR
"N\u00f8dvendig attributt ''{0}'' er ikke deklarert.",
// ILLEGAL_CHAR_ERR
"Ugyldig bokstav/tegn ''{0}'' i XPath uttrykk.",
// ILLEGAL_PI_ERR
"Ugyldig navn ''{0}'' for prosesserings-instruksjon.",
// STRAY_ATTRIBUTE_ERR
"Attributt ''{0}'' utenfor element.",
// ILLEGAL_ATTRIBUTE_ERR
"Ugyldig attributt ''{0}''.",
// CIRCULAR_INCLUDE_ERR
"Sirkul \00e6 import/include; stilark ''{0}'' er alt lest.",
// RESULT_TREE_SORT_ERR
"Result-tre fragmenter kan ikke sorteres (<xsl:sort> elementer vil "+
"bli ignorert). Du m\u00e5 sortere nodene mens du bygger treet.",
// SYMBOLS_REDEF_ERR
"Formatterings-symboler ''{0}'' er alt definert.",
// XSL_VERSION_ERR
"XSL versjon ''{0}'' er ikke st\u00f8ttet av XSLTC.",
// CIRCULAR_VARIABLE_ERR
"Sirkul\00e6r variabel/parameter referanse i ''{0}''.",
// ILLEGAL_BINARY_OP_ERR
"Ugyldig operator for bin\00e6rt uttrykk.",
// ILLEGAL_ARG_ERR
"Ugyldig parameter i funksjons-kall.",
// DOCUMENT_ARG_ERR
"Andre argument til document() m\u00e5 v\00e6re et node-sett.",
// MISSING_WHEN_ERR
"Du m\u00e5 deklarere minst ett <xsl:when> element innenfor <xsl:choose>.",
// MULTIPLE_OTHERWISE_ERR
"Kun ett <xsl:otherwise> element kan deklareres innenfor <xsl:choose>.",
// STRAY_OTHERWISE_ERR
"<xsl:otherwise> kan kun benyttes innenfor <xsl:choose>.",
// STRAY_WHEN_ERR
"<xsl:when> kan kun benyttes innenfor <xsl:choose>.",
// WHEN_ELEMENT_ERR
"Kun <xsl:when> og <xsl:otherwise> kan benyttes innenfor <xsl:choose>.",
// UNNAMED_ATTRIBSET_ERR
"<xsl:attribute-set> element manger 'name' attributt.",
// ILLEGAL_CHILD_ERR
"Ugyldig element.",
// ILLEGAL_ELEM_NAME_ERR
"''{0}'' er ikke et gyldig navn for et element.",
// ILLEGAL_ATTR_NAME_ERR
"''{0}'' er ikke et gyldig navn for et attributt.",
// ILLEGAL_TEXT_NODE_ERR
"Du kan ikke plassere tekst utenfor et <xsl:stylesheet> element.",
// SAX_PARSER_CONFIG_ERR
"JAXP parser er ikke korrekt konfigurert.",
// INTERNAL_ERR
"XSLTC-intern feil: ''{0}''",
// UNSUPPORTED_XSL_ERR
"St\u00f8tter ikke XSL element ''{0}''.",
// UNSUPPORTED_EXT_ERR
"XSLTC st\u00f8tter ikke utvidet funksjon ''{0}''.",
// MISSING_XSLT_URI_ERR
"Dette dokumentet er ikke et XSL stilark "+
"(xmlns:xsl='http://www.w3.org/1999/XSL/Transform' er ikke deklarert).",
// MISSING_XSLT_TARGET_ERR
"Kan ikke finne stilark ved navn ''{0}'' i dette dokumentet.",
// NOT_IMPLEMENTED_ERR
"Ikke implementert/gjenkjent: ''{0}''.",
// NOT_STYLESHEET_ERR
"Dokumentet inneholder ikke et XSL stilark",
// ELEMENT_PARSE_ERR
"Kan ikke tolke element ''{0}''",
// KEY_USE_ATTR_ERR
"'use'-attributtet i <xsl:key> m\u00e5 v\00e6re node, node-sett, tekst eller nummer.",
// OUTPUT_VERSION_ERR
"Det genererte XML dokumentet m\u00e5 gis versjon 1.0",
// ILLEGAL_RELAT_OP_ERR
"Ugyldig operator for relasjons-uttrykk.",
// ATTRIBSET_UNDEF_ERR
"Finner ikke <xsl:attribute-set> element med navn ''{0}''.",
// ATTR_VAL_TEMPLATE_ERR
"Kan ikke tolke attributt ''{0}''.",
// UNKNOWN_SIG_TYPE_ERR
"Ukjent data-type i signatur for klassen ''{0}''.",
// NO_TRANSLET_CLASS_ERR
"Dette Templates objected inneholder ingen translet klasse definisjon.",
// NO_MAIN_TRANSLET_ERR
"Dette Templates objected inneholder ingen klasse ved navn ''{0}''.",
// TRANSLET_CLASS_ERR
"Kan ikke laste translet-klasse ''{0}''.",
// TRANSLET_OBJECT_ERR
"Translet klassen er lastet man kan instansieres.",
// ERROR_LISTENER_NULL_ERR
"ErrorListener for ''{0}'' fors\u00f8kt satt til 'null'.",
// JAXP_UNKNOWN_SOURCE_ERR
"Kun StreamSource, SAXSource og DOMSOurce er st\u00f8ttet av XSLTC",
// JAXP_NO_SOURCE_ERR
"Source objekt sendt til ''{0}'' har intet innhold.",
// JAXP_COMPILE_ERR
"Kan ikke kompilere stilark.",
// JAXP_INVALID_ATTR_ERR
"TransformerFactory gjenkjenner ikke attributtet ''{0}''.",
// JAXP_SET_RESULT_ERROR
"setResult() m\u00e5 kalles f\u00f8r startDocument().",
// JAXP_NO_TRANSLET_ERR
"Transformer objektet inneholder ikken noen translet instans.",
// JAXP_NO_HANDLER_ERR
"Ingen 'handler' er satt for \u00e5 ta imot generert dokument.",
// JAXP_NO_RESULT_ERR
"Result objektet sendt til ''{0}'' er ikke gyldig.",
// JAXP_UNKNOWN_PROP_ERR
"Fors\u00f8ker \u00e5 lese ugyldig attributt ''{0}'' fra Transformer.",
// SAX2DOM_ADAPTER_ERR
"Kan ikke instansiere SAX2DOM adapter: ''{0}''.",
// XSLTC_SOURCE_ERR
"XSLTCSource.build() kalt uten at 'systemId' er definert.",
// COMPILE_STDIN_ERR
"Du kan ikke bruke -i uten \u00e5 ogs\u00e5 angi klasse-navn med -o.",
// COMPILE_USAGE_STR
"Bruk:\n" +
" xsltc [-o <klasse>] [-d <katalog>] [-j <arkiv>]\n"+
" [-p <pakke>] [-x] [-s] [-u] <stilark>|-i\n\n"+
" Der: <klasse> er navnet du vil gi den kompilerte java klassen.\n"+
" <stilark> er ett eller flere XSL stilark, eller dersom -u\n"+
" er benyttet, en eller flere URL'er til stilark.\n"+
" <katalog> katalog der klasse filer vil plasseres.\n"+
" <arkiv> er en JAR-fil der klassene vil plasseres\n"+
" <pakke> er an Java 'package' klassene vil legges i.\n\n"+
" Annet:\n"+
" -i tvinger kompilatoren til \u00e5 lese fra stdin.\n"+
" -o ignoreres dersom flere enn ett silark kompileres.\n"+
" -x sl\u00e5r p\u00e5 debug meldinger.\n"+
" -s blokkerer alle kall til System.exit().",
// TRANSFORM_USAGE_STR
"Bruk: \n" +
" xslt [-j <arkiv>] {-u <url> | <dokument>} <klasse>\n"+
" [<param>=<verdi> ...]\n\n" +
" Der: <dokument> er XML dokumentet som skal behandles.\n" +
" <url> er en URL til XML dokumentet som skal behandles.\n" +
" <klasse> er Java klassen som skal benyttes.\n" +
" <arkiv> er en JAR-fil som klassen leses fra.\n"+
" Annet:\n"+
" -x sl\u00e5r p\u00e5 debug meldinger.\n"+
" -s blokkerer alle kall til System.exit()."
};
private static Vector _keys;
static {
_keys = new Vector();
_keys.addElement(ErrorMsg.ERROR_MESSAGES_KEY);
_keys.addElement(ErrorMsg.COMPILER_ERROR_KEY);
_keys.addElement(ErrorMsg.COMPILER_WARNING_KEY);
_keys.addElement(ErrorMsg.RUNTIME_ERROR_KEY);
}
public Enumeration getKeys() {
return _keys.elements();
}
public Object handleGetObject(String key) {
if (key == null) return null;
if (key.equals(ErrorMsg.ERROR_MESSAGES_KEY))
return errorMessages;
else if (key.equals(ErrorMsg.COMPILER_ERROR_KEY))
return "Compiler error(s): ";
else if (key.equals(ErrorMsg.COMPILER_WARNING_KEY))
return "Compiler warning(s): ";
else if (key.equals(ErrorMsg.RUNTIME_ERROR_KEY))
return "Translet error(s): ";
return(null);
}
}
1.10 +3 -2 xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java
Index: LoadDocument.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- LoadDocument.java 2001/10/25 10:23:32 1.9
+++ LoadDocument.java 2001/10/30 14:57:54 1.10
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: LoadDocument.java,v 1.9 2001/10/25 10:23:32 morten Exp $
+ * @(#)$Id: LoadDocument.java,v 1.10 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -240,7 +240,8 @@
return(union);
}
else {
- throw new IllegalArgumentException("Illegal argument to document() function");
+ final String err = "document("+arg.toString()+")";
+ throw new IllegalArgumentException(err);
}
}
catch (Exception e) {
1.5 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecordFactory.java
Index: NodeSortRecordFactory.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecordFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NodeSortRecordFactory.java 2001/09/28 14:39:14 1.4
+++ NodeSortRecordFactory.java 2001/10/30 14:57:54 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeSortRecordFactory.java,v 1.4 2001/09/28 14:39:14 morten Exp $
+ * @(#)$Id: NodeSortRecordFactory.java,v 1.5 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -93,7 +93,7 @@
_translet = (AbstractTranslet)translet;
}
catch (ClassNotFoundException e) {
- throw new TransletException("Could not find class " + className);
+ throw new TransletException(e);
}
}
1.28 +4 -6 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
Index: AbstractTranslet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- AbstractTranslet.java 2001/10/15 09:13:23 1.27
+++ AbstractTranslet.java 2001/10/30 14:57:54 1.28
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: AbstractTranslet.java,v 1.27 2001/10/15 09:13:23 morten Exp $
+ * @(#)$Id: AbstractTranslet.java,v 1.28 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -110,12 +110,10 @@
*/
public final DOMAdapter makeDOMAdapter(DOM dom)
throws TransletException {
- if (dom instanceof DOMImpl) {
+ if (dom instanceof DOMImpl)
return new DOMAdapter((DOMImpl)dom, namesArray, namespaceArray);
- }
- else {
- throw new TransletException("wrong type of source DOM");
- }
+ BasisLibrary.runTimeError(BasisLibrary.DOM_ADAPTER_INIT_ERR);
+ return null;
}
/************************************************************************
1.24 +79 -32 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
Index: BasisLibrary.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- BasisLibrary.java 2001/10/22 07:40:39 1.23
+++ BasisLibrary.java 2001/10/30 14:57:54 1.24
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BasisLibrary.java,v 1.23 2001/10/22 07:40:39 morten Exp $
+ * @(#)$Id: BasisLibrary.java,v 1.24 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -66,10 +66,10 @@
package org.apache.xalan.xsltc.runtime;
-//import java.util.Hashtable;
+import java.text.MessageFormat;
+import java.text.FieldPosition;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-import java.text.FieldPosition;
import org.xml.sax.AttributeList;
@@ -204,7 +204,8 @@
return stringToReal(((DOM) obj).getStringValue());
}
else {
- runTimeError("Invalid argument type in call to number().");
+ final String className = obj.getClass().getName();
+ runTimeError(INVALID_ARGUMENT_ERR, className, "number()");
return 0.0;
}
}
@@ -238,7 +239,8 @@
return !temp.equals(EMPTYSTRING);
}
else {
- runTimeError("Invalid argument type in call to number().");
+ final String className = obj.getClass().getName();
+ runTimeError(INVALID_ARGUMENT_ERR, className, "number()");
}
return false;
}
@@ -259,7 +261,7 @@
return value.substring(istart);
}
catch (IndexOutOfBoundsException e) {
- runTimeInternalError();
+ runTimeError(RUN_TIME_INTERNAL_ERR, "substring()");
return null;
}
}
@@ -287,7 +289,7 @@
return value.substring(istart, isum);
}
catch (IndexOutOfBoundsException e) {
- runTimeInternalError();
+ runTimeError(RUN_TIME_INTERNAL_ERR, "substring()");
return null;
}
}
@@ -403,7 +405,7 @@
* an unresolved external function.
*/
public static void unresolved_externalF(String name) {
- runTimeError("External function '"+name+"' not supported by XSLTC.");
+ runTimeError(EXTERNAL_FUNC_ERR, name);
}
/**
@@ -424,8 +426,7 @@
if (name.equals("xsl:vendor-url"))
return("http://xml.apache.org/xalan-j");
- runTimeError("Invalid argument type '"+name+
- "' in call to system-property().");
+ runTimeError(INVALID_ARGUMENT_ERR, name, "system-property()");
return(EMPTYSTRING);
}
@@ -469,7 +470,7 @@
return numberF(lstring, dom) <= numberF(rstring, dom);
default:
- runTimeInternalError();
+ runTimeError(RUN_TIME_INTERNAL_ERR, "compare()");
return false;
}
}
@@ -608,7 +609,7 @@
break;
default:
- runTimeInternalError();
+ runTimeError(RUN_TIME_INTERNAL_ERR, "compare()");
}
return false;
@@ -673,7 +674,7 @@
return numberF(left, dom) <= numberF(right, dom);
default:
- runTimeInternalError();
+ runTimeError(RUN_TIME_INTERNAL_ERR, "compare()");
}
}
// falls through
@@ -761,7 +762,8 @@
return(false);
}
else {
- runTimeError("Unknown argument type in call to equal.");
+ final String className = right.getClass().getName();
+ runTimeError(INVALID_ARGUMENT_ERR, className, "compare()");
}
}
return result;
@@ -860,8 +862,7 @@
return(result.toString());
}
catch (IllegalArgumentException e) {
- runTimeError("Attempting to format number '"+ number +
- "' using pattern '" + pattern + "'.");
+ runTimeError(FORMAT_NUMBER_ERR, Double.toString(number), pattern);
return(EMPTYSTRING);
}
}
@@ -886,12 +887,13 @@
return(dom.getIterator());
}
else {
- runTimeTypeError("reference", obj.getClass().getName());
+ final String className = obj.getClass().getName();
+ runTimeError(DATA_CONVERSION_ERR, "reference", className);
return null;
}
}
catch (ClassCastException e) {
- runTimeTypeError("reference", "node-set");
+ runTimeError(DATA_CONVERSION_ERR, "reference", "node-set");
return null;
}
}
@@ -935,29 +937,74 @@
}
}
catch (TransletException e) {
- runTimeError("TransletException raised in copy().");
+ runTimeError(RUN_TIME_COPY_ERR);
}
}
- /**
- * Print a run-time type error message.
- */
- public static void runTimeTypeError(String from, String to) {
- runTimeError("Invalid conversion from '" + from + "' to '" + to + "'.");
- }
+ public static final int RUN_TIME_INTERNAL_ERR = 0;
+ public static final int RUN_TIME_COPY_ERR = 1;
+ public static final int DATA_CONVERSION_ERR = 2;
+ public static final int EXTERNAL_FUNC_ERR = 3;
+ public static final int EQUALITY_EXPR_ERR = 4;
+ public static final int INVALID_ARGUMENT_ERR = 5;
+ public static final int FORMAT_NUMBER_ERR = 6;
+ public static final int ITERATOR_CLONE_ERR = 7;
+ public static final int AXIS_SUPPORT_ERR = 8;
+ public static final int TYPED_AXIS_SUPPORT_ERR = 9;
+ public static final int STRAY_ATTRIBUTE_ERR = 10;
+ public static final int STRAY_NAMESPACE_ERR = 11;
+ public static final int NAMESPACE_PREFIX_ERR = 12;
+ public static final int DOM_ADAPTER_INIT_ERR = 13;
+
+ private final static String[] errorMessages = {
+ // RUN_TIME_INTERNAL_ERR
+ "Run-time internal error in ''{0}''",
+ // RUN_TIME_COPY_ERR
+ "Run-time error when executing <xsl:copy>.",
+ // DATA_CONVERSION_ERR
+ "Invalid conversion from ''{0}'' to ''{1}''.",
+ // EXTERNAL_FUNC_ERR
+ "External function ''{0}'' not supported by XSLTC.",
+ // EQUALITY_EXPR_ERR
+ "Unknown argument type in equality expression.",
+ // INVALID_ARGUMENT_ERR
+ "Invalid argument type ''{0}'' in call to ''{1}''",
+ // FORMAT_NUMBER_ERR
+ "Attempting to format number ''{0}'' using pattern ''{1}''.",
+ // ITERATOR_CLONE_ERR
+ "Cannot clone iterator ''{0}''.",
+ // AXIS_SUPPORT_ERR
+ "Iterator for axis ''{0}'' not supported.",
+ // TYPED_AXIS_SUPPORT_ERR
+ "Iterator for typed axis ''{0}'' not supported.",
+ // STRAY_ATTRIBUTE_ERR
+ "Attribute ''{0}'' outside of element.",
+ // STRAY_NAMESPACE_ERR
+ "Namespace declaration ''{0}''=''{1}'' outside of element.",
+ // NAMESPACE_PREFIX_ERR
+ "Namespace for prefix ''{0}'' has not been declared.",
+ // DOM_ADAPTER_INIT_ERR
+ "DOMAdapter created using wrong type of source DOM."
+ };
/**
- * Print a run-time internal error message.
+ * Print a run-time error message.
*/
- public static void runTimeInternalError() {
- runTimeError("Internal error.");
+ public static void runTimeError(int code) {
+ throw new RuntimeException(errorMessages[code]);
}
- /**
- * Print a run-time error message.
- */
- public static void runTimeError(String message) {
+ public static void runTimeError(int code, Object[] args) {
+ final String message = MessageFormat.format(errorMessages[code],args);
throw new RuntimeException(message);
+ }
+
+ public static void runTimeError(int code, Object arg0) {
+ runTimeError(code, new Object[]{ arg0 } );
+ }
+
+ public static void runTimeError(int code, Object arg0, Object arg1) {
+ runTimeError(code, new Object[]{ arg0, arg1 } );
}
public static void consoleOutput(String msg) {
1.8 +5 -5 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java
Index: SAXAdapter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/SAXAdapter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SAXAdapter.java 2001/08/30 12:36:07 1.7
+++ SAXAdapter.java 2001/10/30 14:57:54 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SAXAdapter.java,v 1.7 2001/08/30 12:36:07 amiro Exp $
+ * @(#)$Id: SAXAdapter.java,v 1.8 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -135,13 +135,13 @@
}
}
- public void attribute(String attributeName, String attributeValue)
+ public void attribute(String name, String value)
throws TransletException {
if (_openElementName != null) {
- _attributes.add(attributeName, attributeValue);
+ _attributes.add(name, value);
}
else {
- throw new TransletException("attribute outside of start tag");
+ BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, name);
}
}
@@ -177,7 +177,7 @@
public void omitHeader(boolean value) {}
public void setCdataElements(Hashtable elements) { }
public void close() {}
- public boolean setEscaping(boolean escape) throws TransletException {
+ public boolean setEscaping(boolean escape) throws TransletException {
return(true);
}
public String getPrefix(String uri) { return(""); }
1.40 +11 -40 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
Index: TextOutput.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- TextOutput.java 2001/10/25 15:48:12 1.39
+++ TextOutput.java 2001/10/30 14:57:54 1.40
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TextOutput.java,v 1.39 2001/10/25 15:48:12 morten Exp $
+ * @(#)$Id: TextOutput.java,v 1.40 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -268,11 +268,9 @@
final String prefix = _elementName.substring(0,col);
final String localname = _elementName.substring(col+1);
final String uri = lookupNamespace(prefix);
- if (uri == null) {
- throw new TransletException("Namespace for prefix "+
- prefix+" has not been "+
- "declared.");
- }
+ if (uri == null)
+ BasisLibrary.runTimeError(BasisLibrary.NAMESPACE_PREFIX_ERR,
+ prefix);
if (uri.equals(EMPTYSTRING)) _elementName = localname;
_saxHandler.startElement(uri, localname,
_elementName, _attributes);
@@ -666,11 +664,9 @@
final String localname = qname.substring(endcol+1);
final String prefix = qname.substring(0,startcol);
final String uri = lookupNamespace(prefix);
- if (uri == null) {
- throw new TransletException("Namespace for prefix "+
- prefix+" has not been "+
- "declared.");
- }
+ if (uri == null)
+ BasisLibrary.runTimeError(BasisLibrary.NAMESPACE_PREFIX_ERR,
+ prefix);
// Omit prefix (use default) if the namespace URI is null
if (uri.equals(EMPTYSTRING))
return(localname);
@@ -694,8 +690,7 @@
return;
case XML:
if (!_startTagOpen)
- throw new TransletException("attribute '"+name+
- "' outside of element");
+ BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR,name);
// Attributes whose names start with XML need special handling
if (name.startsWith("xml")) {
// Output as namespace declaration
@@ -716,9 +711,7 @@
return;
case HTML:
if (!_startTagOpen)
- throw new TransletException("attribute '"+name+
- "' outside of element");
-
+ BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR,name);
// The following is an attempt to escape an URL stored in a href
// attribute of HTML output. Normally URLs should be encoded at
// the time they are created, since escaping or unescaping a
@@ -912,36 +905,14 @@
pushNamespace(prefix, uri);
else {
if ((prefix == EMPTYSTRING) && (uri == EMPTYSTRING)) return;
- throw new TransletException("namespace declaration '"+prefix+
- "'='"+uri+"' outside of element");
+ BasisLibrary.runTimeError(BasisLibrary.STRAY_NAMESPACE_ERR,
+ prefix, uri);
}
}
catch (SAXException e) {
throw new TransletException(e);
}
}
-
- /**
- * Takes a qname as a string on the format prefix:local-name and
- * returns a strig with the expanded QName on the format uri:local-name.
- */
- /*
- private String expandQName(String withPrefix) {
- int col = withPrefix.lastIndexOf(':');
- if (col == -1) return(withPrefix);
-
- final String prefix = withPrefix.substring(0,col);
- final String local = withPrefix.substring(col+1,withPrefix.length());
- final String uri = lookupNamespace(prefix);
-
- if (uri == null)
- return(local);
- else if (uri == EMPTYSTRING)
- return(local);
- else
- return(uri+":"+local);
- }
- */
/************************************************************************
* The following are all methods for configuring the output settings
1.8 +36 -41 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java
Index: TemplatesImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TemplatesImpl.java 2001/10/02 11:16:52 1.7
+++ TemplatesImpl.java 2001/10/30 14:57:54 1.8
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TemplatesImpl.java,v 1.7 2001/10/02 11:16:52 morten Exp $
+ * @(#)$Id: TemplatesImpl.java,v 1.8 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -76,31 +76,24 @@
import org.apache.xalan.xsltc.Translet;
import org.apache.xalan.xsltc.compiler.*;
import org.apache.xalan.xsltc.runtime.*;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
-
public final class TemplatesImpl implements Templates, Serializable {
// Contains the name of the main translet class
- private String _transletName = null;
+ private String _name = null;
// Contains the actual class definition for the translet class and
// any auxiliary classes (representing node sort records, predicates, etc.)
private byte[][] _bytecodes = null;
- private Class[] _class = null;
+ // Contains the translet class definition(s). These are created when this
+ // Templates is first instanciated or read back from disk (see readObject())
+ private Class[] _class = null;
+ // This tells us which index the main translet class has in the _class
+ // and _bytecodes arrays (above).
private int _transletIndex = -1;
-
- // This error could occur when a compilation inside the TransformerFactory
- // failed and when a template has been loaded from stable storage.
- private final static String NO_TRANSLET_CODE =
- "This template does not contain a valid translet class definition.";
- private final static String NO_MAIN_TRANSLET =
- "This template does not contain a class with the name ";
- private final static String TRANSLET_CLASS_ERR =
- "Could not load the translet class ";
- private final static String TRANSLET_OBJECT_ERR =
- "Translet class loaded, but unable to create translet instance.";
// Our own private class loader - builds Class definitions from bytecodes
private class TransletClassLoader extends ClassLoader {
@@ -110,19 +103,18 @@
}
public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(_transletName);
+ out.writeObject(_name);
out.writeObject(_bytecodes);
out.flush();
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
- _transletName = (String)in.readObject();
- _bytecodes = (byte[][])in.readObject();
- _class = null;
+ _name = (String)in.readObject();
+ _bytecodes = (byte[][])in.readObject();
+ _class = null; // must be created again...
}
-
/**
* The only way to create an XSLTC emplate object
* The bytecodes for the translet and auxiliary classes, plus the name of
@@ -130,7 +122,7 @@
*/
protected TemplatesImpl(byte[][] bytecodes, String transletName) {
_bytecodes = bytecodes;
- _transletName = transletName;
+ _name = transletName;
}
/**
@@ -152,14 +144,14 @@
* The TransformerFactory should call this method to set the translet name
*/
protected void setTransletName(String name) {
- _transletName = name;
+ _name = name;
}
/**
* Returns the name of the main translet class stored in this template
*/
protected String getTransletName() {
- return _transletName;
+ return _name;
}
/**
@@ -169,8 +161,10 @@
private void defineTransletClasses()
throws TransformerConfigurationException {
- if (_bytecodes == null)
- throw new TransformerConfigurationException(NO_TRANSLET_CODE);
+ if (_bytecodes == null) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.NO_TRANSLET_CLASS_ERR);
+ throw new TransformerConfigurationException(err.toString());
+ }
TransletClassLoader loader =
(TransletClassLoader) AccessController.doPrivileged(
@@ -187,22 +181,23 @@
for (int i = 0; i < classCount; i++) {
_class[i] = loader.defineClass(_bytecodes[i]);
- if (_class[i].getName().equals(_transletName))
+ if (_class[i].getName().equals(_name))
_transletIndex = i;
}
- if (_transletIndex < 0)
- throw new TransformerConfigurationException(NO_MAIN_TRANSLET+
- _transletName);
+ if (_transletIndex < 0) {
+ ErrorMsg err= new ErrorMsg(ErrorMsg.NO_MAIN_TRANSLET_ERR,_name);
+ throw new TransformerConfigurationException(err.toString());
+ }
}
- catch (ClassFormatError e) {
- throw new TransformerConfigurationException(TRANSLET_CLASS_ERR+
- _transletName);
- }
- catch (LinkageError e) {
- throw new TransformerConfigurationException(TRANSLET_OBJECT_ERR+
- _transletName);
+ catch (ClassFormatError e) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_CLASS_ERR+_name);
+ throw new TransformerConfigurationException(err.toString());
+ }
+ catch (LinkageError e) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_OBJECT_ERR+_name);
+ throw new TransformerConfigurationException(err.toString());
}
}
@@ -214,7 +209,7 @@
private Translet getTransletInstance()
throws TransformerConfigurationException {
try {
- if (_transletName == null) return null;
+ if (_name == null) return null;
if (_class == null) defineTransletClasses();
@@ -232,12 +227,12 @@
return translet;
}
catch (InstantiationException e) {
- throw new TransformerConfigurationException(TRANSLET_OBJECT_ERR+
- _transletName);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_OBJECT_ERR+_name);
+ throw new TransformerConfigurationException(err.toString());
}
catch (IllegalAccessException e) {
- throw new TransformerConfigurationException(TRANSLET_OBJECT_ERR+
- _transletName);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_OBJECT_ERR+_name);
+ throw new TransformerConfigurationException(err.toString());
}
}
1.27 +30 -28 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- TransformerFactoryImpl.java 2001/10/22 10:53:56 1.26
+++ TransformerFactoryImpl.java 2001/10/30 14:57:54 1.27
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerFactoryImpl.java,v 1.26 2001/10/22 10:53:56 tmiller Exp $
+ * @(#)$Id: TransformerFactoryImpl.java,v 1.27 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -83,11 +83,13 @@
import org.xml.sax.InputSource;
import org.apache.xalan.xsltc.Translet;
+import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+
import org.apache.xalan.xsltc.compiler.XSLTC;
import org.apache.xalan.xsltc.compiler.SourceLoader;
import org.apache.xalan.xsltc.compiler.CompilerException;
import org.apache.xalan.xsltc.compiler.util.Util;
-import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
/**
* Implementation of a JAXP1.1 TransformerFactory for Translets.
@@ -113,20 +115,6 @@
"<xsl:template match=\"/\"><xsl:copy-of select=\".\"/></xsl:template>"+
"</xsl:stylesheet>";
- // All used error messages should be listed here
- private static final String ERROR_LISTENER_NULL =
- "Attempting to set ErrorListener for TransformerFactory to null";
- private static final String UNKNOWN_SOURCE_ERR =
- "Only StreamSource and SAXSource are supported by XSLTC";
- private static final String NO_SOURCE_ERR =
- "Source object passed to newTemplates() has no contents";
- private static final String NO_ACCESS_ERR =
- "Cannot access file or URL ";
- private static final String COMPILE_ERR =
- "Could not compile stylesheet";
- private static final String INVALID_ATTRIBUTE =
- "TransformerFactory does not recognise attribute: ";
-
// This Hashtable is used to store parameters for locating
// <?xml-stylesheet ...?> processing instructions in XML documents.
private Hashtable _piParams = null;
@@ -164,8 +152,11 @@
*/
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException {
- if (listener == null)
- throw new IllegalArgumentException(ERROR_LISTENER_NULL);
+ if (listener == null) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
+ "TransformerFactory");
+ throw new IllegalArgumentException(err.toString());
+ }
_errorListener = listener;
}
@@ -189,9 +180,11 @@
*/
public Object getAttribute(String name)
throws IllegalArgumentException {
- if (name.equals("translet-name"))
- return(_defaultTransletName);
- throw new IllegalArgumentException(INVALID_ATTRIBUTE+name);
+ // Return value for attribute 'translet-name'
+ if (name.equals("translet-name")) return(_defaultTransletName);
+ // Throw an exception for all other attributes
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
+ throw new IllegalArgumentException(err.toString());
}
/**
@@ -208,7 +201,9 @@
// for translets that cannot be given a name from their system-id.
if ((name.equals("translet-name")) && (value instanceof String))
_defaultTransletName = (String)value;
- throw new IllegalArgumentException(INVALID_ATTRIBUTE+name);
+ // Throw an exception for all other attributes
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
+ throw new IllegalArgumentException(err.toString());
}
/**
@@ -319,7 +314,8 @@
// Check that the transformation went well before returning
if (bytecodes == null) {
- throw new TransformerConfigurationException(COMPILE_ERR);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
+ throw new TransformerConfigurationException(err.toString());
}
// Create a Transformer object and store for other calls
@@ -435,18 +431,23 @@
}
}
else {
- throw new TransformerConfigurationException(UNKNOWN_SOURCE_ERR);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_SOURCE_ERR);
+ throw new TransformerConfigurationException(err.toString());
}
input.setSystemId(systemId);
}
catch (NullPointerException e) {
- throw new TransformerConfigurationException(NO_SOURCE_ERR);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR,
+ "TransformerFactory.newTemplates()");
+ throw new TransformerConfigurationException(err.toString());
}
catch (SecurityException e) {
- throw new TransformerConfigurationException(NO_ACCESS_ERR+systemId);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.FILE_ACCESS_ERR, systemId);
+ throw new TransformerConfigurationException(err.toString());
}
catch (MalformedURLException e){
- throw new TransformerConfigurationException(NO_ACCESS_ERR+systemId);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.FILE_ACCESS_ERR, systemId);
+ throw new TransformerConfigurationException(err.toString());
}
finally {
return(input);
@@ -500,7 +501,8 @@
passErrorsToListener(xsltc.getErrors());
else
xsltc.printErrors();
- throw new TransformerConfigurationException(COMPILE_ERR);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
+ throw new TransformerConfigurationException(err.toString());
}
return(new TemplatesImpl(bytecodes, transletName));
}
1.6 +7 -5 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java
Index: TransformerHandlerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TransformerHandlerImpl.java 2001/10/25 12:34:07 1.5
+++ TransformerHandlerImpl.java 2001/10/30 14:57:54 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerHandlerImpl.java,v 1.5 2001/10/25 12:34:07 morten Exp $
+ * @(#)$Id: TransformerHandlerImpl.java,v 1.6 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -71,6 +71,7 @@
import org.apache.xalan.xsltc.dom.DOMImpl;
import org.apache.xalan.xsltc.dom.DTDMonitor;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
/**
* Implementation of a JAXP1.1 TransformerHandler
@@ -87,9 +88,6 @@
private boolean _done = false; // Set in endDocument()
- private final static String NULL_RESULT_ERROR =
- "setResult() must be called prior to startDocument().";
-
/**
* Cosntructor - pass in reference to a TransformerImpl object
*/
@@ -168,13 +166,17 @@
* Receive notification of the beginning of a document.
*/
public void startDocument() throws SAXException {
+ // Make sure setResult() was called before the first SAX event
if (_result == null) {
- throw new SAXException(NULL_RESULT_ERROR);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SET_RESULT_ERR);
+ throw new SAXException(err.toString());
}
+
// Create an internal DOM (not W3C) and get SAX2 input handler
_dom = new DOMImpl();
_handler = _dom.getBuilder();
+ // Proxy call
_handler.startDocument();
}
1.31 +37 -46 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- TransformerImpl.java 2001/10/25 13:48:16 1.30
+++ TransformerImpl.java 2001/10/30 14:57:54 1.31
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerImpl.java,v 1.30 2001/10/25 13:48:16 morten Exp $
+ * @(#)$Id: TransformerImpl.java,v 1.31 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -105,6 +105,7 @@
import org.apache.xalan.xsltc.dom.*;
import org.apache.xalan.xsltc.runtime.*;
import org.apache.xalan.xsltc.compiler.*;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
import java.util.Properties;
@@ -127,26 +128,12 @@
// Pre-set DOMImpl to use as input (used only with TransformerHandlerImpl)
private DOMImpl _dom = null;
-
- // List all error messages here
- private final static String TRANSLET_ERR_MSG =
- "The transformer has no encapsulated translet object.";
- private final static String HANDLER_ERR_MSG =
- "No defined output handler for transformation result.";
- private static final String ERROR_LISTENER_NULL =
- "Attempting to set ErrorListener for Transformer to null";
- private static final String INPUT_SOURCE_EMPTY =
- "The Source object passed to transform() has no contents.";
- private static final String OUTPUT_RESULT_EMPTY =
- "The Result object passed to transform() is invalid.";
- private static final String NO_SUCH_PROPERTY =
- "Attempting to access invalid Transformer property: ";
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
private static final String NAMESPACE_FEATURE =
"http://xml.org/sax/features/namespaces";
-
+
/**
* Implements JAXP's Transformer constructor
* Our Transformer objects always need a translet to do the actual work
@@ -174,12 +161,14 @@
throws TransformerException {
if (_translet == null) {
- throw new TransformerException(TRANSLET_ERR_MSG);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_TRANSLET_ERR);
+ throw new TransformerException(err.toString());
}
_handler = getOutputHandler(result);
- if (_handler == null) {
- throw new TransformerException(HANDLER_ERR_MSG);
+ if (_handler == null) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_HANDLER_ERR);
+ throw new TransformerException(err.toString());
}
if (_uriResolver != null) {
@@ -246,15 +235,15 @@
// Common, final handling of all input sources, only used if the
// other contents of the Result object could not be used
if (systemId != null) {
- if ((new File(systemId)).exists())
- systemId = "file:"+systemId;
+ if ((new File(systemId)).exists()) systemId = "file:"+systemId;
final URL url = new URL(systemId);
final URLConnection connection = url.openConnection();
final OutputStream ostream = connection.getOutputStream();
return(new DefaultSAXOutputHandler(ostream, _encoding));
}
else {
- throw new TransformerException(OUTPUT_RESULT_EMPTY);
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_RESULT_ERR);
+ throw new TransformerException(err.toString());
}
}
// If we cannot write to the location specified by the SystemId
@@ -263,8 +252,8 @@
}
// If we cannot create a SAX2DOM adapter
catch (ParserConfigurationException e) {
- throw new TransformerException(
- "SAX2DOM adapter could not be created, " + e.getMessage());
+ ErrorMsg err = new ErrorMsg(ErrorMsg.SAX2DOM_ADAPTER_ERR);
+ throw new TransformerException(err.toString());
}
// If we cannot create the file specified by the SystemId
catch (IOException e) {
@@ -388,8 +377,10 @@
input = new InputSource(streamReader);
else if (systemId != null)
input = new InputSource(systemId);
- else
- throw new TransformerException(INPUT_SOURCE_EMPTY);
+ else {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
+ throw new TransformerException(err.toString());
+ }
// Parse the input and build the internal DOM
reader.parse(input);
@@ -414,23 +405,19 @@
return dom;
}
catch (FileNotFoundException e) {
- if (_errorListener != null)
- postErrorToListener("File not found: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
catch (MalformedURLException e) {
- if (_errorListener != null)
- postErrorToListener("Malformed URL: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
catch (UnknownHostException e) {
- if (_errorListener != null)
- postErrorToListener("Cannot resolve URI: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
catch (Exception e) {
- if (_errorListener != null)
- postErrorToListener("Internal error: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
}
@@ -458,18 +445,15 @@
_translet.transform(dom, handler);
}
catch (TransletException e) {
- if (_errorListener != null)
- postErrorToListener(e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
catch (RuntimeException e) {
- if (_errorListener != null)
- postErrorToListener("Runtime Error: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
catch (Exception e) {
- if (_errorListener != null)
- postErrorToListener("Internal error: " + e.getMessage());
+ if (_errorListener != null) postErrorToListener(e.getMessage());
throw new TransformerException(e);
}
}
@@ -493,8 +477,11 @@
*/
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException {
- if (listener == null)
- throw new IllegalArgumentException(ERROR_LISTENER_NULL);
+ if (listener == null) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
+ "Transformer");
+ throw new IllegalArgumentException(err.toString());
+ }
_errorListener = listener;
}
@@ -573,8 +560,10 @@
*/
public String getOutputProperty(String name)
throws IllegalArgumentException {
- if (!validOutputProperty(name))
- throw new IllegalArgumentException(NO_SUCH_PROPERTY+name);
+ if (!validOutputProperty(name)) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);
+ throw new IllegalArgumentException(err.toString());
+ }
return(_properties.getProperty(name));
}
@@ -604,8 +593,10 @@
*/
public void setOutputProperty(String name, String value)
throws IllegalArgumentException {
- if (!validOutputProperty(name))
- throw new IllegalArgumentException(NO_SUCH_PROPERTY+name);
+ if (!validOutputProperty(name)) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);
+ throw new IllegalArgumentException(err.toString());
+ }
_properties.setProperty(name, value);
}
1.3 +7 -5 xml-xalan/java/src/org/apache/xalan/xsltc/trax/XSLTCSource.java
Index: XSLTCSource.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/XSLTCSource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSLTCSource.java 2001/10/03 11:03:09 1.2
+++ XSLTCSource.java 2001/10/30 14:57:54 1.3
@@ -1,6 +1,6 @@
/*
- * @(#)$Id: XSLTCSource.java,v 1.2 2001/10/03 11:03:09 morten Exp $
+ * @(#)$Id: XSLTCSource.java,v 1.3 2001/10/30 14:57:54 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -82,6 +82,7 @@
import org.apache.xalan.xsltc.dom.DOMImpl;
import org.apache.xalan.xsltc.dom.DOMBuilder;
import org.apache.xalan.xsltc.dom.DTDMonitor;
+import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
public final class XSLTCSource implements Source {
@@ -92,9 +93,6 @@
private final static String LEXICAL_HANDLER_PROPERTY =
"http://xml.org/sax/properties/lexical-handler";
- private final static String NO_SYSTEM_ID_ERR =
- "build() called before setSystemId(String systemId)";
-
/**
* Create a new XSLTC-specific DOM source
* @param size The estimated node-count for this DOM. A good guess here
@@ -148,9 +146,13 @@
public void build(XMLReader reader, String systemId) throws SAXException {
try {
// Make sure that the system id is set before proceding
- if (systemId == null) throw new SAXException(NO_SYSTEM_ID_ERR);
+ if ((systemId == null) && (_systemId == null)) {
+ ErrorMsg err = new ErrorMsg(ErrorMsg.XSLTC_SOURCE_ERR);
+ throw new SAXException(err.toString());
+ }
// Use this method in case we need to prepend 'file:' to url
+ if (systemId == null) systemId = _systemId;
setSystemId(systemId);
// Create an input source for the parser first, just in case the
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org