santiagopg 2003/04/24 08:45:32
Modified: java/src/org/apache/xalan/xsltc/compiler XSLTC.java
java/src/org/apache/xalan/xsltc/trax
TemplatesHandlerImpl.java
Log:
Output properties were not properly cleared when reusing the same instance
of a TemplatesHandlerImpl. The top-level stylesheet in the XSLTC object
referenced by TemplatesHandlerImpl (indirectly via an instance of Parser)
was not reset after the first use of the instance.
Revision Changes Path
1.52 +36 -35
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
Index: XSLTC.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- XSLTC.java 1 Apr 2003 21:09:00 -0000 1.51
+++ XSLTC.java 24 Apr 2003 15:45:32 -0000 1.52
@@ -101,9 +101,9 @@
// A reference to an external SourceLoader (for use with include/import)
private SourceLoader _loader = null;
-
+
// A reference to the stylesheet being compiled.
- private Stylesheet _stylesheet = null;
+ private Stylesheet _stylesheet;
// Counters used by various classes to generate unique names.
// private int _variableSerial = 1;
@@ -112,9 +112,9 @@
private int _stepPatternSerial = 1;
private int _helperClassSerial = 0;
private int _attributeSetSerial = 0;
-
+
private int[] _numberFieldIndexes;
-
+
// Name index tables
private int _nextGType; // Next available element type
private Vector _namesIndex; // Index of all registered QNames
@@ -133,7 +133,7 @@
public static final int CLASSLOADER_OUTPUT = 3;
public static final int BYTEARRAY_AND_FILE_OUTPUT = 4;
public static final int BYTEARRAY_AND_JAR_OUTPUT = 5;
-
+
// Compiler options (passed from command line or XSLTC client)
private boolean _debug = false; // -x
@@ -194,7 +194,7 @@
_classes = new Vector();
_bcelClasses = new Vector();
}
-
+
/**
* Initializes the compiler to produce a new translet
*/
@@ -206,6 +206,7 @@
_namespaces.put("",new Integer(_nextNSType));
_namesIndex = new Vector(128);
_namespaceIndex = new Vector(32);
+ _stylesheet = null;
_parser.init();
//_variableSerial = 1;
_modeSerial = 1;
@@ -226,7 +227,7 @@
* Defines an external SourceLoader to provide the compiler with
documents
* referenced in xsl:include/import
* @param loader The SourceLoader to use for include/import
- */
+ */
public void setSourceLoader(SourceLoader loader) {
_loader = loader;
}
@@ -253,7 +254,7 @@
public void setPIParameters(String media, String title, String charset) {
_parser.setPIParameters(media, title, charset);
}
-
+
/**
* Compiles an XSL stylesheet pointed to by a URL
* @param url An URL containing the input XSL stylesheet
@@ -315,7 +316,7 @@
reset();
// The systemId may not be set, so we'll have to check the URL
- String systemId = null;
+ String systemId = null;
if (input != null) {
systemId = input.getSystemId();
}
@@ -386,7 +387,7 @@
public boolean compile(Vector stylesheets) {
// Get the number of stylesheets (ie. URLs) in the vector
final int count = stylesheets.size();
-
+
// Return straight away if the vector is empty
if (count == 0) return true;
@@ -403,7 +404,7 @@
// Traverse all elements in the vector and compile
final Enumeration urls = stylesheets.elements();
while (urls.hasMoreElements()) {
- _className = null; // reset, so that new name will be computed
+ _className = null; // reset, so that new name will be computed
final Object url = urls.nextElement();
if (url instanceof URL) {
if (!compile((URL)url)) return false;
@@ -440,7 +441,7 @@
else
return null;
}
-
+
/**
* Compiles a stylesheet pointed to by a URL. The result is put in a
* set of byte arrays. One byte array for each generated class.
@@ -450,7 +451,7 @@
*/
public byte[][] compile(String name, InputSource input) {
return compile(name, input, BYTEARRAY_OUTPUT);
- }
+ }
/**
* Set the XMLReader to use for parsing the next input stylesheet
@@ -459,7 +460,7 @@
public void setXMLReader(XMLReader reader) {
_reader = reader;
}
-
+
/**
* Get the XMLReader to use for parsing the next input stylesheet
*/
@@ -521,11 +522,11 @@
public boolean callsNodeset() {
return _callsNodeset;
}
-
+
protected void setHasIdCall(boolean flag) {
_hasIdCall = flag;
}
-
+
public boolean hasIdCall() {
return _hasIdCall;
}
@@ -538,7 +539,7 @@
*/
public void setClassName(String className) {
final String base = Util.baseName(className);
- final String noext = Util.noExtName(base);
+ final String noext = Util.noExtName(base);
String name = Util.toJavaName(noext);
if (_packageName == null)
@@ -546,7 +547,7 @@
else
_className = _packageName + '.' + name;
}
-
+
/**
* Get the class name for the generated translet.
*/
@@ -561,7 +562,7 @@
private String classFileName(final String className) {
return className.replace('.', File.separatorChar) + ".class";
}
-
+
/**
* Generate an output File object to send the translet to
*/
@@ -626,7 +627,7 @@
public Stylesheet getStylesheet() {
return _stylesheet;
}
-
+
/**
* Registers an attribute and gives it a type so that it can be mapped to
* DOM attribute types at run-time.
@@ -674,7 +675,7 @@
final SymbolTable stable = _parser.getSymbolTable();
final String uri = stable.lookupNamespace(name.toString());
final int code = registerNamespace(uri);
- return code;
+ return code;
}
/**
@@ -690,7 +691,7 @@
}
return code.intValue();
}
-
+
public int nextModeSerial() {
return _modeSerial++;
}
@@ -710,7 +711,7 @@
public int nextHelperClassSerial() {
return _helperClassSerial++;
}
-
+
public int nextAttributeSetSerial() {
return _attributeSetSerial++;
}
@@ -722,7 +723,7 @@
public Vector getNamespaceIndex() {
return _namespaceIndex;
}
-
+
/**
* Returns a unique name for every helper class needed to
* execute a translet.
@@ -730,11 +731,11 @@
public String getHelperClassName() {
return getClassName() + '$' + _helperClassSerial++;
}
-
+
public void dumpClass(JavaClass clazz) {
-
- if (_outputType == FILE_OUTPUT ||
- _outputType == BYTEARRAY_AND_FILE_OUTPUT)
+
+ if (_outputType == FILE_OUTPUT ||
+ _outputType == BYTEARRAY_AND_FILE_OUTPUT)
{
File outFile = getOutputFile(clazz.getClassName());
String parentDir = outFile.getParent();
@@ -744,7 +745,7 @@
parentFile.mkdirs();
}
}
-
+
try {
switch (_outputType) {
case FILE_OUTPUT:
@@ -754,7 +755,7 @@
getOutputFile(clazz.getClassName()))));
break;
case JAR_OUTPUT:
- _bcelClasses.addElement(clazz);
+ _bcelClasses.addElement(clazz);
break;
case BYTEARRAY_OUTPUT:
case BYTEARRAY_AND_FILE_OUTPUT:
@@ -763,13 +764,13 @@
ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
clazz.dump(out);
_classes.addElement(out.toByteArray());
-
+
if (_outputType == BYTEARRAY_AND_FILE_OUTPUT)
clazz.dump(new BufferedOutputStream(
new
FileOutputStream(getOutputFile(clazz.getClassName()))));
else if (_outputType == BYTEARRAY_AND_JAR_OUTPUT)
_bcelClasses.addElement(clazz);
-
+
break;
}
}
@@ -784,7 +785,7 @@
private String entryName(File f) throws IOException {
return f.getName().replace(File.separatorChar, '/');
}
-
+
/**
* Generate output JAR-file and packages
*/
@@ -798,7 +799,7 @@
// create manifest
Enumeration classes = _bcelClasses.elements();
final String now = (new Date()).toString();
- final java.util.jar.Attributes.Name dateAttr =
+ final java.util.jar.Attributes.Name dateAttr =
new java.util.jar.Attributes.Name("Date");
while (classes.hasMoreElements()) {
final JavaClass clazz = (JavaClass)classes.nextElement();
1.23 +6 -7
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java
Index: TemplatesHandlerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesHandlerImpl.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- TemplatesHandlerImpl.java 16 Apr 2003 21:54:48 -0000 1.22
+++ TemplatesHandlerImpl.java 24 Apr 2003 15:45:32 -0000 1.23
@@ -123,11 +123,8 @@
_indentNumber = indentNumber;
_tfactory = tfactory;
- // Initialize a parser object
- XSLTC xsltc = new XSLTC();
- xsltc.init();
- xsltc.setOutputType(XSLTC.BYTEARRAY_OUTPUT);
- _parser = xsltc.getParser();
+ // Instantiate XSLTC and get reference to parser object
+ _parser = new XSLTC().getParser();
}
/**
@@ -269,7 +266,9 @@
* Re-initialize parser and forward SAX2 event.
*/
public void startDocument() {
- _parser.init();
+ XSLTC xsltc = _parser.getXSLTC();
+ xsltc.init(); // calls _parser.init()
+ xsltc.setOutputType(XSLTC.BYTEARRAY_OUTPUT);
_parser.startDocument();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]