I don't get why I have a namespace problem.

The string representing the doc is created in the server side like this


 private static String formatDoc(SVGDocument doc) throws IOException {

StringWriter stringWriter = new StringWriter();

org.apache.batik.dom.util.DOMUtilities.writeDocument(doc, stringWriter);

stringWriter.flush();

stringWriter.close();

return stringWriter.toString();

}



 public String getSvgDocument() throws RemoteException {

try {

return formatDoc(getCanvas().getSVGDocument());

} catch (IOException e) {

throw new RemoteException("could not format the document",e);

}

}


Why it does not contain the namespaces when I reread the string?does the
writeDocument is not the right way to serialize a document?

And by talking about the DocumentFactoryImplementation, you
mean org.apache.batik.dom.svg.SAXSVGDocumentFactory ?

By the way, thank's for the several answers or directions you often give to
me, they have largely contributed to my project.

On Mon, Dec 28, 2009 at 4:14 PM, <[email protected]> wrote:

> Hi Dao,
>
> dao <[email protected]> wrote on 12/28/2009 07:12:30 AM:
>
> > I get This exception
> >
> > java.lang.ClassCastException: org.apache.batik.dom.GenericElement
> > cannot be cast to org.w3c.dom.svg.SVGSVGElement
> > at org.apache.batik.dom.svg.SVGOMDocument.getRootElement
> > (SVGOMDocument.java:233)
>
>     Almost certainly this is a problem with namespaces (so your
> root element might be an svg element but not an svg:svg element).
>
>     Also you aren't using our DocumentFactory implementation,  this
> is at least a performance hit.
>
> > When I do this, it is all right. What's wrong?
> >
> > public CanvasProxy(long fps, String rmiRegistryLocation) throws
> > NotBoundException, ParserConfigurationException, SAXException,
> IOException {
> > connect(rmiRegistryLocation);
> >         canvas = new JSVGCanvas();
> > canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> > canvas.setURI(remoteEngine.getSvgDocumentURI().toString());
> > --
> > Dao Hodac
>



-- 
Dao Hodac

Reply via email to