mmidy       99/12/14 15:42:47

  Modified:    src/org/apache/xalan/xslt Constants.java
                        ElemDecimalFormat.java FuncFormatNumb.java
                        Stylesheet.java UnImplNode.java
               src/org/apache/xalan/xslt/res XSLTErrorResources.java
                        XSLTErrorResources_en.java
  Log:
  Create a default decimal-format element and make sure redefinitions are 
applied in format pattern
  
  Revision  Changes    Path
  1.9       +2 -0      xml-xalan/src/org/apache/xalan/xslt/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Constants.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Constants.java    1999/12/01 22:16:17     1.8
  +++ Constants.java    1999/12/14 23:42:44     1.9
  @@ -72,6 +72,7 @@
     // public static final String LIAISON_CLASS = 
"org.apache.xalan.xpath.xdom.XercesLiaison";
     public static final String LIAISON_CLASS = 
"org.apache.xalan.xpath.dtm.DTMLiaison";
     
  +  
     /**
     * IDs for XSL element types. These are associated 
     * with the string literals in the XSLTEngineImpl class.
  @@ -442,6 +443,7 @@
     // some stuff for Decimal-format
     public static final String ATTRVAL_INFINITY = "Infinity";
     public static final String ATTRVAL_NAN = "NaN";
  +  public static final String DEFAULT_DECIMAL_FORMAT = "#default";
   
     // temp dummy 
     public static final String ATTRNAME_XXXX = "XXXX";
  
  
  
  1.3       +14 -0     
xml-xalan/src/org/apache/xalan/xslt/ElemDecimalFormat.java
  
  Index: ElemDecimalFormat.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemDecimalFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemDecimalFormat.java    1999/11/15 22:42:27     1.2
  +++ ElemDecimalFormat.java    1999/12/14 23:42:44     1.3
  @@ -157,6 +157,20 @@
         m_infinity_avt = Constants.ATTRVAL_INFINITY;
       if (null == m_NaN_avt)
         m_NaN_avt = Constants.ATTRVAL_NAN;
  +    
  +    // Look for the default decimal-format element  
  +    if (null == m_name_avt)
  +    { 
  +      if (null != 
m_stylesheet.getDecimalFormatElem(Constants.DEFAULT_DECIMAL_FORMAT))      
  +        processor.warn(XSLTErrorResources.WARNING0019); //Only one default 
Decimal format is allowed
  +      m_name_avt = Constants.DEFAULT_DECIMAL_FORMAT;  
  +    }
  +    // Look for duplicate decimal-format names
  +    else
  +    {  
  +      if (null != m_stylesheet.getDecimalFormatElem(m_name_avt))       
  +        processor.warn(XSLTErrorResources.WARNING0020); // All declarations 
have to be unique      
  +    }  
     }
     
    /*
  
  
  
  1.6       +29 -20    xml-xalan/src/org/apache/xalan/xslt/FuncFormatNumb.java
  
  Index: FuncFormatNumb.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/FuncFormatNumb.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FuncFormatNumb.java       1999/12/13 08:13:47     1.5
  +++ FuncFormatNumb.java       1999/12/14 23:42:44     1.6
  @@ -84,7 +84,7 @@
       ElemTemplateElement templElem = 
(ElemTemplateElement)execContext.getNamespaceContext();
       Stylesheet ss = templElem.m_stylesheet;
       
  -    java.text.DecimalFormat formatter;
  +    java.text.DecimalFormat formatter = null;
       java.text.DecimalFormatSymbols dfs = null;
       double num = ((XObject)args.elementAt(0)).num();
       String patternStr = ((XObject)args.elementAt(1)).str();
  @@ -98,34 +98,43 @@
       {
         if(nArgs == 3)
         {
  -        String formatStr = ((XObject)args.elementAt(2)).str();
  -        //  Document baseDoc = (Node.DOCUMENT_NODE == context.getNodeType()) 
? 
  -        //                       (Document)context : 
context.getOwnerDocument();
  -        
  -        //  if(baseDoc instanceof Stylesheet)
  -        //  {          
  -        dfs = ss.getDecimalFormatElem(formatStr);
  -        //}
  +        String formatStr = ((XObject)args.elementAt(2)).str();          
  +        dfs = ss.getDecimalFormatElem(formatStr);        
           if (null == dfs)
           {    
  -          // Have to figure out a way to do XPath errors from here.
             
path.warn(org.apache.xalan.xpath.res.XPATHErrorResources.WARNING0012, 
                       new Object[]{formatStr}); //"not found!!!  
  -          formatter = new java.text.DecimalFormat(patternStr);
  +          //formatter = new java.text.DecimalFormat(patternStr);
           }    
  -        else   
  -          formatter = new java.text.DecimalFormat(patternStr, dfs);
  -        // path.warn(XPATHErrorResources.WARNING0001); //"locale name in the 
format-number function not yet handled!");
  +        else
  +        {  
  +          //formatter = new java.text.DecimalFormat(patternStr, dfs);
  +          formatter = new java.text.DecimalFormat();
  +          formatter.setDecimalFormatSymbols(dfs);
  +          formatter.applyLocalizedPattern(patternStr);
  +        }  
  +        
  +      }
  +      //else
  +      if (null == formatter)
  +      {
  +        // Try for default decimal-format
  +        dfs = ss.getDecimalFormatElem(Constants.DEFAULT_DECIMAL_FORMAT);     
   
  +        if (null == dfs)             
  +          formatter = new java.text.DecimalFormat(patternStr);
  +        else
  +          //formatter = new java.text.DecimalFormat(patternStr, dfs);
  +          formatter = new java.text.DecimalFormat();
  +          formatter.setDecimalFormatSymbols(dfs);
  +          formatter.applyLocalizedPattern(patternStr);
         }
  -      else
  -        formatter = new java.text.DecimalFormat(patternStr);
  -
         return new XString(formatter.format(num));
       }
  -    catch(IllegalArgumentException iae)
  +    catch(Exception iae)
       {
  -      // Myriam: you should call the problem listener here...
  -      throw new XSLProcessorException(iae);
  +      ss.error(XSLTErrorResources.ERROR0099, new Object[]{patternStr});
  +      return new XString("");   
  +      //throw new XSLProcessorException(iae);
       }
     }
   }
  
  
  
  1.15      +6 -6      xml-xalan/src/org/apache/xalan/xslt/Stylesheet.java
  
  Index: Stylesheet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Stylesheet.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Stylesheet.java   1999/12/14 00:21:55     1.14
  +++ Stylesheet.java   1999/12/14 23:42:44     1.15
  @@ -618,13 +618,13 @@
      * Table of tables of element decimal-format.
      * @see ElemDecimalFormat.
      */
  -  Vector m_DecimalFormatDeclarations = new Vector();
  +  Stack m_DecimalFormatDeclarations = new Stack();
     
     /**
      * Get table of tables of element decimal-format.
      * @see ElemDecimalFormat.
      */
  -  public Vector getDecimalFormatDeclarations()
  +  public Stack getDecimalFormatDeclarations()
     {
       return m_DecimalFormatDeclarations;
     }
  @@ -633,7 +633,7 @@
      * Set table of tables of element decimal-format.
      * @see ElemDecimalFormat.
      */
  -  public void setDecimalFormatDeclarations(Vector v)
  +  public void setDecimalFormatDeclarations(Stack v)
     {
       m_DecimalFormatDeclarations = v;
     }
  @@ -738,7 +738,7 @@
      */
     void processDecimalFormatElement(ElemTemplateElement edf, AttributeList 
atts)    
     {
  -    m_DecimalFormatDeclarations.addElement(edf);    
  +    m_DecimalFormatDeclarations.push(edf);    
     }
     
     /**
  @@ -1693,8 +1693,8 @@
       DecimalFormatSymbols dfs = null;
       if(null != m_DecimalFormatDeclarations)
       {
  -      boolean foundDoc = false;
  -      for (int i=0;i<m_DecimalFormatDeclarations.size(); i++)
  +      // Start from the top of the stack
  +      for (int i=m_DecimalFormatDeclarations.size()-1; i>=0; i--)
         {
           ElemDecimalFormat edf = 
(ElemDecimalFormat)m_DecimalFormatDeclarations.elementAt(i);
           if (edf.getName().equals(name))
  
  
  
  1.3       +1 -1      xml-xalan/src/org/apache/xalan/xslt/UnImplNode.java
  
  Index: UnImplNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/UnImplNode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnImplNode.java   1999/11/15 15:57:40     1.2
  +++ UnImplNode.java   1999/12/14 23:42:44     1.3
  @@ -83,7 +83,7 @@
      */
     void error(int msg, Object[]args)
     {
  -       throw new RuntimeException(XSLMessages.createMessage(msg, null)); 
//"UnImplNode error: "+msg);
  +       throw new RuntimeException(XSLMessages.createMessage(msg, args)); 
//"UnImplNode error: "+msg);
     }
     
     /** Unimplemented. */
  
  
  
  1.7       +10 -3     
xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources.java
  
  Index: XSLTErrorResources.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSLTErrorResources.java   1999/12/02 20:11:41     1.6
  +++ XSLTErrorResources.java   1999/12/14 23:42:46     1.7
  @@ -208,8 +208,9 @@
   ERROR0095 = 95,
   ERROR0096 = 96,
   ERROR0097 = 97,
  -ERROR0098 = 98,  
  -MAX_CODE = 98;                 // this is needed to keep track of the number 
of messages          
  +ERROR0098 = 98,
  +ERROR0099 = 99,
  +MAX_CODE = 99;                 // this is needed to keep track of the number 
of messages          
   
   public static final int
   WARNING0000 = 0,
  @@ -231,7 +232,9 @@
   WARNING0016 = 16,
   WARNING0017 = 17,
   WARNING0018 = 18,
  -MAX_WARNING = 18;             // this is needed to keep track of the number 
of warnings
  +WARNING0019 = 19,
  +WARNING0020 = 20,
  +MAX_WARNING = 20;             // this is needed to keep track of the number 
of warnings
   
   
   
  @@ -340,7 +343,9 @@
   {"ER0096", "Missing namespace URI for specified prefix"},
   {"ER0097", "Missing argument for option: {0}"},
   {"ER0098", "Invalid option: {0}"},
  +{"ER0099", "Malformed format string: {0}"},
   
  +
   {"WR0001", "Found '}' but no attribute template open!"},
   {"WR0002", "Warning: count attribute does not match an ancestor in 
xsl:number! Target = {0}"},
   {"WR0003", "Old syntax: The name of the 'expr' attribute has been changed to 
'select'."},
  @@ -359,6 +364,8 @@
   {"WR0016", "XSLT4J does not yet handle the {0} attribute!"},
   {"WR0017", "No declaration found for decimal format: {0}"},
   {"WR0018", "Old XSLT Namespace: {0}"},
  +{"WR0019", "Only one default xsl:decimal-format declaration is allowed. The 
last one will be used."},
  +{"WR0020", "xsl:decimal-format names must be unique. The last one will be 
used."},
   
   
   {"BAD_CODE", "Parameter to createMessage was out of bounds"},
  
  
  
  1.5       +3 -0      
xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources_en.java
  
  Index: XSLTErrorResources_en.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources_en.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XSLTErrorResources_en.java        1999/12/02 20:11:41     1.4
  +++ XSLTErrorResources_en.java        1999/12/14 23:42:46     1.5
  @@ -115,6 +115,7 @@
   {"ER0096", "Missing namespace URI for specified prefix"},
   {"ER0097", "Missing argument for option: {0}"},
   {"ER0098", "Invalid option: {0}"},
  +{"ER0099", "Malformed format string: {0}"},
   
   
   {"WR0001", "Found '}' but no attribute template open!"},
  @@ -135,6 +136,8 @@
   {"WR0016", "XSLT4J does not yet handle the {0} attribute!"},
   {"WR0017", "No declaration found for decimal format: {0}"},
   {"WR0018", "Old XSLT Namespace: {0}"},
  +{"WR0019", "Only one default xsl:decimal-format declaration is allowed. The 
last one will be used."},
  +{"WR0020", "xsl:decimal-format names must be unique. The last one will be 
used."},
   
   {"BAD_CODE", "Parameter to createMessage was out of bounds"},
   {"FORMAT_FAILED", "Exception thrown during messageFormat call"},
  
  
  

Reply via email to