Hi George,

George Armhold wrote:

Can someone please explain the difference between Element.setAttribute
and Element.setAttributeNS(), as it affects Batik?  My code loads a
document into the canvas and performs various modifications to the DOM,
adding various <g>, <rect> and <line> Elements.  I notice that through
accretion, my code is using all of the following in various places:

  e.setAttribute(attribName, attribValue);
  e.setAttributeNS(svgNS, attribName, attribValue);
  e.setAttributeNS(null, attribName, attribValue);

Wow! :)


It seems that some attribs need the SVG namespace (e.g. the xml "id"
attrib.)  Others are happy with no namespace (<line> x/y coords.)  Yet
others seem to need the null namespace (the width/height of the <svg>
element.)  Are there some general rules about when & how to supply a
namespace for attributes?

I think you have fooled your self. For all intents and purposes _nothing_ uses e.setAttributeNS(svgNS, ...) - I don't know where you got the impression you needed to do this for 'id' you do not. For the 'href' attribute (use, image, etc) you must use setAttributeNS(xlinkNS, "href", ...) - this is closely related to 'id' perhaps this confused you?

    In Batik setAttribute(attribName, attribValue) is exactly the
same as setAttributeNS(null, attribName, attribValue).

    Vincent tells me that the "correct" one of setAttribute vs
setAttributeNS(null...) is setAttributeNS(null,...) [I am not as
sure since in some bindings there may be no 'null' value for
DOMString - i.e. C++].

    If you can provide a small reproducible example to the contrary
I would be very interested in seeing it but I do a fair amount of
this stuff and I always just use 'setAttribute' (except of course
for 'xlink:href').




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



Reply via email to