You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2006/07/20 23:30:50 UTC

svn commit: r424071 - /xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java

Author: cezar
Date: Thu Jul 20 14:30:50 2006
New Revision: 424071

URL: http://svn.apache.org/viewvc?rev=424071&view=rev
Log:
Fix for Jira XMLBEANS-274 Over zealous whitespace cropping after parsing entity like &.

chckintests pass

Modified:
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java?rev=424071&r1=424070&r2=424071&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java Thu Jul 20 14:30:50 2006
@@ -2990,6 +2990,7 @@
         protected void startElement ( QName name )
         {
             start( createElementXobj( _locale, checkName( name, false ), parent()._name ) );
+            _stripLeft = true;
         }
 
         protected void endElement ( )
@@ -2997,6 +2998,7 @@
             assert parent().isElem();
 
             end();
+            _stripLeft = true;
         }
 
         protected void xmlns ( String prefix, String uri )
@@ -3071,12 +3073,14 @@
                 _lastXobj = x;
                 _lastPos  = 0;
             }
+            _stripLeft = true;
         }
 
         protected void comment ( String comment )
         {
             if (!_stripComments)
                 comment( comment, 0, comment.length() );
+            _stripLeft = true;
         }
 
         protected void comment ( char[] chars, int off, int cch )
@@ -3087,6 +3091,7 @@
                     _charUtil.saveChars( chars, off, cch ),
                     _charUtil._offSrc, _charUtil._cchSrc );
             }
+            _stripLeft = true;
         }
 
         private void comment ( Object src, int off, int cch )
@@ -3101,13 +3106,20 @@
             _lastPos  = 0;
         }
 
+        private boolean _stripLeft = true;
+
         private void stripText ( Object src, int off, int cch )
         {
             if (_stripWhitespace)
             {
-                src = _charUtil.stripLeft( src, off, cch );
-                off = _charUtil._offSrc;
-                cch = _charUtil._cchSrc;
+                // this is to avoid bug in cases like <company>Procter &amp; Gamble</company>
+                if (_stripLeft)
+                {
+                    src = _charUtil.stripLeft( src, off, cch );
+                    _stripLeft = false;
+                    off = _charUtil._offSrc;
+                    cch = _charUtil._cchSrc;
+                }
             }
 
             text( src, off, cch );
@@ -3166,6 +3178,7 @@
 
         protected void abort ( )
         {
+            _stripLeft = true;
             while ( !parent().isRoot() )
                 end();
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org