Hello

I am trying to figure out the easiest way to take the result of an XSL transformation, through Batik, then send the resulting PNG file to a web client. I am currently making the XSL result a SVGDocument like this:

DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
Document document = impl.createDocument(
SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
Element root = document.getDocumentElement();
javax.xml.transform.dom.DOMResult result = new DOMResult(root);


The result of my translation looks like this:

    <svg:svg xmlns:svg="http://www.w3.org/2000/svg";
        width="185"
        height="100"
        viewBox="0 0 185 100">
        <svg:title>Market Indices Chart</svg:title>
        ...
    </svg:svg>

The resulting SVGDocument looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <svg xmlns="http://www.w3.org/2000/svg";
        xmlns:xlink="http://www.w3.org/1999/xlink";
        contentScriptType="text/ecmascript"
        zoomAndPan="magnify"
        contentStyleType="text/css"
        preserveAspectRatio="xMidYMid meet"
        version="1.0">
        <svg:svg xmlns:svg="http://www.w3.org/2000/svg";
            width="185"
            height="100"
            viewBox="0 0 185 100">
            <svg:title>Market Indices Chart</svg:title>
            ...
        </svg:svg>
    </svg>

SVGDOMImplementation.createDocument obviously creates the root node and the XSL translation results are put inside of it. Is there a better way to do this? TranscoderInput says that it takes a org.w3c.dom.Document but I get the following error when I try to pass in a Xerces DOM tree:

org.w3c.dom.DOMException: The current node (type: 9, name: #document) do not allow children of the given type (type: 1, name: svg:svg)
at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)
at org.apache.batik.dom.AbstractDocument.checkChildType(Unknown Source)
at org.apache.batik.dom.AbstractParentNode.checkAndRemove(Unknown Source)
at org.apache.batik.dom.AbstractParentNode.insertBefore(Unknown Source)
at org.apache.batik.dom.util.DOMUtilities.deepCloneDocument(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at net.sf.colle.xml.BatikPlugin.finalizeResult(BatikPlugin.java:132)
at net.sf.colle.xml.Transformation.transform(Transformation.java:407)
at net.sf.colle.web.Context.transform(Context.java:509)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.colle.web.KnownManager.service(KnownManager.java:158)
at net.sf.colle.web.ControlServlet.service(ControlServlet.java:128)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationH andler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java: 567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1776)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationCon text.java:514)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1726)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java: 196)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:487)


Dwayne


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to