You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/11/05 14:10:19 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/datatype DateTimeDatatypeValidator.java DateTimeValidator.java TimeDatatypeValidator.java

elena       01/11/05 05:10:19

  Modified:    java/src/org/apache/xerces/dom Tag: xerces_j_1
                        AttrNSImpl.java AttributeMap.java
                        CoreDOMImplementationImpl.java
                        CoreDocumentImpl.java DOMImplementationImpl.java
                        ElementNSImpl.java
               java/src/org/apache/xerces/readers Tag: xerces_j_1
                        DefaultEntityHandler.java
               java/src/org/apache/xerces/validators/datatype Tag:
                        xerces_j_1 DateTimeDatatypeValidator.java
                        DateTimeValidator.java TimeDatatypeValidator.java
  Log:
  - DOM L2 conformance bug fixes
  - Applied patch from Henry Zongaro (date/time bug fixes)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.21.2.1  +5 -2      xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java
  
  Index: AttrNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java,v
  retrieving revision 1.21
  retrieving revision 1.21.2.1
  diff -u -r1.21 -r1.21.2.1
  --- AttrNSImpl.java	2001/08/10 01:18:16	1.21
  +++ AttrNSImpl.java	2001/11/05 13:10:18	1.21.2.1
  @@ -1,4 +1,4 @@
  -/* $Id: AttrNSImpl.java,v 1.21 2001/08/10 01:18:16 lehors Exp $ */
  +/* $Id: AttrNSImpl.java,v 1.21.2.1 2001/11/05 13:10:18 elena Exp $ */
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -224,7 +224,7 @@
                   throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 
       	                               "DOM002 Illegal character");
               }
  -            if (namespaceURI == null) {
  +            if (namespaceURI == null || prefix.indexOf(':') >=0) {
                   throw new DOMException(DOMException.NAMESPACE_ERR, 
   				       "DOM003 Namespace error");
               } else if (prefix != null) {
  @@ -238,6 +238,9 @@
                           throw new DOMException(DOMException.NAMESPACE_ERR, 
                                                  "DOM003 Namespace error");
                       }
  +                } else if (name.equals("xmlns")) {
  +                        throw new DOMException(DOMException.NAMESPACE_ERR,
  +                                    "DOM003 Namespace error");
                   }
               }
           }
  
  
  
  1.14.2.1  +7 -0      xml-xerces/java/src/org/apache/xerces/dom/AttributeMap.java
  
  Index: AttributeMap.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttributeMap.java,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- AttributeMap.java	2001/08/10 01:18:16	1.14
  +++ AttributeMap.java	2001/11/05 13:10:18	1.14.2.1
  @@ -385,6 +385,13 @@
                       if (j>=0 && findNamePoint(nodeName, j+1) < 0) {
                           NodeImpl clone = (NodeImpl)d.cloneNode(true);
                           clone.ownerNode = ownerNode;
  +                         // we must rely on the name to find a default attribute
  +                        // ("test:attr"), but while copying it from the DOCTYPE
  +                        // we should not loose namespace URI that was assigned
  +                        // to the attribute in the instance document.
  +                        if (clone instanceof AttrNSImpl) {
  +                            ((AttrNSImpl)clone).namespaceURI = namespaceURI;
  +                        }
                           clone.isOwned(true);
                           clone.isSpecified(false);
                           nodes.setElementAt(clone, i);
  
  
  
  1.1.4.1   +3 -1      xml-xerces/java/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java
  
  Index: CoreDOMImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- CoreDOMImplementationImpl.java	2001/08/10 01:18:16	1.1
  +++ CoreDOMImplementationImpl.java	2001/11/05 13:10:18	1.1.4.1
  @@ -156,7 +156,9 @@
       		                           "DOM002 Illegal character");
           }
           int index = qualifiedName.indexOf(':');
  -        if (index == 0 || index == qualifiedName.length() - 1) {
  +        int lastIndex = qualifiedName.lastIndexOf(':');
  +        // it is an error for NCName to have more than one ':'
  +        if (index == 0 || index == qualifiedName.length() - 1  || lastIndex!=index) {
   	    throw new DOMException(DOMException.NAMESPACE_ERR, 
   				       "DOM003 Namespace error");
   	}
  
  
  
  1.1.4.2   +1 -35     xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java
  
  Index: CoreDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java,v
  retrieving revision 1.1.4.1
  retrieving revision 1.1.4.2
  diff -u -r1.1.4.1 -r1.1.4.2
  --- CoreDocumentImpl.java	2001/10/30 14:26:51	1.1.4.1
  +++ CoreDocumentImpl.java	2001/11/05 13:10:18	1.1.4.2
  @@ -1028,40 +1028,6 @@
   		break;
               }
   
  -            // REVISIT: The DOM specifications say that DocumentType nodes
  -            // cannot be imported. Is this OK?
  -    	    case DOCUMENT_TYPE_NODE: {
  -		DocumentType srcdoctype = (DocumentType)source;
  -		DocumentTypeImpl newdoctype = (DocumentTypeImpl)
  -		    createDocumentType(srcdoctype.getNodeName(),
  -				       srcdoctype.getPublicId(),
  -				       srcdoctype.getSystemId());
  -		// Values are on NamedNodeMaps
  -		NamedNodeMap smap = srcdoctype.getEntities();
  -		NamedNodeMap tmap = newdoctype.getEntities();
  -		if(smap != null) {
  -		    for(int i = 0; i < smap.getLength(); i++) {
  -			tmap.setNamedItem(importNode(smap.item(i), true,
  -                                                     reversedIdentifiers));
  -                    }
  -                }
  -		smap = srcdoctype.getNotations();
  -		tmap = newdoctype.getNotations();
  -		if (smap != null) {
  -		    for(int i = 0; i < smap.getLength(); i++) {
  -			tmap.setNamedItem(importNode(smap.item(i), true,
  -                                                     reversedIdentifiers));
  -                    }
  -                }
  -		// NOTE: At this time, the DOM definition of DocumentType
  -		// doesn't cover Elements and their Attributes. domimpl's
  -		// extentions in that area will not be preserved, even if
  -		// copying from domimpl to domimpl. We could special-case
  -		// that here. Arguably we should. Consider. ?????
  -		newnode = newdoctype;
  -		break;
  -            }
  -
       	    case DOCUMENT_FRAGMENT_NODE: {
   		newnode = createDocumentFragment();
   		// No name, kids carry value
  @@ -1079,7 +1045,7 @@
   		// No name, no value
   		break;
               }
  -
  +            case DOCUMENT_TYPE_NODE: 
               case DOCUMENT_NODE : // Can't import document nodes
               default: {           // Unknown node type
                   throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
  
  
  
  1.15.2.1  +3 -1      xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java
  
  Index: DOMImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- DOMImplementationImpl.java	2001/08/10 01:18:16	1.15
  +++ DOMImplementationImpl.java	2001/11/05 13:10:18	1.15.2.1
  @@ -160,7 +160,9 @@
       		                           "DOM002 Illegal character");
           }
           int index = qualifiedName.indexOf(':');
  -        if (index == 0 || index == qualifiedName.length() - 1) {
  +        int lastIndex = qualifiedName.lastIndexOf(':');
  +        // it is an error for NCName to have more than one ':'
  +        if (index == 0 || index == qualifiedName.length() - 1  || lastIndex!=index) {
   	    throw new DOMException(DOMException.NAMESPACE_ERR, 
   				       "DOM003 Namespace error");
   	}
  
  
  
  1.16.2.1  +2 -2      xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java
  
  Index: ElementNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- ElementNSImpl.java	2001/08/10 01:18:16	1.16
  +++ ElementNSImpl.java	2001/11/05 13:10:18	1.16.2.1
  @@ -1,4 +1,4 @@
  -/* $Id: ElementNSImpl.java,v 1.16 2001/08/10 01:18:16 lehors Exp $ */
  +/* $Id: ElementNSImpl.java,v 1.16.2.1 2001/11/05 13:10:18 elena Exp $ */
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -214,7 +214,7 @@
                   throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 
       	                               "DOM002 Illegal character");
               }
  -            if (namespaceURI == null) {
  +            if (namespaceURI == null || prefix.indexOf(':') >=0) {
                     throw new DOMException(DOMException.NAMESPACE_ERR, 
                                            "DOM003 Namespace error");
               } else if (prefix != null) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.1   +4 -2      xml-xerces/java/src/org/apache/xerces/readers/Attic/DefaultEntityHandler.java
  
  Index: DefaultEntityHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/readers/Attic/DefaultEntityHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- DefaultEntityHandler.java	2001/07/20 17:26:26	1.8
  +++ DefaultEntityHandler.java	2001/11/05 13:10:19	1.8.2.1
  @@ -79,7 +79,7 @@
   /**
    * Default entity handler implementation.
    *
  - * @version $Id: DefaultEntityHandler.java,v 1.8 2001/07/20 17:26:26 lmartin Exp $
  + * @version $Id: DefaultEntityHandler.java,v 1.8.2.1 2001/11/05 13:10:19 elena Exp $
    */
   public class DefaultEntityHandler 
       implements XMLEntityHandler, XMLEntityHandler.DTDHandler {
  @@ -391,7 +391,9 @@
   
           // check for bad parameters id
           if (id == null || id.length() == 0) {
  -            return systemId;
  +            // REVISIT: returning null here will result in NPE
  +            // for notations and entity declarations
  +            return "";
           }
   
           // if id already expanded, return
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.1   +3 -3      xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DateTimeDatatypeValidator.java
  
  Index: DateTimeDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DateTimeDatatypeValidator.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- DateTimeDatatypeValidator.java	2001/06/21 20:56:01	1.5
  +++ DateTimeDatatypeValidator.java	2001/11/05 13:10:19	1.5.2.1
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,7 +64,7 @@
    * Validator for <dateTime> datatype (W3C Schema Datatypes)
    * 
    * @author Elena Litani
  - * @version $Id: DateTimeDatatypeValidator.java,v 1.5 2001/06/21 20:56:01 elena Exp $
  + * @version $Id: DateTimeDatatypeValidator.java,v 1.5.2.1 2001/11/05 13:10:19 elena Exp $
    */
   public class DateTimeDatatypeValidator extends DateTimeValidator {
   
  @@ -107,7 +107,7 @@
           validateDateTime(date);
   
   
  -        if ( date[utc]!=0 && date[utc]!='Z') {
  +        if ( (date[utc]!=0  && date[utc]!='Z') || date[h] == 24 ) {
               normalize(date);
           }
           return date;
  
  
  
  1.14.2.2  +27 -22    xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DateTimeValidator.java
  
  Index: DateTimeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/DateTimeValidator.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- DateTimeValidator.java	2001/10/02 18:11:42	1.14.2.1
  +++ DateTimeValidator.java	2001/11/05 13:10:19	1.14.2.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -60,6 +60,7 @@
   import java.util.Vector;
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.lang.Math;
   import org.apache.xerces.utils.regex.RegularExpression;
   import org.apache.xerces.validators.schema.SchemaSymbols;
   
  @@ -72,7 +73,7 @@
    * @author Elena Litani
    * @author Len Berman  
    *
  - * @version $Id: DateTimeValidator.java,v 1.14.2.1 2001/10/02 18:11:42 elena Exp $
  + * @version $Id: DateTimeValidator.java,v 1.14.2.2 2001/11/05 13:10:19 elena Exp $
    */
   
   public abstract class DateTimeValidator extends AbstractNumericFacetValidator {
  @@ -553,13 +554,6 @@
           }
           int i = indexOf(start, end, '-');
           if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced");
  -        int length = i-start;
  -        if (length<4) {
  -            throw new RuntimeException("Year must have 'CCYY' format");
  -        }
  -        else if (length > 4 && fBuffer.charAt(start)=='0'){
  -            throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
  -        }
           date[CY]= parseIntYear(i);
           if (fBuffer.charAt(i)!='-') {
               throw new RuntimeException("CCYY must be followed by '-' sign");
  @@ -684,28 +678,30 @@
           }
   
           //validate hours
  -        if ( data[h]>23 || data[h]<0 ) {
  -            throw new RuntimeException("Hour must have values 0-23");
  +        if ( data[h]>24 || data[h]<0 ||
  +             (data[h] == 24 && (data[m]!=0 || data[s]!=0 || data[ms]!=0)) ) {
  +            throw new RuntimeException("Hour must have values 0-24.  If hour is 24, minutes and seconds must both have the value 0.");
           }
   
  -        //validate
  +        //validate minutes
           if ( data[m]>59 || data[m]<0 ) {
               throw new RuntimeException("Minute must have values 0-59");
           }
   
  -        //validate
  +        //validate seconds
           if ( data[s]>60 || data[s]<0 ) {
               throw new RuntimeException("Second must have values 0-60");
   
           }
   
  -        //validate
  -        if ( timeZone[hh]>14 || timeZone[hh]<-14 ) {
  +        //validate time-zone hours
  +        if ( Math.abs(timeZone[hh])>14 ||
  +             (Math.abs(timeZone[hh]) == 14 && timeZone[mm] != 0) ) {
               throw new RuntimeException("Time zone should have range -14..+14");
           }
   
  -        //validate
  -        if ( timeZone[mm]>59 || timeZone[mm]<-59 ) {
  +        //validate time-zone minutes
  +        if ( Math.abs(timeZone[mm]) > 59 ) {
               throw new RuntimeException("Minute must have values 0-59");
           }
       }
  @@ -774,11 +770,17 @@
               negative = true;
               limit = Integer.MIN_VALUE;
               i++;
  -         
           } 
           else{
               limit = -Integer.MAX_VALUE;
           }
  +
  +        int length = end-i;
  +        if (length<4 ||
  +            (length > 4 && fBuffer.charAt(i)=='0')) {
  +            throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden.");
  +        }
  +
           multmin = limit / radix;
           while (i < end)
           {
  @@ -802,7 +804,9 @@
       }
   
       /**
  -     * If timezone present - normalize dateTime  [E Adding durations to dateTimes]
  +     * normalize dateTime  [E Adding durations to dateTimes]
  +     * If timezone present - normalize to UTC
  +     * If hour is 24 - normalize to start of following day
        * 
        * @param date   CCYY-MM-DDThh:mm:ss+03
        * @return CCYY-MM-DDThh:mm:ssZ
  @@ -856,8 +860,11 @@
               temp=date[M]+carry;
               date[M]=modulo(temp, 1, 13);
               date[CY]=date[CY]+fQuotient(temp, 1, 13);
  +        }
  +
  +        if (date[utc] != 0) {
  +            date[utc]='Z';
           }
  -        date[utc]='Z';  
       }
   
   
  @@ -917,8 +924,6 @@
   
   
       private boolean isLeapYear(int year) {
  -
  -        //REVISIT: should we take care about Julian calendar? 
           return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0))); 
       }
   
  
  
  
  1.5.2.1   +4 -4      xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/TimeDatatypeValidator.java
  
  Index: TimeDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/Attic/TimeDatatypeValidator.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- TimeDatatypeValidator.java	2001/06/21 20:56:10	1.5
  +++ TimeDatatypeValidator.java	2001/11/05 13:10:19	1.5.2.1
  @@ -3,7 +3,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,7 +64,7 @@
    * Validator for <time> datatype (W3C Schema Datatypes)
    * 
    * @author Elena Litani
  - * @version $Id: TimeDatatypeValidator.java,v 1.5 2001/06/21 20:56:10 elena Exp $
  + * @version $Id: TimeDatatypeValidator.java,v 1.5.2.1 2001/11/05 13:10:19 elena Exp $
    */
   public class TimeDatatypeValidator extends DateTimeValidator {
   
  @@ -110,10 +110,10 @@
           //REVISIT: do we need SchemaDateTimeException?
           validateDateTime(date);
           
  -        if ( date[utc]!=0 ) {
  +        if ( date[utc]!=0 || date[h] == 24 ) {
               normalize(date);
           }
  -                return date;
  +        return date;
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org