You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/08/01 20:25:28 UTC

cvs commit: xml-xalan/src/org/apache/xalan/xpath FuncGenerateId.java

sboag       00/08/01 11:25:28

  Modified:    src/org/apache/xalan/xpath FuncGenerateId.java
  Log:
  Fix generate-id() so so it uses hex string to solve problem with negative values (attribution to "Sergei S. Ivanov" <iv...@aha.ru>).
  
  Revision  Changes    Path
  1.6       +9 -2      xml-xalan/src/org/apache/xalan/xpath/FuncGenerateId.java
  
  Index: FuncGenerateId.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/FuncGenerateId.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FuncGenerateId.java	2000/03/06 20:13:26	1.5
  +++ FuncGenerateId.java	2000/08/01 18:25:27	1.6
  @@ -88,17 +88,24 @@
           context = null;
         }
       }
  +    // attribution to "Sergei S. Ivanov" -- 
  +    // XSLT spec says: "The unique identifier [produced by generate-id()] must
  +    // consist of ASCII alphanumeric characters and must start with an alphabetic
  +    // character."
  +    // Xalan sometimes generates ids like N-1234, because the implementation uses
  +    // hash code, which is not always non-negative. The fix is to use 
  +    // toHexString instead of toString.
       try
       {
         org.apache.xalan.xpath.dtm.DTMProxy dtmp = (org.apache.xalan.xpath.dtm.DTMProxy)context;
         
         return new XString((null == context) 
  -                         ? "" : "N"+Integer.toString(dtmp.getDTMNodeNumber()));
  +                         ? "" : "N"+Integer.toHexString(dtmp.getDTMNodeNumber()));
       }
       catch(ClassCastException cce)
       {
         return new XString((null == context) 
  -                         ? "" : "N"+Integer.toString(context.hashCode()));
  +                         ? "" : "N"+Integer.toHexString(context.hashCode()));
       }
     }
   }