Hi Cameron

Thanks for your quick reply. 

Your latest code correctly adds the pi before the SVG node. However, it
appears that the elements that were added through the DOMGroupManager are no
longer being written out.
DOMTreeManager dtm =  svgGen.getDOMTreeManager();
DOMGroupManager dgm = new DOMGroupManager(new GraphicContext(), dtm);
dgm.addElement(imageElement);

this used to work. Any ideas what could be the cause?

Regards

Daniel


-----Original Message-----
From: Cameron McCormack [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 15, 2004 3:29 AM
To: [EMAIL PROTECTED]
Subject: Re: Adding a proccessing instruction

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]

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

Reply via email to