jkesselm 02/04/22 12:26:02
Modified: java/src/org/apache/xml/utils FastStringBuffer.java
Log:
Bug 4546 -- thanks to Wolfram Eisert for tracking this down and
proposing the patch.
Revision Changes Path
1.19 +21 -10
xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java
Index: FastStringBuffer.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- FastStringBuffer.java 12 Feb 2002 17:29:30 -0000 1.18
+++ FastStringBuffer.java 22 Apr 2002 19:26:02 -0000 1.19
@@ -1110,6 +1110,8 @@
* This version is aware of the fact that it may be called several times
* in succession if the data is made up of multiple "chunks", and thus
* must actively manage the handling of leading and trailing whitespace.
+ *
+ * Note: The recursion is due to the possible recursion of inner FSBs.
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
@@ -1141,6 +1143,8 @@
* suppressed.</dd>
* </dd>
* </dl>
+ *
+ *
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
@@ -1153,16 +1157,23 @@
int end = length + start;
int scanpos=start;
- // Leading whitespaces should be _completely_ suppressed if and only if
- // (a) we're the first chunk in the normalized sequence or (b) the
- // previous chunk ended in a normalized-but-not-suppressed whitespace.
- if(0!= (edgeTreatmentFlags&SUPPRESS_LEADING_WS) )
- for (; scanpos < end; scanpos++)
- {
- char c = ch[scanpos];
- if(!XMLCharacterRecognizer.isWhiteSpace(c))
- break;
- }
+ // Leading whitespaces should be _completely_ suppressed if and only if
+ // (a) we're the first chunk in the normalized sequence or (b) the
+ // previous chunk ended in a normalized-but-not-suppressed whitespace.
+ // If no suppression required and first char is whitespace, than
+ // add single space and suppress following white spaces
+ if (XMLCharacterRecognizer.isWhiteSpace(ch[scanpos]))
+ {
+ if(0 == (edgeTreatmentFlags&SUPPRESS_LEADING_WS) )
+ handler.characters(SINGLE_SPACE, 0, 1);
+
+ while(++scanpos < end)
+ {
+ char c = ch[scanpos];
+ if(!XMLCharacterRecognizer.isWhiteSpace(c))
+ break;
+ }
+ }
// %REVIEW% Do we really need both flags?
boolean whiteSpaceFound = false; // Last char seen was whitespace
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]