sandygao    2002/10/25 09:42:39

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
  Log:
  Performance: adding a new validate method that takes an Object as the string
  value. This enables passing a StringBuffer to such method, and possibly avoid
  some object creations. Without this method, we need to convert StringBuffer
  to String before calling validate method, then create a StringBuffer in the
  validate method for normalization, and finally convert the StringBuffer to a
  String again after normalization:
  buffer -> string -> buffer -> string
  With this method, the original StringBuffer can be used to hold the normalized
  value. This saves 2 object creations:
  buffer -> string
  
  Revision  Changes    Path
  1.120     +11 -9     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- XMLSchemaValidator.java   24 Oct 2002 15:56:35 -0000      1.119
  +++ XMLSchemaValidator.java   25 Oct 2002 16:42:38 -0000      1.120
  @@ -2209,6 +2209,8 @@
               // Same for append buffer. Simple types and elements with fixed
               // value constraint don't allow sub-elements. -SG
               fAppendBuffer = false;
  +            // same here.
  +            fUnionType = false;
           }
   
           return augs;
  @@ -2806,9 +2808,6 @@
           }
           // fixed values are handled later, after xsi:type determined.
   
  -        String content = XMLSymbols.EMPTY_STRING;
  -        if (fAppendBuffer)
  -            content = fBuffer.toString();
           fValidatedInfo.normalizedValue = null;
   
           // Element Locally Valid (Element)
  @@ -2843,11 +2842,12 @@
   
               // 5.2 If the declaration has no {value constraint} or the item has 
either element or character [children] or clause 3.2 has applied, then all of the 
following must be true:
               // 5.2.1 The element information item must be valid with respect to the 
actual type definition as defined by Element Locally Valid (Type) (3.3.4).
  -            Object actualValue = elementLocallyValidType(element, content);
  +            Object actualValue = elementLocallyValidType(element, fBuffer);
               // 5.2.2 If there is a fixed {value constraint} and clause 3.2 has not 
applied, all of the following must be true:
               if (fCurrentElemDecl != null &&
                   fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED &&
                   !fNil) {
  +                String content = fBuffer.toString();
                   // 5.2.2.1 The element information item must have no element 
information item [children].
                   if (fSubElement)
                       reportSchemaError("cvc-elt.5.2.2.1", new 
Object[]{element.rawname});
  @@ -2882,8 +2882,10 @@
               fDocumentHandler != null && fUnionType) {
               // for union types we need to send data because we delayed sending
               // this data when we received it in the characters() call.
  -            if (fValidatedInfo.normalizedValue != null)
  -                content = fValidatedInfo.normalizedValue;
  +            String content = fValidatedInfo.normalizedValue;
  +            if (content == null)
  +                content = fBuffer.toString();
  +            
               int bufLen = content.length();
               if (fNormalizedStr.ch == null || fNormalizedStr.ch.length < bufLen) {
                   fNormalizedStr.ch = new char[bufLen];
  @@ -2895,7 +2897,7 @@
           }
       } // processElementContent
   
  -    Object elementLocallyValidType(QName element, String textContent) {
  +    Object elementLocallyValidType(QName element, Object textContent) {
           if (fCurrentType == null)
               return null;
   
  @@ -2930,7 +2932,7 @@
           return retValue;
       } // elementLocallyValidType
   
  -    Object elementLocallyValidComplexType(QName element, String textContent) {
  +    Object elementLocallyValidComplexType(QName element, Object textContent) {
           Object actualValue = null;
           XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
   
  
  
  

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

Reply via email to