You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/11/02 22:23:03 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLValidator.java
ericye 00/11/02 13:22:59
Modified: java/src/org/apache/xerces/impl Tag: xerces_j_2
XMLValidator.java
Log:
fix a bug in characters and white space handling
Revision Changes Path
No revision
No revision
1.1.2.21 +23 -16 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLValidator.java
Index: XMLValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLValidator.java,v
retrieving revision 1.1.2.20
retrieving revision 1.1.2.21
diff -u -r1.1.2.20 -r1.1.2.21
--- XMLValidator.java 2000/10/31 22:17:57 1.1.2.20
+++ XMLValidator.java 2000/11/02 21:22:54 1.1.2.21
@@ -89,7 +89,7 @@
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
* @author Andy Clark, IBM
*
- * @version $Id: XMLValidator.java,v 1.1.2.20 2000/10/31 22:17:57 ericye Exp $
+ * @version $Id: XMLValidator.java,v 1.1.2.21 2000/11/02 21:22:54 ericye Exp $
*/
public class XMLValidator
implements XMLComponent,
@@ -251,6 +251,10 @@
// initialize state
fInDTD = false;
fInDTDIgnore = false;
+ fStandaloneIsYes = false;
+ fSeenRootElement = false;
+ fBufferDatatype = false;
+ fInElementContent = false;
fValidation = configurationManager.getFeature(Constants.SAX_FEATURE_PREFIX+Constants.VALIDATION_FEATURE);
@@ -571,18 +575,27 @@
public void characters(XMLString text) throws SAXException {
boolean callNextCharacters = true;
+ boolean allWhiteSpace = true;
+ for (int i=text.offset; i< text.offset+text.length; i++) {
+ if (!XMLChar.isSpace(text.ch[i])) {
+ allWhiteSpace = false;
+ break;
+ }
+ }
+
+ // if in children model, and all charaters are white spaces, call the ignoreableWhiteSpace callback.
+ if (fInElementContent && allWhiteSpace) {
+ if (fDocumentHandler != null) {
+ fDocumentHandler.ignorableWhitespace(text);
+ callNextCharacters = false;
+ }
+ }
+
if (fValidation) {
if (fInElementContent ) {
- boolean allWhiteSpace = true;
if ( fCurrentGrammarIsDTD &&
fStandaloneIsYes &&
((DTDGrammar)fCurrentGrammar).getElementDeclIsExternal(fCurrentElementIndex)) {
- for (int i=text.offset; i< text.offset+text.length; i++) {
- if (!XMLChar.isSpace(text.ch[i])) {
- allWhiteSpace = false;
- break;
- }
- }
if (allWhiteSpace) {
fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
"MSG_WHITE_SPACE_IN_ELEMENT_CONTENT_WHEN_STANDALONE",
@@ -592,16 +605,10 @@
if (!allWhiteSpace) {
charDataInContent();
}
- else {
- // call handlers method: ignorable white space when children content.
- if (fDocumentHandler != null) {
- fDocumentHandler.ignorableWhitespace(text);
- callNextCharacters = false;
- }
- }
}
+
if ( fCurrentContentSpecType == XMLElementDecl.TYPE_EMPTY) {
- charDataInContent();
+ charDataInContent();
}
if (fBufferDatatype) {
fDatatypeBuffer.append(text.ch, text.offset, text.length);