/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. You * may not use this file except in compliance with the License.
* * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License").
formatting XML with line breaks and perhaps indentation.
St AX always outputs XML files as a single enormous line with no added whitespace whatsoever, making manual inspection very cumbersome.
Unless you have a compelling reason to do otherwise, you should probably use St AX by default when dealing with XML in Java.
It’s more efficient than DOM Parser for large XML files in terms of time and memory usage.SAX provides only a “push” parser (no writer) that requires a cumbersome event handling setup to obtain the parsed data, and DOM replicates the entire XML document in memory which is not feasible for large files.In contrast, St AX is a “streaming” API like SAX with minimal memory footprint regardless of data size, but its “pull” model is nearly as easy to use and understand as DOM – and St AX also features a writer.Interface XMLStream Reader provides PULL API (compared to SAX which provides PUSH API).It means that the programmer explicitly decides when to extract next event from the XML document and can get prepared to it beforehand.