xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Rüdiger <andreruedi...@web.de>
Subject DOM node from SVGGraphics2D
Date Fri, 10 Nov 2006 11:54:25 GMT

Hello List!

I want to export an org.w3c.dom.Node from a SVGGraphics2D object.

What I'm currently trying to do is:

    DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    Document doc = domImpl.createDocument(svgNS, "svg", null);
    ImageHandler imageHandler = new DefaultImageHandler();
    ExtensionHandler extensionHandler = new DefaultExtensionHandler();
    SVGGeneratorContext ctx = SVGGraphics2D.buildSVGGeneratorContext(doc,
            imageHandler, extensionHandler);
    SVGGraphics2D g = new SVGGraphics2D(ctx, false);
    Dimension dim = [...];
    [paint something]
    Element rootNode = doc.getDocumentElement();
    return rootNode;

The problem with this is that getRoot() seems to overwrite doc's already set
namespace and I've to manually do a rootNode.setAttributeNS(null, "xmlns",
svgNS) to set the namespace correctly.

Now my question: Is there a more elegant solution to my problem? Am I
probably thinking too complicated here?

A further question would be if it's possible to generate SAX-events for a
SVGGraphics2D object. I'm currently converting the dom to sax events for
further transformations.

Thanks a lot!

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message