xml:space
Tyler Baker
tyler at infinet.com
Mon Feb 23 17:15:43 GMT 1998
Michael J. Suzio wrote:
> What I wonder is, how does SAX decide what is ignorable
> whitespace and what is significant? I'm not clear on how that
> works, and the role xml:space plays in defining that.
> Ignoring whitespace is one of the most tedious things I keep doing
> in my XML parsing apps, I'd prefer to have to explicitly *work* to
> keep whitespace.
> What I don't understand is, given something like this in a DTD:
I think for problems like this, the application should just filter it all out
itself which is very simple.
Here is an inefficient implementation that will do just that for you in Java for
instance:
String data = "Fee Fi Fo\n\n\n Fum\t\t\t ";
java.util.StringTokenizer st = new StringTokenizer(data);
StringBuffer buffer = new StringBuffer();
while (st.hasMoreTokens()) {
buffer.append(st.nextToken());
buffer.append(' ');
}
buffer.setLength(buffer.length()-1);
String result = buffer.toString();
Result should be "Fee Fi Fo Fum"
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list