morten 01/05/21 07:46:23
Modified: java/src/org/apache/xalan/xsltc/compiler
FormatNumberCall.java Stylesheet.java
Log:
Change to ensure that the translet only instanciates e DecimalFormat
object when it has to. FormatNumberCall.typeCheck() sets a flag
in Stylesheet to indicate that a DecimalFormat object is needed.
Obtained from: none
Submitted by: [EMAIL PROTECTED]
Reviewed by: [EMAIL PROTECTED]
Revision Changes Path
1.2 +6 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FormatNumberCall.java
Index: FormatNumberCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FormatNumberCall.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FormatNumberCall.java 2001/04/17 18:51:29 1.1
+++ FormatNumberCall.java 2001/05/21 14:46:08 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: FormatNumberCall.java,v 1.1 2001/04/17 18:51:29 sboag Exp $
+ * @(#)$Id: FormatNumberCall.java,v 1.2 2001/05/21 14:46:08 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -83,6 +83,11 @@
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
+ // The stylesheet element only adds code to instanciate the
+ // default DecimalFormat object if at least one format-number()
+ // call exists in the stylesheet. We must signal this call...
+ getStylesheet().numberFormattingUsed();
+
final Type tvalue = _value.typeCheck(stable);
if (tvalue instanceof RealType == false) {
_value = new CastExpr(_value, Type.Real);
1.5 +13 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
Index: Stylesheet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Stylesheet.java 2001/05/17 11:02:35 1.4
+++ Stylesheet.java 2001/05/21 14:46:12 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Stylesheet.java,v 1.4 2001/05/17 11:02:35 morten Exp $
+ * @(#)$Id: Stylesheet.java,v 1.5 2001/05/21 14:46:12 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -119,6 +119,8 @@
// All named key elements (needed by Key/IdPattern)
private Hashtable _keys = new Hashtable();
+ private boolean _numberFormattingUsed = false;
+
private boolean _simplified = false;
public boolean isSimplified() {
@@ -147,6 +149,10 @@
return ((parent != null) && (parent instanceof Include));
}
+ public void numberFormattingUsed() {
+ _numberFormattingUsed = true;
+ }
+
public void setImportPrecedence(final int precedence) {
_importPrecedence = precedence;
@@ -552,7 +558,8 @@
// Compile default decimal formatting symbols.
// This is an implicit, nameless xsl:decimal-format top-level element.
- DecimalFormatting.translateDefaultDFS(classGen, constructor);
+ if (_numberFormattingUsed)
+ DecimalFormatting.translateDefaultDFS(classGen, constructor);
il.append(RETURN);
@@ -922,8 +929,12 @@
}
public String getNamespace(String prefix) {
+ /* WRONG - WRONG - WRONG - namespace delcarations are not passed
+ as attributes.
final Node attr = _stylesheetAttributes.getNamedItem("xmlns:" + prefix);
return attr != null ? attr.getNodeValue() : null;
+ */
+ return getParser().getSymbolTable().lookupNamespace(prefix);
}
public String getClassName() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]