You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Schweigl, Johann" <Jo...@softwareag.com> on 2003/04/16 19:34:55 UTC

cannot convince xerces to call ignorableWhitespace()

Hello there,

i'm trying to split a huge XML document via SAX and want to get rid of
whitespace between elements. The underlying schema has no mixed="true"
attribute, so I suppose every whitespace character in between elements
qualifies as ignorable. I'm overloading the ignorableWhitespace method of
DefaultHandler in BigFileHandler like this:

	public void ignorableWhitespace(char buf[], int offset, int length)
throws SAXException {
		System.err.println(".");
	}


and start the whole process in this code fragment:

try {
	factory.setNamespaceAware(true);
	factory.setValidating(true);
	
	parser = factory.newSAXParser();
	
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
	
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
"...");
	parser.parse(new File(bigFile), new BigFileHandler());
}

However, ignorableWhitespace() never gets called. Everything is passed to
characters(). Did I miss anything? I'm using JDK 1.4.1_01, Xerces 2.4.0.

Cheers,
Johann

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


Re: cannot convince xerces to call ignorableWhitespace()

Posted by Richard Rowell <ri...@bowmansystems.com>.
On Wed, 2003-04-16 at 12:34, Schweigl, Johann wrote:
<snip>
>However, ignorableWhitespace() never gets called.

http://xml.apache.org/xerces2-j/features.html

It's not a bug, it's a feature ;-)


RE: cannot convince xerces to call ignorableWhitespace()

Posted by Rahul Srivastava <rs...@firstam.com>.
 > Schweigl, Johann wrote...
 >
 > i'm trying to split a huge XML document via SAX and want to get rid of
 > whitespace between elements. The underlying schema has no mixed="true"
 > attribute, so I suppose every whitespace character in between elements
 > qualifies as ignorable. I'm overloading the ignorableWhitespace method of
 > DefaultHandler in BigFileHandler like this:

Ignorablewhitespace is not defined by XMLSchema, and hence this feature
won't work when the grammar is XMLSchema. This feature works *only* when the
grammar is DTD. As Rowell mentioned, you can see:
http://xml.apache.org/xerces2-j/features.html#dom.include-ignorable-whitespa
ce

Cheers,
Rahul.


 >
 > 	public void ignorableWhitespace(char buf[], int offset, int length)
 > throws SAXException {
 > 		System.err.println(".");
 > 	}
 >
 >
 > and start the whole process in this code fragment:
 >
 > try {
 > 	factory.setNamespaceAware(true);
 > 	factory.setValidating(true);
 >
 > 	parser = factory.newSAXParser();
 >
 > parser.setProperty("http://java.sun.com/xml/jaxp/properties/schem
 > aLanguage",
 > "http://www.w3.org/2001/XMLSchema");
 >
 > parser.setProperty("http://java.sun.com/xml/jaxp/properties/schem
 > aSource",
 > "...");
 > 	parser.parse(new File(bigFile), new BigFileHandler());
 > }
 >
 > However, ignorableWhitespace() never gets called. Everything is passed to
 > characters(). Did I miss anything? I'm using JDK 1.4.1_01, Xerces 2.4.0.
 >
 > Cheers,
 > Johann
 >
 > ---------------------------------------------------------------------
 > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
 > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
 >
 >



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