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 Sudha Sathiaseelan <Su...@plumtree.com> on 2003/03/18 23:19:12 UTC
Whitespaces
Hi all,
Is there a known way to ignore whitespace when loading an xml document through DocumentBuilderFactoryImpl? For those familiar with .NET/C#, it's possible to toggle the PreserveWhitespace flag on an XmlDocument. I can't seem to find a corollary with the xerces parser. Any suggestions (besides formatting the input xml document on one line)
Thanks,
Sudha
i.e.
<?xml version="1.0"?><books price="6"><book><author>Carson</author></book></books>
as opposed to
<?xml version="1.0"?>
<books price="6">
<book>
<author>Carson</author>
<price format="dollar">31.95</price>
<pubdate>05/01/2001</pubdate>
</book>
</books>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Whitespaces
Posted by Neeraj Bajaj <ne...@sun.com>.
Sudha Sathiaseelan wrote:
>Hi all,
>
>Is there a known way to ignore whitespace when loading an xml document through DocumentBuilderFactoryImpl?
>
Set
DocumentBuilderFactory#setIgnoringElementContentWhitespace(boolean) to
true. You should note that this feature works only when element content
is made avaliable to the parser. making it mandatory for DOCTYPE
declaration to be part of XML document.
http://java.sun.com/webservices/docs/1.1/api/javax/xml/parsers/DocumentBuilderFactory.html
http://www.w3.org/TR/REC-xml#sec-white-space
Neeraj
>For those familiar with .NET/C#, it's possible to toggle the PreserveWhitespace flag on an XmlDocument. I can't seem to find a corollary with the xerces parser. Any suggestions (besides formatting the input xml document on one line)
>
>Thanks,
>Sudha
>
>i.e.
>
><?xml version="1.0"?><books price="6"><book><author>Carson</author></book></books>
>
>as opposed to
>
><?xml version="1.0"?>
> <books price="6">
> <book>
> <author>Carson</author>
> <price format="dollar">31.95</price>
> <pubdate>05/01/2001</pubdate>
> </book>
> </books>
>
>---------------------------------------------------------------------
>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
Re: Whitespaces
Posted by Joseph Kesselman <ke...@us.ibm.com>.
See http://xml.apache.org/xerces2-j/features.html, entry
http://apache.org/xml/features/dom/include-ignorable-whitespace
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"may'ron DaroQbe'chugh vaj bIrIQbej" ("Put down the squeezebox and nobody
gets hurt.")
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org