You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Krzysztof Zielinski <kr...@desy.de> on 2001/05/17 12:42:22 UTC

'\n' characters in DOMtree

I am reading an XML and creating DOMTree using Xerces. Unfortunately
characters like '\n' are also read from the file.

What to do in order to avoid those characters in the DOMTree ?
Or how to avoid them when manipulating DOMTree,and then sending it to
Xalan2 transformer ?

Thanks.

Re: '\n' characters in DOMtree

Posted by Krzysztof Zielinski <kr...@desy.de>.
But I need to have a DOM tree, as I need to modify some text elements
after I read document from the file. SAX2 doesn't create DOM tree, does
it ?

Andy Clark schrieb:
> 
> sadlion wrote:
> > parser.setIncludeIgnorableWhitespace (false) ;
> 
> It's better to use the configuration methods available via
> SAX2. There is a feature defined for this. For example:
> 
> 
> parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace",
>                     false);
> 
> Check the Features and Properties in the documentation for
> more info.
> 
> --
> Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: '\n' characters in DOMtree

Posted by Arnaud Le Hors <le...@us.ibm.com>.
Krzysztof Zielinski wrote:
> 
> Could you give an example of DTD that tell that there can't be any '\n'
> or any other space characters exept text which is an element value ?

Here:

<!ELEMENT A (B, C)>

That says element A contains an element B followed by an element C (and
nothing else). In that case any whitespace between the related tags is
"whitespace in element content", commonly refered to as "ignorable
whitespace".

You guys need to read the XML spec or a book or something. No offense
intended.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

Re: '\n' characters in DOMtree

Posted by Krzysztof Zielinski <kr...@desy.de>.
Could you give an example of DTD that tell that there can't be any '\n'
or any other space characters exept text which is an element value ?

Thanks

K.

Arnaud Le Hors schrieb:
> 
> Krzysztof Zielinski wrote:
> >
> > I have set that feature, but when I am displaying DOM tree, there are
> > still those elements.
> 
> You also need a DTD that tells the parser what is "ignorable"... This is
> done by specifying that your elements only contain elements.
> --
> Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

Re: '\n' characters in DOMtree

Posted by Arnaud Le Hors <le...@us.ibm.com>.
Krzysztof Zielinski wrote:
> 
> I have set that feature, but when I am displaying DOM tree, there are
> still those elements.

You also need a DTD that tells the parser what is "ignorable"... This is
done by specifying that your elements only contain elements.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

Re: '\n' characters in DOMtree

Posted by Krzysztof Zielinski <kr...@desy.de>.
I have set that feature, but when I am displaying DOM tree, there are
still those elements.

Andy Clark schrieb:
> 
> sadlion wrote:
> > parser.setIncludeIgnorableWhitespace (false) ;
> 
> It's better to use the configuration methods available via
> SAX2. There is a feature defined for this. For example:
> 
> 
> parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace",
>                     false);
> 
> Check the Features and Properties in the documentation for
> more info.
> 
> --
> Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: '\n' characters in DOMtree

Posted by Andy Clark <an...@apache.org>.
sadlion wrote:
> parser.setIncludeIgnorableWhitespace (false) ;

It's better to use the configuration methods available via
SAX2. There is a feature defined for this. For example:

 
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace",
                    false);

Check the Features and Properties in the documentation for 
more info.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: '\n' characters in DOMtree

Posted by sadlion <sa...@human.co.kr>.
Hello!

I don't know how you want to process exactly....
,but if  you want white space characters are removed,  use the following command ....I

parser.setIncludeIgnorableWhitespace (false) ;

It make let the parser don't process white space for element which it don't declare with #pcdata of subelement in dtd , 
If element have subelement that declares with #pcdata, white space characters must be processed....

I hope that it is helpful comment for you....

Have a good day!

 bye! ^^!

from sadlion in Seoul

----- Original Message ----- 
From: "Krzysztof Zielinski" <kr...@desy.de>
To: <xe...@xml.apache.org>
Sent: Thursday, May 17, 2001 7:42 PM
Subject: '\n' characters in DOMtree


> I am reading an XML and creating DOMTree using Xerces. Unfortunately
> characters like '\n' are also read from the file.
> 
> What to do in order to avoid those characters in the DOMTree ?
> Or how to avoid them when manipulating DOMTree,and then sending it to
> Xalan2 transformer ?
> 
> Thanks.
>