Hi everyone,

I should clarify that I am at the beginning of learning SVG and have
to fight with it's specialities. There are some things that I like
about SVG.

For instance, verbosity: You have the DOCTYPE and PUBLIC and xmlns and
script tags and script tag types and all that stuff. And if you get it
wrong, then your browser shows nothing. If we only want to use SVG 1.1
and JavaScript, why the confusion? I found out it can be much easier
with ASV 3+6. Opera doesn't show much (only the Text itself, as if it
were xml), and I never got Mozilla's SVG to show any SVG. I'm too lazy
to try out all possible combinations, I know. But I'd like the browser
to at least try to show something. I don't like ASV, but it does well
there.

Another one, clarity: You look at some code and you think you
perfectly know what it's doing. Right?

For instance, you'll immediately know what this does:

nodes.es:

function replacetext(evt) {
    nodes=window.svgDocument.getElementById("sampletext").childNodes;
    len=nodes.length;

    for (i=0; i<len; i++)
        nodes.item(i).data="node "+i;
}

nodes.svg:

<?xml version="1.0"?>
<svg onload="replacetext(evt)" >
    <script xlink:href="nodes.es" />
    <text id="sampletext" y="20">
        <tspan x="5" dy="1em">line 1</tspan>
        <tspan x="5" dy="1em">line 2</tspan>
        <tspan x="5" dy="1em">line 3</tspan>
    </text>
</svg>


(By the way, I wanted to put this into one file instead of two, but
then I would have had to know this strange CDATA syntax... Who on
earth invented that?)

You'll expect that the script would change the lines

line 1
line 2
line 3

into the lines

node 1
node 2
node 3

and you'll expect that len is 3, right? No. that's what it shows:

node 0
 line 1node 2
 line 2node 4
 line 3node 6

and len will be 7 in the end. Note the extra node 0 and the
concatenated old and new text of the tspan's.

To get the desired result, you have to do some magic stuff which I
didn't find out yet or delete the text between the <tspan> and
</tspan> tags and change the for loop to 

for (i=2; i<len; i+=2)
    nodes.item(i).data="node "+i/2;

I understand that the tspan tags are children of the text tag, but
this doesn't explain why there are seven childNodes of the text and I
can't seem to descent more down the tree with
childNodes.item(i).childnodes.

I've bought books about SVG and Javascript, but it appears I have to
also buy books about the DOM, and style sheets and... And what else?

Thanks for listening, the SVG Developers group is a great group with
some really helpful people! And yes, I'll fight through it! One day,
I'll understand, I'm sure!

Willem




-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to