Hi,

 

I've tried playing with the namespaces I use, but still get various errors.

 

Can I confirm what the correct namespaces to use are:

 

--------------------------------------------------------------

 

I create my SVG document using:

 

SVGDocument doc = (SVGDocument) impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);

 

--------------------------------------------------------------

 

Within the document I create SVG Elements using, for example:

 

createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"rect");

 

--------------------------------------------------------------

 

And I set attributes on those elements using, for example:

 

element.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke", "red");

 

This all seems to work fine.

 

--------------------------------------------------------------

 

With my own defined shapes I use the following:

 

            Element defs = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, SVG12Constants.SVG_DEFS_TAG);

 

            Element path_star_filled = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, SVG12Constants.SVG_PATH_TAG);

            path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"id", STAR_FILLED);

            path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke-width", "0.3");

            path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke", "black");

            path_star_filled

                        .setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"d",

                                    "M0,0.9 -0.2205,0.27 -0.9,0.27 -0.3645,-0.144 -0.63,-0.9 0,-0.432 0.63,-0.9 0.36,-0.144 0.9,0.27 0.2205,0.27,z");

            defs.appendChild(path_star_filled);

           

 

--------------------------------------------------------------

 

And when I make a call to use one of my defined elements I use the following:

 

            Element plotCh = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,SVG12Constants.SVG_USE_TAG);

            plotCh.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"xlink:href", "#" + type);

     

            plotCh.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"width", new Double(w).toString() + "%");

 

--------------------------------------------------------------

 

Am I using the wrong name space for my defined elements? Im not sure if its in the definition, or the calling of my definition, or both?

 

Thanks in advance for any help,

 

Gratefully,

Dylan

 

Reply via email to