File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes xml ingore whitespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml ingore whitespace" Watch "xml ingore whitespace" New topic
Author

xml ingore whitespace

jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
hi

i am using :

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();

docFactory.setIgnoringElementContentWhitespace(true);
docFactory.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace",
false);
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

Document doc = docBuilder.parse(xsltFile);

but it does not ingore the white space, i do not want to remove all space manually , can anyone give me a solution
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Whitespace is only "ignorable" if you have a schema which describes the document. (Your code doesn't validate, so you don't have a schema.) Otherwise there is no way for the parser to tell which whitespace you are not interested in.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: xml ingore whitespace
 
Similar Threads
Ignoring whitespace in character data
Subtle, subtle, little Log4j difficulty
empty text nodes
NMTOKENS (supports seperation with tabs, CRs, extra whitespaces OR not?)
Need help for Shell Script to reduce a file