Hi,
On Wed, 2007-07-25 at 12:41 -0400, Bishop, Michael W. CONTR
J9C880
wrote:
> I use the following to load a file to an SVGDocument:
>
> private static String className =
> XMLResourceDescriptor.getXMLParserClassName();
> private static SAXSVGDocumentFactory factory =
> new SAXSVGDocumentFactory(className);
> ...
> factory.createSVGDocument(svgFile.toURI().toString());
>
> The problem is, when I walk the DOM tree to discover
information about
> each Node and its siblings, I end up with a bunch of
empty whitespace
> nodes. When I build an SVGDocument in memory, I don't
have this
> problem. How can I load an SVGDocument to a File and
have it ignore
> whitespace?
IMHO, any conforming svg parser should have a whitespace
node in the DOM
if the document is structured like your example. We
experience this
problem as well, so we do the workaround by put node filter
(that check
for whitespace outside <text> node with xml space
preserve) every time
we traverse the DOM Tree.
Another note: when you save the document into file, don't do
pretty
formating or you will get this whitespace problem. Or if you
really want
to pretty format the xml source, break at attribute level,
do not break
at element level, eg: <rect ...><circle ..break
here at attribute level
so the >< (end tag and open tag) is side by side
Regards
Tonny Kohar
--
Kiyut
imagine, design, create ...
http://www.kiyut.com
------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribe xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help xmlgraphics.apache.org
|