Hello,

I want to include an inline SVG (created with Batik) into an XHTML page (via a custom JSF component). Unfortunately there is an XML Declaration (something like <?xml version="1.0" encoding="utf-8"?>) at the beginning of the SVG output of SVGGraphics2D.stream() which is not allowed inside an XHTML document (except in the first line of the doc of course).

Is there an easy way to prevent the XML Declaration from getting written to the stream? I can't find an easy way to do so. What I am doing now is a time-consuming identity transformation of the SVG with the xsl-output parameter omit-xml-declaration set to "yes".

Here is a sample code (without the identity transformation workaround)

public void encodeBegin(FacesContext context)
    throws SVGGraphics2DIOException {

    ResponseWriter writer = context.getResponseWriter();
    DOMImplementation domImpl = GenericDOMImplementation
        .getDOMImplementation();
    Document document = domImpl.createDocument(
        SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);

    SVGGraphics2D g = new SVGGraphics2D(document);
    g.setSVGCanvasSize(new Dimension(180, 50));
    Shape circle = new Ellipse2D.Double(0, 0, 50, 50);
    g.fill(circle);

    g.stream(writer, true);

}

Thank you,
Kai

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

Reply via email to