scripting nested svg documents

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • flosi

    scripting nested svg documents

    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
  • Martin Honnen

    #2
    Re: scripting nested svg documents



    flosi wrote:

    [color=blue]
    > 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 ?[/color]

    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
    The World Wide Web Consortium (W3C) is an international community where Member organizations, a full-time staff, and the public work together to develop Web standards.

    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.

    --

    Martin Honnen

    Comment

    • Jim Ley

      #3
      Re: scripting nested svg documents

      On 30 Nov 2004 07:18:01 -0800, juergen.flosbac h@bigfoot.com (flosi)
      wrote:
      [color=blue]
      >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 ?[/color]

      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.

      Comment

      • flosi

        #4
        Re: scripting nested svg documents

        jim@jibbering.c om (Jim Ley) wrote in message news:<41acb04b. 504729823@news. individual.net> ...[color=blue]
        > On 30 Nov 2004 07:18:01 -0800, juergen.flosbac h@bigfoot.com (flosi)
        > wrote:
        >[color=green]
        > >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 ?[/color]
        >
        > 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.[/color]

        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

        Comment

        Working...