Hi Dylan,
"Dylan Browne" <[EMAIL PROTECTED]> wrote on 05/30/2006 06:07:35
AM:
> Can I confirm what the correct namespaces to use are:
> impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg",
null);
> createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"rect");
These are good.
> element.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke",
"red");
This is wrong, all SVG attributes are in the 'null' namespace:
element.setAttributeNS(null, "stroke", "red");
> This all seems to work fine.
This is surprising Batik should ignore 'stroke' in the SVG
namespace...
> 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);
The above are fine, but all the setAttributeNS calls should be null:
path_star_filled.setAttributeNS(null, "id", STAR_FILLED);
path_star_filled.setAttributeNS(null,"stroke-width", "0.3");
path_star_filled.setAttributeNS(null,"stroke", "black");
path_star_filled.setAttributeNS(null,"d", "M0,0.9 [...], 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);
This is fine.
> plotCh.setAttributeNS
> (SVGDOMImplementation.SVG_NAMESPACE_URI,
> "xlink:href", "#" + type);
This needs to set the 'href' attribute in the
XLINK namespace (it's an xlink attribute).
import org.apache.batik.util.XMLConstants;
plotCh.setAttributeNS
(XMLConstants.XLINK_NAMESPACE_URI,
"xlink:href", "#" + type);
> plotCh.setAttributeNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI,"width", new Double(w).toString() + "%");
One again should be in 'null' namespace (SVG attribute).
> 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?
Your element stuff looks fine, but your attributes are
problematic.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]