sandygao 2002/10/25 12:51:30 Modified: java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java Log: Performance: we don't always need to fully normalize the string. 1. For base64 and derived types, the whitespaces are actually handled in the Base64 classes, so we don't need to normalize the string at all. 2. For many other types (all but string and derived types), no whitespace is allowed in in the value (only leading and trailing ones are allowed). So instead of collapse, the whitespaces, we only need to trim the leading and trailing one. if there are whitespaces in the middle, an error will be reported when trying to convert the string value to actual value. Revision Changes Path 1.20 +41 -2 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Index: XSSimpleTypeDecl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- XSSimpleTypeDecl.java 25 Oct 2002 16:42:30 -0000 1.19 +++ XSSimpleTypeDecl.java 25 Oct 2002 19:51:30 -0000 1.20 @@ -137,6 +137,37 @@ new UnionDV() }; + static final short NORMALIZE_NONE = 0; + static final short NORMALIZE_TRIM = 1; + static final short NORMALIZE_FULL = 2; + static final short[] fDVNormalizeType = { + NORMALIZE_NONE, //AnySimpleDV(), + NORMALIZE_FULL, //StringDV(), + NORMALIZE_TRIM, //BooleanDV(), + NORMALIZE_TRIM, //DecimalDV(), + NORMALIZE_TRIM, //FloatDV(), + NORMALIZE_TRIM, //DoubleDV(), + NORMALIZE_TRIM, //DurationDV(), + NORMALIZE_TRIM, //DateTimeDV(), + NORMALIZE_TRIM, //TimeDV(), + NORMALIZE_TRIM, //DateDV(), + NORMALIZE_TRIM, //YearMonthDV(), + NORMALIZE_TRIM, //YearDV(), + NORMALIZE_TRIM, //MonthDayDV(), + NORMALIZE_TRIM, //DayDV(), + NORMALIZE_TRIM, //MonthDV(), + NORMALIZE_TRIM, //HexBinaryDV(), + NORMALIZE_NONE, //Base64BinaryDV(), // Base64 know how to deal with spaces + NORMALIZE_TRIM, //AnyURIDV(), + NORMALIZE_TRIM, //QNameDV(), + NORMALIZE_TRIM, //QNameDV(), // notation + NORMALIZE_FULL, //IDDV(), + NORMALIZE_FULL, //IDREFDV(), + NORMALIZE_FULL, //EntityDV(), + NORMALIZE_FULL, //ListDV(), + NORMALIZE_NONE, //UnionDV() + }; + static final short SPECIAL_PATTERN_NONE = 0; static final short SPECIAL_PATTERN_NMTOKEN = 1; static final short SPECIAL_PATTERN_NAME = 2; @@ -1639,10 +1670,18 @@ } // normalize the string according to the whiteSpace facet - protected static String normalize(Object content, short ws) { + protected String normalize(Object content, short ws) { if (content == null) return null; + short norm_type = fDVNormalizeType[fValidationDV]; + if (norm_type == NORMALIZE_NONE) { + return content.toString(); + } + else if (norm_type == NORMALIZE_TRIM) { + return content.toString().trim(); + } + if (!(content instanceof StringBuffer)) { String strContent = content.toString(); return normalize(strContent, ws);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]