xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema TraverseSchema.java
Date Wed, 14 Feb 2001 21:28:37 GMT
elena       01/02/14 13:28:36

  Modified:    java/src/org/apache/xerces/validators/common
                        XMLValidator.java
               java/src/org/apache/xerces/validators/datatype
                        AbstractDatatypeValidator.java
                        DatatypeValidator.java
                        DatatypeValidatorFactoryImpl.java
                        StringDatatypeValidator.java
               java/src/org/apache/xerces/validators/schema
                        TraverseSchema.java
  Log:
  Added whiteSpace facet support + normalization changes
  to reflect this change.
  It is still protected under flag..
  
  Revision  Changes    Path
  1.115     +91 -69    xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
  
  Index: XMLValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- XMLValidator.java	2001/02/09 21:47:10	1.114
  +++ XMLValidator.java	2001/02/14 21:28:26	1.115
  @@ -121,7 +121,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.114 2001/02/09 21:47:10 neilg Exp $
  + * @version $Id: XMLValidator.java,v 1.115 2001/02/14 21:28:26 elena Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -348,11 +348,12 @@
      //Schema Normalization
       private boolean NORMALIZATION_ON = false;
       private boolean DEBUG_NORMALIZATION = false;
  +    private DatatypeValidator fCurrentDV = null; //current datatype validator
       private boolean fFirstChunk = true; // got first chunk in characters() (SAX)
       private boolean fTrailing = false;  // Previous chunk had a trailing space
  -    private boolean fCollapse = false;  //collapse spaces
  -    private StringBuffer fStringBuffer = null;  //holds normalized str value
  -    private StringBuffer fTempBuffer = null;  //holds unnormalized str value
  +    private short fWhiteSpace = DatatypeValidator.COLLAPSE;  //whiteSpace: preserve/replace/collapse
  +    private StringBuffer fStringBuffer = new StringBuffer(CHUNK_SIZE);  //holds normalized
str value
  +    private StringBuffer fTempBuffer = new StringBuffer(CHUNK_SIZE);  //holds unnormalized
str value
       
   
   
  @@ -718,9 +719,6 @@
      
       private int normalizeWhitespace( StringBuffer chars, boolean collapse) {
           int length = fTempBuffer.length(); 
  -        if (fStringBuffer == null) {
  -            fStringBuffer = new StringBuffer((CHUNK_SIZE>=length)?CHUNK_SIZE:length);
  -        }
           fStringBuffer.setLength(0);
           boolean skipSpace = collapse;
           boolean sawNonWS = false;
  @@ -771,9 +769,9 @@
          if (fFirstChunk) {
               fGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
               //REVISIT: add normalization according to datatypes 
  -            DatatypeValidator dv = fTempElementDecl.datatypeValidator;
  -            if (dv !=null) { 
  -                fCollapse = true;
  +            fCurrentDV = fTempElementDecl.datatypeValidator;
  +            if (fCurrentDV !=null) { 
  +                fWhiteSpace = fCurrentDV.getWSFacet();
               }
               fFirstChunk = false;
               if (DEBUG_NORMALIZATION) {
  @@ -789,35 +787,37 @@
              }
           if (fBufferDatatype) {
               if (DEBUG_NORMALIZATION) {
  -                System.out.println("Start schema datatype normalization");
  +                System.out.println("Start schema datatype normalization <whiteSpace
value=" +fWhiteSpace+">");
               }
  -            if (fTempBuffer == null) {
  -                fTempBuffer = new StringBuffer((CHUNK_SIZE>=length)?CHUNK_SIZE:length);
  +            if (fWhiteSpace == DatatypeValidator.PRESERVE) { //do not normalize
  +               fDatatypeBuffer.append(chars, offset, length);
               }
  -            fTempBuffer.setLength(0);
  -            fTempBuffer.append(chars, offset, length);
  -            int spaces = normalizeWhitespace(fTempBuffer, fCollapse);
  -            int nLength = fStringBuffer.length();
  -            if (nLength > 0) {
  -                if (spaces != 0 && fCollapse) { //some normalization was done
  -                    if (!fFirstChunk && fTrailing && spaces !=2) {
  -                        fStringBuffer.insert(0, ' ');
  -                        nLength++;
  +            else {
  +                fTempBuffer.setLength(0);
  +                fTempBuffer.append(chars, offset, length);
  +                int spaces = normalizeWhitespace(fTempBuffer, (fWhiteSpace==DatatypeValidator.COLLAPSE));
  +                int nLength = fStringBuffer.length();
  +                if (nLength > 0) {
  +                    if (spaces != 0 && 
  +                        fWhiteSpace == DatatypeValidator.COLLAPSE) { 
  +                        //some normalization was done
  +                        if (!fFirstChunk && fTrailing && spaces !=2) {
  +                            fStringBuffer.insert(0, ' ');
  +                            nLength++;
  +                        }
  +                        //REVISIT: try to avoid..
  +                        char[] newChars = new char[nLength]; 
  +                        fStringBuffer.getChars(0, nLength , newChars, 0);
  +                        chars = newChars;
  +                        offset = 0;
  +                        length = nLength;
                       }
  -                    //REVISIT: try to avoid..
  -                    char[] newChars = new char[nLength]; 
  -                    fStringBuffer.getChars(0, nLength , newChars, 0);
  -                    chars = newChars;
  -                    offset = 0;
  -                    length = nLength;
  +                    fDatatypeBuffer.append(chars, offset, length);
  +                    fDocumentHandler.characters(chars, offset, length);
                   }
  -                fDatatypeBuffer.append(chars, offset, length);
  -                fDocumentHandler.characters(chars, offset, length);
  +                fTrailing = (spaces > 1)?true:false;
  +                return;
               }
  -            fTrailing = (spaces > 1)?true:false;
  -
  -           //REVISIT: do we need to call characters if there is nothing to pass? 
  -            return;
           }
         }      
         fDocumentHandler.characters(chars, offset, length);
  @@ -849,21 +849,31 @@
            if (fBufferDatatype) {
   
                if (NORMALIZATION_ON) {
  -                 fCollapse = true; //REVISIT: must be updated according to datatypes
  -                 String str =  fStringPool.toString(data);
  -                 int length = str.length();
  -                 if (fTempBuffer == null) {
  -                     fTempBuffer = new StringBuffer((CHUNK_SIZE>=length)?CHUNK_SIZE:length);
  -                 }
  -                 fTempBuffer.setLength(0);
  -                 fTempBuffer.append(str);
  -                 int spaces = normalizeWhitespace(fTempBuffer, fCollapse);
  -                 if (spaces >0) {
  +                fGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
  +                //REVISIT: add normalization according to datatypes 
  +                fCurrentDV = fTempElementDecl.datatypeValidator;
  +                if (fCurrentDV !=null) { 
  +                    fWhiteSpace = fCurrentDV.getWSFacet();
  +                }
  +                if (fWhiteSpace == DatatypeValidator.PRESERVE) {  //no normalization done
  +                    fDatatypeBuffer.append(fStringPool.toString(data));
  +                }
  +                else {
  +                    String str =  fStringPool.toString(data);
  +                    int length = str.length();
  +                    if (fTempBuffer == null) {
  +                        fTempBuffer = new StringBuffer((CHUNK_SIZE>=length)?CHUNK_SIZE:length);
  +                    }
  +                    fTempBuffer.setLength(0);
  +                    fTempBuffer.append(str);
  +                    int spaces = normalizeWhitespace(fTempBuffer, (fWhiteSpace == DatatypeValidator.COLLAPSE));
  +                    if (spaces >0) {
                        //normalization was done.
  -                     fStringPool.releaseString(data);
  -                     data = fStringPool.addString(fStringBuffer.toString());
  -                 }
  -                 fDatatypeBuffer.append(fStringBuffer.toString());
  +                        fStringPool.releaseString(data);
  +                        data = fStringPool.addString(fStringBuffer.toString());
  +                    }
  +                    fDatatypeBuffer.append(fStringBuffer.toString());
  +                }
                }
                else {
                    fDatatypeBuffer.append(fStringPool.toString(data));
  @@ -3229,12 +3239,19 @@
                                                         }
                                                         if (attDecl.type == XMLAttributeDecl.TYPE_IDREF
) {
                                                            attDV.validate(value, this.fStoreIDRef
);
  -                                                      } else {
  +                                                      }
  +                                                       else {
                                                             if (NORMALIZATION_ON) {
  -                                                              //REVISIT: add check if CDATA..
  -                                                              int normalizedValue = fStringPool.addString(value);
  -                                                              attrList.setAttValue(index,normalizedValue
);
  -                                                              fTempAttDecl.datatypeValidator.validate(value,
null );
  +                                                              fWhiteSpace = attDV.getWSFacet();
  +                                                              if (fWhiteSpace == DatatypeValidator.REPLACE)
{ //CDATA
  +                                                                  attDV.validate(unTrimValue,
null );
  +                                                              }
  +                                                              else { // normalize 
  +                                                                  int normalizedValue =
fStringPool.addString(value);
  +                                                                  attrList.setAttValue(index,normalizedValue
);
  +                                                                  attDV.validate(value,
null );
  +                                                              }
  +                                                              
                                                             }
                                                             else {
                                                                 attDV.validate(unTrimValue,
null );
  @@ -3292,12 +3309,18 @@
                                          this.fStoreIDRef.setDatatypeObject( fValID.validate(
value, null ) );
                                       } else if (fTempAttDecl.type == XMLAttributeDecl.TYPE_IDREF
) {
                                          fTempAttDecl.datatypeValidator.validate(value, this.fStoreIDRef
);
  -                                    } else {
  +                                    }
  +                                    else {
                                           if (NORMALIZATION_ON) {
  -                                              //REVISIT: add check if CDATA..
  -                                              int normalizedValue = fStringPool.addString(value);
  -                                              attrList.setAttValue(index,normalizedValue
);
  -                                              fTempAttDecl.datatypeValidator.validate(value,
null );
  +                                            fWhiteSpace = fTempAttDecl.datatypeValidator.getWSFacet();
  +                                            if (fWhiteSpace == DatatypeValidator.REPLACE)
{ //CDATA
  +                                                   fTempAttDecl.datatypeValidator.validate(unTrimValue,
null );
  +                                            }
  +                                            else { // normalize 
  +                                                  int normalizedValue = fStringPool.addString(value);
  +                                                  attrList.setAttValue(index,normalizedValue
);
  +                                                  fTempAttDecl.datatypeValidator.validate(value,
null );
  +                                            }
                                           }
                                           else {
                                                 fTempAttDecl.datatypeValidator.validate(unTrimValue,
null );
  @@ -3765,24 +3788,23 @@
                                          XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
            } else {
               try {
  -
  -               fGrammar.getElementDecl(elementIndex, fTempElementDecl);
  -
  -               DatatypeValidator dv = fTempElementDecl.datatypeValidator;
  -
  -               // If there is xsi:type validator, substitute it.
  +                if (!NORMALIZATION_ON || fCurrentDV == null) { //no character data   
  +                    fGrammar.getElementDecl(elementIndex, fTempElementDecl);
  +                    fCurrentDV = fTempElementDecl.datatypeValidator;
  +                }
  +                
  +                // If there is xsi:type validator, substitute it.
                  if ( fXsiTypeValidator != null ) {
  -                  dv = fXsiTypeValidator;
  +                  fCurrentDV = fXsiTypeValidator;
                     fXsiTypeValidator = null;
                  }
  -
  -               if (dv == null) {
  +               if (fCurrentDV == null) {
                     System.out.println("Internal Error: this element have a simpletype "+
                                        "but no datatypevalidator was found, element "+fTempElementDecl.name
                                        +",locapart: "+fStringPool.toString(fTempElementDecl.name.localpart));
                  } else {
  -                  dv.validate(fDatatypeBuffer.toString(), null);
  -                  fCollapse = false;
  +                  fCurrentDV.validate(fDatatypeBuffer.toString(), null);
  +                  fCurrentDV = null;
                     fFirstChunk= true;
                  }
   
  
  
  
  1.4       +11 -22    xml-xerces/java/src/org/apache/xerces/validators/datatype/AbstractDatatypeValidator.java
  
  Index: AbstractDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/AbstractDatatypeValidator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractDatatypeValidator.java	2000/06/06 19:54:24	1.3
  +++ AbstractDatatypeValidator.java	2001/02/14 21:28:29	1.4
  @@ -57,7 +57,7 @@
   
   
   /**
  - * @version $Id: AbstractDatatypeValidator.java,v 1.3 2000/06/06 19:54:24 jeffreyr Exp
$
  + * @version $Id: AbstractDatatypeValidator.java,v 1.4 2001/02/14 21:28:29 elena Exp $
    * @author  Jeffrey Rodriguez
   */
   
  @@ -72,21 +72,8 @@
   
       private Hashtable fFacets; // Hashtable of Facets Strings.
   
  -    //abstract public AbstractDatatypeValidator();
  -    //public AbstractDatatypeValidator(){
  -    //}
   
  -
  -    //abstract public AbstractDatatypeValidator ( DatatypeValidator base, Hashtable facets,

  -      //                                 boolean list ); 
  -
  -    //public AbstractDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -    //                                                                boolean list ){ 
  -    //
  -    //
  -    //}
  -
  -    /**
  +     /**
        * Checks that "content" string is valid
        * datatype.
        * If invalid a Datatype validation exception is thrown.
  @@ -103,13 +90,7 @@
        * @see         org.apache.xerces.validators.datatype.InvalidDatatypeValueException
        */
       abstract public Object validate(String content, Object state) throws InvalidDatatypeValueException;
  -
  -    //{ 
  -     //   System.out.println( "Here in AbstracDatatype " + content );
  -      //  return null;
  -    //}
  -
  -
  +    
       abstract public Object clone() throws CloneNotSupportedException ;
   
   
  @@ -121,6 +102,14 @@
        */
       public Hashtable getFacets() {
           return null;  // Not implemented yet
  +    }
  +    
  +    /**
  +     * default value for whiteSpace facet is collapse
  +     * this function is overwritten in StringDatatypeValidator
  +     */
  +    public short getWSFacet (){
  +        return DatatypeValidator.COLLAPSE;
       }
       /**
        * Compares content in the Domain value vs. lexical
  
  
  
  1.7       +8 -2      xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidator.java
  
  Index: DatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DatatypeValidator.java	2000/06/02 23:04:23	1.6
  +++ DatatypeValidator.java	2001/02/14 21:28:30	1.7
  @@ -68,7 +68,7 @@
    * W3C to remove facets from the data type spec.
    * 
    * @author Jeffrey Rodriguez-
  - * @version $Id: DatatypeValidator.java,v 1.6 2000/06/02 23:04:23 jeffreyr Exp $
  + * @version $Id: DatatypeValidator.java,v 1.7 2001/02/14 21:28:30 elena Exp $
    */
   public interface DatatypeValidator {
       public static final int FACET_LENGTH       = 1;
  @@ -85,9 +85,15 @@
       public static final int FACET_ENCODING     = 1<<11;
       public static final int FACET_DURATION     = 1<<12;
       public static final int FACET_PERIOD       = 1<<13;
  +    public static final int FACET_WHITESPACE   = 1<<14;
   
  +    //2.4.2.6 whiteSpace - Datatypes 
  +    public static final short PRESERVE = 0;
  +    public static final short REPLACE  = 1;
  +    public static final short COLLAPSE = 2;
   
   
  +
       /**
        * Checks that "content" string is valid 
        * datatype.
  @@ -105,8 +111,8 @@
        * @see         org.apache.xerces.validators.datatype.InvalidDatatypeValueException
        */
       public Object validate(String content, Object state ) throws InvalidDatatypeValueException;
  -
   
  +    public short getWSFacet ();
       /**
        * returns the datatype facet if any is set as a
        * Hashtable
  
  
  
  1.20      +40 -18    xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidatorFactoryImpl.java
  
  Index: DatatypeValidatorFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DatatypeValidatorFactoryImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DatatypeValidatorFactoryImpl.java	2000/12/11 21:11:27	1.19
  +++ DatatypeValidatorFactoryImpl.java	2001/02/14 21:28:30	1.20
  @@ -87,7 +87,7 @@
    * 
    * @author Jeffrey Rodriguez
    * @author Mark Swinkles - List Validation refactoring
  - * @version $Id: DatatypeValidatorFactoryImpl.java,v 1.19 2000/12/11 21:11:27 ericye Exp
$
  + * @version $Id: DatatypeValidatorFactoryImpl.java,v 1.20 2001/02/14 21:28:30 elena Exp
$
    */
   public class DatatypeValidatorFactoryImpl implements DatatypeValidatorFactory {
   
  @@ -142,6 +142,7 @@
   
                   Hashtable facets = new Hashtable();
                   facets.put(SchemaSymbols.ELT_PATTERN , "\\c+" );
  +                facets.put(SchemaSymbols.ELT_WHITESPACE, "collapse");
                   createDatatypeValidator("NMTOKEN", new StringDatatypeValidator(), facets,
false );
   
                   createDatatypeValidator("NMTOKENS",  
  @@ -174,7 +175,8 @@
                   fRegistry.put("binary",            new BinaryDatatypeValidator());
                   fRegistry.put("uriReference",      new URIReferenceDatatypeValidator());
                   fRegistry.put("QName",             new QNameDatatypeValidator()); 
  -
  +                
  +                
                   // need to check if the registry has been "DTD" initilized --ericye
                   // since we share the same instance of DTD attribute validators across
the board,
                   // we couldn't afford call the initializeDTDRegistry more than one time.
  @@ -183,30 +185,25 @@
                   }
   
                   Hashtable facets = new Hashtable();
  -                facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*"
);
  -
  -                createDatatypeValidator("language", new StringDatatypeValidator() , facets,
  -                                        false );
  -
  -                //createDatatypeValidator( "IDREFS", new IDREFDatatypeValidator(), null
, true );
  -
  -                //createDatatypeValidator( "ENTITIES", new ENTITYDatatypeValidator(), 
null, true );
  +                facets.put(SchemaSymbols.ELT_WHITESPACE, "replace");
  +                createDatatypeValidator("CDATA", new StringDatatypeValidator(), facets,
false);
   
  -                //facets = new Hashtable();
  -                //facets.put(SchemaSymbols.ELT_PATTERN , "\\c+" );
  -                //createDatatypeValidator("NMTOKEN", new StringDatatypeValidator(), facets,
false );
   
  -                //createDatatypeValidator("NMTOKENS",  
  -                //                        getDatatypeValidator( "NMTOKEN" ), null, true
);
  +                facets = new Hashtable();
  +                facets.put(SchemaSymbols.ELT_WHITESPACE, "collapse");
  +                createDatatypeValidator("token", getDatatypeValidator("CDATA"), facets,
false);
   
  +                facets = new Hashtable();
  +                facets.put(SchemaSymbols.ELT_PATTERN , "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*"
);
  +                createDatatypeValidator("language", getDatatypeValidator("token") , facets,
false );
   
                   facets = new Hashtable();
                   facets.put(SchemaSymbols.ELT_PATTERN , "\\i\\c*" );
  -                createDatatypeValidator("Name", new StringDatatypeValidator(), facets,
false );
  +                createDatatypeValidator("Name", getDatatypeValidator("token"), facets,
false );
   
                   facets = new Hashtable();
                   facets.put(SchemaSymbols.ELT_PATTERN , "[\\i-[:]][\\c-[:]]*"  );
  -                createDatatypeValidator("NCName", new StringDatatypeValidator(), facets,
false );
  +                createDatatypeValidator("NCName", getDatatypeValidator("token"), facets,
false );
   
                   facets = new Hashtable();
                   facets.put(SchemaSymbols.ELT_SCALE, "0");
  @@ -359,8 +356,33 @@
                   simpleType = new ListDatatypeValidator(base, facets, list);    
               } else {
                   try {
  -                    Class validatorDef = base.getClass();
  +                    String value = (String)facets.get(SchemaSymbols.ELT_WHITESPACE);
  +                    if (base instanceof StringDatatypeValidator) { 
  +                        //record value of whiteSpace facet present on the base datatype
  +                        short ws = base.getWSFacet();
  +                        if ( value == null) {
  +                           value = (ws!=DatatypeValidator.COLLAPSE)?(ws==DatatypeValidator.REPLACE)?"replace":"preserve":"collapse";
  +                           facets.put(SchemaSymbols.ELT_WHITESPACE, value);
  +                        }
  +                        else {
  +                            if (ws == DatatypeValidator.REPLACE && !value.equals("collapse")){
  +                                facets.put(SchemaSymbols.ELT_WHITESPACE, "replace");
  +                            }
  +                            else if (ws == DatatypeValidator.COLLAPSE) {
  +                                facets.put(SchemaSymbols.ELT_WHITESPACE, "collapse");
  +                            }
  +                        }
  +                    }
  +                    else { 
  +                        //for all other datatypes we don't need to pass WHITESPACE Facet
  +                        //its value is always 'collapse' and cannot be reset by user
  +                        if (value !=null) {
  +                            facets.remove(SchemaSymbols.ELT_WHITESPACE);
  +                        }
  +                    }
   
  +                    Class validatorDef = base.getClass();
  +                    
                       Class [] validatorArgsClass = new Class[] {  
                           org.apache.xerces.validators.datatype.DatatypeValidator.class,
                           java.util.Hashtable.class,
  
  
  
  1.18      +19 -3     xml-xerces/java/src/org/apache/xerces/validators/datatype/StringDatatypeValidator.java
  
  Index: StringDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/StringDatatypeValidator.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StringDatatypeValidator.java	2000/10/17 00:52:40	1.17
  +++ StringDatatypeValidator.java	2001/02/14 21:28:31	1.18
  @@ -74,7 +74,7 @@
    * @author Kito D. Mann, Virtua Communications Corp.
    * @author Jeffrey Rodriguez
    * @author Mark Swinkles - List Validation refactoring
  - * @version $Id: StringDatatypeValidator.java,v 1.17 2000/10/17 00:52:40 jeffreyr Exp $
  + * @version $Id: StringDatatypeValidator.java,v 1.18 2001/02/14 21:28:31 elena Exp $
    */
   public class StringDatatypeValidator extends AbstractDatatypeValidator{
       private Locale     fLocale          = null;
  @@ -90,6 +90,7 @@
       private String     fMinInclusive     = null;
       private String     fMinExclusive     = null;
       private int        fFacetsDefined    = 0;
  +    private  short      fWhiteSpace = DatatypeValidator.PRESERVE;
   
       private boolean    isMaxExclusiveDefined = false;
       private boolean    isMaxInclusiveDefined = false;
  @@ -162,6 +163,19 @@
                   } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
                       fFacetsDefined += DatatypeValidator.FACET_MINEXCLUSIVE;
                       fMinExclusive = (String)facets.get(key);
  +                } else if (key.equals(SchemaSymbols.ELT_WHITESPACE)) {
  +                    fFacetsDefined += DatatypeValidator.FACET_WHITESPACE;
  +                    String ws = (String)facets.get(key);
  +                    if (ws.equals("replace")) {
  +                        fWhiteSpace = DatatypeValidator.REPLACE;
  +                    }
  +                    else if (ws.equals("collapse")) {
  +                        fWhiteSpace = DatatypeValidator.COLLAPSE;
  +                    }
  +                    else {
  +                        fWhiteSpace = DatatypeValidator.PRESERVE;
  +                    }
  +
                   } else {
                       throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
                   }
  @@ -205,8 +219,10 @@
           }// End of Facets Setting
       }
   
  -
   
  +    public short getWSFacet(){
  +        return fWhiteSpace;
  +    }
   
       /**
        * validate that a string is a W3C string type
  @@ -234,7 +250,7 @@
   
       /**
        * 
  -     * @return                          A Hashtable containing the facets
  +     * @return   A Hashtable containing the facets
        *         for this datatype.
        */
       public Hashtable getFacets(){
  
  
  
  1.101     +7 -7      xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
  
  Index: TraverseSchema.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- TraverseSchema.java	2001/02/11 21:45:35	1.100
  +++ TraverseSchema.java	2001/02/14 21:28:34	1.101
  @@ -124,7 +124,7 @@
    *  
    * @see org.apache.xerces.validators.common.Grammar
    *
  - * @version $Id: TraverseSchema.java,v 1.100 2001/02/11 21:45:35 lmartin Exp $
  + * @version $Id: TraverseSchema.java,v 1.101 2001/02/14 21:28:34 elena Exp $
    */
   public class TraverseSchema implements 
                               NamespacesScope.NamespacesHandler{
  @@ -1080,28 +1080,28 @@
           
           Hashtable facetData =null; 
           int numFacets=0;
  -
  +        facetData        = new Hashtable();
           if (restriction && content != null) {
  -        
               int numEnumerationLiterals = 0;
  -            facetData        = new Hashtable();
               Vector enumData  = new Vector();
               content = checkContent(simpleTypeDecl, content , true);
  +            String facet;
               while (content != null) { 
                   if (content.getNodeType() == Node.ELEMENT_NODE) {
                           numFacets++;
  -                        if (content.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION))
{
  +                        facet =content.getLocalName(); 
  +                        if (facet.equals(SchemaSymbols.ELT_ENUMERATION)) {
                               numEnumerationLiterals++;
                               String enumVal = content.getAttribute(SchemaSymbols.ATT_VALUE);
                               enumData.addElement(enumVal);
                               checkContent(simpleTypeDecl, XUtil.getFirstChildElement( content
), true);
                           }
  -                        else if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION))
{
  +                        else if (facet.equals(SchemaSymbols.ELT_ANNOTATION)) {
                                     reportSchemaError(SchemaMessageProvider.ContentError,
                                                       new Object [] { simpleTypeDecl.getAttribute(
SchemaSymbols.ATT_NAME )});
                           }
                           else {
  -                             facetData.put(content.getLocalName(),content.getAttribute(
SchemaSymbols.ATT_VALUE ));
  +                             facetData.put(facet,content.getAttribute( SchemaSymbols.ATT_VALUE
));
                                checkContent(simpleTypeDecl, XUtil.getFirstChildElement( content
), true);
                           }
                   }
  
  
  

Mime
View raw message