explaining baseVal and SVG DOM

In working through Erik D's comments upon the book I'm working on, he
observes how an
alternative to document.getElementById("R").getAttribute("height") might
be document.getElementById("R").height.baseVal.value

I confess to being a bit ignorant of any reasons for preferring or not
the use of baseVal, but am considering including text such as the
following to describe the situation:

-----------------sample text---------------begin by setting
context---------
We then display the id property of that node:

document.getElementById("R").id 
which, not surprisingly, ends up being "R".

Of all the properties associated with a node, we may note that most
attributes cannot be referenced in this manner (reminiscent of HTML
DOM1). For example, the expression

document.getElementById("R").height 
is meaningless. Instead, we use

document.getElementById("R").getAttribute("height")
as the way to retrieve ordinary attributes associated with an SVG
object. Specifically, the command

alert(document.getElementById("R").getAttribute("height")) 
produces, as output, the string "30".


----------now to the relevant part ----------------
An alternative approach is worth mentioning: 

document.getElementById("R").height.baseVal.value 

As discussed at (http://www.w3.org/TR/SVG/svgdom.html ), the SVG DOM
methods allow alternative ways, beyond what is typically available in
generic XML for interrogating DOM. Given the nature of differences
between the rendered page and mark-up, in part, no doubt, due to
animation, these methods are frequently recommended. As I understand it,
baseVal represents something resembling a virtual presence of the node
in the SVG DOM, separate from its actual rendering. The topic is, at
present, a bit beyond the scope of this book (though I am hoping another
contributor might write a section about them). In the meantime, I
recommend reading about the animation sandwich model in the SMIL
animation spec
(http://www.w3.org/TR/smil-animation/#AnimationSandwichModel) that
offers an exploration of the use of base values.

------------end sample text---------

The question for you folks: given that I don't (for now)  want to create
a new section in the book, does the above text gloss over the details
adequately and (more importantly) accurately?

The book currently does not cover several topics (as I mentioned before,
I'm keeping a list in the "afterword" of sections that I'm hoping to
find authors for -- see
http://srufaculty.sru.edu/david.dailey/cs427/StateOfArt-Dailey.html#Afte
rword ) including shadow trees (which are somewhat similar to baseVal?).



Cheers
David

Received on Friday, 10 April 2009 16:41:36 UTC