scripting nested svg documents

F

flosi

I'm a greenhorn in SVG and javascripting but I'm learning by doing.
So, here my current problem question :

I have a svg document embedded in another svg document. I whant,
through functions in an external javascript file, manipulate objects
in either the child svg document or the parent document.
How do I get access to elements of the other document ?

Example : I have a document "A" containing X/Y - Axis and included
another svg document "B" with the graphs.

I whant now, as soon as the mouse cursor is over a graph in document
"B" the belonging lable which is located in the parent svg document
"A" to change color or size.

Or I whant the graph in "B" to start blinking as soon as the mouse is
over the lable in "A".

I don't know how cross document borders.

Can anyone give me a short exapmle to get me going ?

Juergen Flosbach
 
M

Martin Honnen

flosi wrote:

I have a svg document embedded in another svg document. I whant,
through functions in an external javascript file, manipulate objects
in either the child svg document or the parent document.
How do I get access to elements of the other document ?

I think with Adobe SVG viewer version 3.x you do not get access to
embedded document.
I don't know about other viewers.
In general I think the SVG 1.2 draft acknowledges that so far (that is
in SVG 1.0 and 1.1) the scripting of embedded documents has not been
addressed, as
http://www.w3.org/TR/SVG12/dom.html
says:
"There is an oversight in the SVG 1.0 DOM in that the SVGImageElement
interface does not allow access to the DOM of the image it refers to (if
that image is an SVG document)."
And then:
"To provide this functionality, SVG 1.2 adds a document attribute to
the SVGMedia interface, which is the Document interface of the
referenced meda, if one is available. It is unlikely that the SVG
specification will describe the format for the returned Document except
in the case of a referenced SVG image."
Thus if a viewer implements the current SVG 1.2 draft you would need to
access the <image> element and that should have a property named
document to access the embedded document.
 
J

Jim Ley

I have a svg document embedded in another svg document. I whant,
through functions in an external javascript file, manipulate objects
in either the child svg document or the parent document.
How do I get access to elements of the other document ?

As Martin said, you can't do this. In batik or ASV 6 preview you
could do it by having the 2nd document USE the part from the 2nd file,
but not in ASV3, so I'd stay away, why not just have a single file,
are you really saving much splitting it into two?

Jim.
 
F

flosi

As Martin said, you can't do this. In batik or ASV 6 preview you
could do it by having the 2nd document USE the part from the 2nd file,
but not in ASV3, so I'd stay away, why not just have a single file,
are you really saving much splitting it into two?

Jim.

Thanks. That helps me with my decision. I used batik all along and
batik doesen't have a problem with nested SVG documents. But the ASV3
has as you mentioned. So, I 'll put everything in one document and the
scripting will be easyer.

Thanks for the info.

Juergen Flosbach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top