morten      01/10/08 03:41:39

  Modified:    java/src/org/apache/xalan/xsltc/compiler Sort.java
  Log:
  Fix for a bug that was caused by the way we set the default data-type for
  sort elements. The default data-type was always set to "text", and the natural
  data-type of the set to sort was not taken into consideration. In this case
  the sort data was generated by the position() function (ie. the data-type was
  "number"), but XSLTC still sorted the data as if it was text
  PR:           bugzilla 1410
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.7       +18 -5     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java
  
  Index: Sort.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Sort.java 2001/08/27 09:07:19     1.6
  +++ Sort.java 2001/10/08 10:41:39     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Sort.java,v 1.6 2001/08/27 09:07:19 morten Exp $
  + * @(#)$Id: Sort.java,v 1.7 2001/10/08 10:41:39 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -89,6 +89,7 @@
       private AttributeValue _caseOrder;
       private AttributeValue _dataType;
   
  +    private String         _data = null;
       public  String         _lang;
       public  String         _country;
   
  @@ -113,9 +114,7 @@
            .create(this, val.length() > 0 ? val : "upper-first", parser);
   
        // Get the sort data type; default is text
  -     val = getAttribute("data-type");
  -     _dataType = AttributeValue
  -         .create(this, val.length() > 0 ? val : "text", parser);
  +     _data = getAttribute("data-type");
   
        // Get the language whose sort rules we will use; default is env.dep.
        if ((val = getAttribute("lang")) != null) {
  @@ -135,9 +134,23 @@
        */
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
        final Type tselect = _select.typeCheck(stable);
  -     if (tselect instanceof StringType == false) {
  +
  +     // If the sort data-type is not set we use the natural data-type
  +     // of the data we will sort
  +     if (tselect instanceof IntType) {
  +         _select = new CastExpr(_select, Type.String);
  +         if ((_data == null) || (_data.length() == 0)) _data = "number";
  +     }
  +     else if (tselect instanceof StringType) {
  +         if ((_data == null) || (_data.length() == 0)) _data = "text";
  +     }
  +     else {
            _select = new CastExpr(_select, Type.String);
  +         if ((_data == null) || (_data.length() == 0)) _data = "text";
        }
  +
  +     _dataType = AttributeValue.create(this, _data, getParser());
  +
        _order.typeCheck(stable);
        _caseOrder.typeCheck(stable);
        _dataType.typeCheck(stable);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to