I wrote:
> It seems that the SVG generator doesn't actually output any processing
> instructions it comes across.  You could add this support pretty easily
> by modifying org/apache/batik/svggen/XmlWriter.java to add a method to
> write the PIs:

Ok, so it seems it's not so simple.  The SVGGraphics2D object will just
copy over the document element from the generated SVG tree to be
serialized.  You could, as well as the other changes I mentioned, change
the line in SVGGraphics2D.stream(Element, Writer, boolean) that says
this:

  svgDocument.appendChild(svgRoot);

with this:

  if (rootParent == null) {
      for (Node n = svgRoot.getOwnerDocument().getFirstChild();
              n != null; n = n.getNextSibling()) {
          int t = n.getNodeType();
          if (t == Node.ELEMENT_NODE) {
              svgDocument.appendChild(n);
          }
          if (t == Node.PROCESSING_INSTRUCTION_NODE) {
              svgDocument.appendChild(n.cloneNode(false));
          }
      }
  } else {
      svgDocument.appendChild(svgRoot);
  }

It's a bit hackish, but should work.  If you were serializing only a
subtree of the generated document, though, the PIs wouldn't get written
out.  (But I'm not sure that you would want them there anyway.)

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

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

Reply via email to