You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/03/29 05:53:27 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl Constants.java XMLDocumentFragmentScannerImpl.java

mrglavas    2004/03/28 19:53:27

  Modified:    java/src/org/apache/xerces/impl/dtd XMLDTDValidator.java
               java/src/org/apache/xerces/impl Constants.java
                        XMLDocumentFragmentScannerImpl.java
  Log:
  Performance: Reducing object creation.
  
  To support E15.2 from the XML 1.0 second edition
  errata we added an augmentation to communicate to the
  validator whether a character was included using a character
  reference. This is pretty expensive since a new instance of
  AugmentationsImpl was created for each character reference.
  
  Now only report this augmentation if the document is being
  validated and only if the character reference is of a probable
  white space character (ch <= 0x20). When parsing a
  document from disk containing over 1200 char refs with 
  SAX (no validation) I saw a 20% improvement.
  
  Revision  Changes    Path
  1.58      +2 -2      xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java
  
  Index: XMLDTDValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- XMLDTDValidator.java	24 Feb 2004 22:48:17 -0000	1.57
  +++ XMLDTDValidator.java	29 Mar 2004 03:53:26 -0000	1.58
  @@ -833,7 +833,7 @@
                   }
                   
                   // For E15.2
  -                if (augs != null && augs.getItem(XMLDocumentFragmentScannerImpl.CHAR_REF) == Boolean.TRUE) {
  +                if (augs != null && augs.getItem(Constants.CHAR_REF_PROBABLE_WS) == Boolean.TRUE) {
                       fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, 
                                                  "MSG_CONTENT_INVALID_SPECIFIED",
                                                  new Object[]{ fCurrentElement.rawname, 
  
  
  
  1.41      +12 -3     xml-xerces/java/src/org/apache/xerces/impl/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Constants.java	19 Mar 2004 23:18:33 -0000	1.40
  +++ Constants.java	29 Mar 2004 03:53:27 -0000	1.41
  @@ -327,18 +327,27 @@
       
       /** 
        * Boolean indicating whether an attribute is declared in the DTD is stored 
  -     * in augmentations using string "ATTRIBUTE_DECLARED". The absence of this
  +     * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this
        * augmentation indicates that the attribute was not declared in the DTD.
        */
       public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED";
       
       /** 
        * Boolean indicating whether an entity referenced in the document has
  -     * not been read is stored in augmentations using string "ENTITY_SKIPPED". 
  +     * not been read is stored in augmentations using the string "ENTITY_SKIPPED". 
        * The absence of this augmentation indicates that the entity had a 
        * declaration and was expanded.
        */
       public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED";
  +    
  +    /**
  +     * Boolean indicating whether a character is a probable white space
  +     * character (ch <= 0x20) that was the replacement text of a character 
  +     * reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS". 
  +     * The absence of this augmentation indicates that the character is not 
  +     * probable white space and/or was not included from a character reference.
  +     */
  +    public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS";
   
       // XML version constants 
       public final static short XML_VERSION_1_0 = 1;
  
  
  
  1.51      +6 -3      xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java
  
  Index: XMLDocumentFragmentScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- XMLDocumentFragmentScannerImpl.java	11 Mar 2004 18:15:17 -0000	1.50
  +++ XMLDocumentFragmentScannerImpl.java	29 Mar 2004 03:53:27 -0000	1.51
  @@ -1072,8 +1072,11 @@
                   if (fNotifyCharRefs) {
                       fDocumentHandler.startGeneralEntity(fCharRefLiteral, null, null, null);
                   }
  -                Augmentations augs = new AugmentationsImpl();
  -                augs.putItem(CHAR_REF, Boolean.TRUE);
  +                Augmentations augs = null;
  +                if (fValidation && ch <= 0x20) {
  +                    augs = new AugmentationsImpl();
  +                    augs.putItem(Constants.CHAR_REF_PROBABLE_WS, Boolean.TRUE);
  +                }
                   fDocumentHandler.characters(fStringBuffer2, augs);
                   if (fNotifyCharRefs) {
                       fDocumentHandler.endGeneralEntity(fCharRefLiteral, null);
  
  
  

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