You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Truong, Bon" <bt...@netfish.com> on 2000/01/13 06:43:28 UTC
Printing a document without whitespace between the elements
Hi,
I have written class that extends DOMParser. In that class I override the
method "ignorableWhitespace",
which looks like this:
public void ignorableWhitespace(int dataIndex) throws Exception
{
if(! NotIncludeIgnorableWhiteSpaces )
super.ignorableWhitespace( dataIndex);
else
;// Ignore ignorable white spaces
}// ignorableWhitespace
In the same class, there is also a method "print",
which has one switch case like this one:
case Node.TEXT_NODE: {
out.print(normalize(node.getNodeValue()));
break;
}
But when I run the program it prints the whitespace between the elements.
How can I get it not to print all the whitespace?
Thanks.
Bon
Re: Printing a document without whitespace between the elements
Posted by Ralf Pfeiffer <rp...@apache.org>.
The ignore ignorableWhitespace functionality that you are attempting to
provide has recently been implemented. Please extract the latest, and check
out the new
Xerces feature (comments from the DOMParser code):
//
http://apache.org/xml/features/dom/include-ignorable-whitespace
// This feature determines whether text nodes that can be
// considered "ignorable whitespace" are included in the DOM
// tree.
// Note: The only way that the parser can determine if text
// is ignorable is by reading the associated grammar
// and having a content model for the document. When
// ignorable whitespace text nodes *are* included in
// the DOM tree, they will be flagged as ignorable.
// The ignorable flag can be queried by calling the
// TextImpl#isIgnorableWhitespace():boolean method.
"Truong, Bon" wrote:
> Hi,
>
> I have written class that extends DOMParser. In that class I override the
> method "ignorableWhitespace",
> which looks like this:
>
> public void ignorableWhitespace(int dataIndex) throws Exception
> {
> if(! NotIncludeIgnorableWhiteSpaces )
> super.ignorableWhitespace( dataIndex);
> else
> ;// Ignore ignorable white spaces
> }// ignorableWhitespace
>
> In the same class, there is also a method "print",
> which has one switch case like this one:
>
> case Node.TEXT_NODE: {
>
> out.print(normalize(node.getNodeValue()));
>
> break;
> }
>
> But when I run the program it prints the whitespace between the elements.
> How can I get it not to print all the whitespace?
>
> Thanks.
>
> Bon