Read SVG (using JavaScript) H - E- L - P ! ! !

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

    Read SVG (using JavaScript) H - E- L - P ! ! !

    How can I use EXTERNAL JavaScript code to read (and modify) an SVG
    file/object? Can JavaScript do this or do I have to resort to Batik?

    IMPORTANT NOTE:
    The JavaScript code CANNOT be embedded in the SVG file, because it is
    server-side generated.

    Thank You


    - Olumide

  • Jason Davis

    #2
    Re: Read SVG (using JavaScript) H - E- L - P ! ! !

    Olumide wrote:[color=blue]
    > How can I use EXTERNAL JavaScript code to read (and modify) an SVG
    > file/object? Can JavaScript do this or do I have to resort to Batik?
    >
    > IMPORTANT NOTE:
    > The JavaScript code CANNOT be embedded in the SVG file, because it is
    > server-side generated.
    >
    > Thank You
    >
    >
    > - Olumide
    >[/color]

    Do you need to save the modifications? If not, just load it like any
    other XML document (through XmlHttpRequest( ) or createDocument( ) and
    document.load() ), and use the DOM to manipulate it.

    -Jason Davis

    Comment

    • Steve Slatcher

      #3
      Re: Read SVG (using JavaScript) H - E- L - P ! ! !

      Olumide wrote:[color=blue]
      > How can I use EXTERNAL JavaScript code to read (and modify) an SVG
      > file/object? Can JavaScript do this or do I have to resort to Batik?[/color]

      I have an example of reading and rendering VML using JavaScript, which you
      may find helpful: http://www.stirbitch.com/steve/smml/index.html


      Comment

      • Olumide

        #4
        Re: Read SVG (using JavaScript) H - E- L - P ! ! !

        [color=blue]
        >
        > ... just load it like any
        > other XML document (through XmlHttpRequest( ) or createDocument( ) and
        > document.load() ), and use the DOM to manipulate it.[/color]



        Thanks Jason, I will look into this. The problem however is that I have
        a multiframe document that looks like this:


        |-----------------------------------------------|
        | | |
        | | |
        | | |
        | | |
        | Left Frame | Right Frame |
        | [SVG] | |
        | | |
        | | |
        | | |
        | | |
        | | |
        | | |
        | | |
        |-----------------------------------------------|

        The Left Frame is an SVG object while the Right Frame is a an HTML
        document with JavaScript code in its head section. My intention is to
        have the SVG object (in the left frame) modified by the javascript code
        in the right frame. (The HTML document in the right frame is server-side
        generated.)


        Er ... can document.load() still "load" the SVG document even though it
        is already loaded in the left frame?

        Thanks


        - Olumide

        Comment

        • Jason Davis

          #5
          Re: Read SVG (using JavaScript) H - E- L - P ! ! !

          Can't you just go:

          top.leftframena me.document

          And reference the SVG document that way? With the Adobe SVG Viewer you
          might have to rely on method calls (I don't have much experience with
          the ASV DOM implementation) , but in Mozilla you should be able to access
          the SVG document like that, and use standardized DOM interfaces (DOM2
          Core and the SVG DOM for example) to manipulate it on the fly.

          -Jason Davis

          Olumide wrote:[color=blue]
          >[color=green]
          >>
          >> ... just load it like any other XML document (through XmlHttpRequest( )
          >> or createDocument( ) and document.load() ), and use the DOM to
          >> manipulate it.[/color]
          >
          >
          >
          >
          > Thanks Jason, I will look into this. The problem however is that I have
          > a multiframe document that looks like this:
          >
          >
          > |-----------------------------------------------|
          > | | |
          > | | |
          > | | |
          > | | |
          > | Left Frame | Right Frame |
          > | [SVG] | |
          > | | |
          > | | |
          > | | |
          > | | |
          > | | |
          > | | |
          > | | |
          > |-----------------------------------------------|
          >
          > The Left Frame is an SVG object while the Right Frame is a an HTML
          > document with JavaScript code in its head section. My intention is to
          > have the SVG object (in the left frame) modified by the javascript code
          > in the right frame. (The HTML document in the right frame is server-side
          > generated.)
          >
          >
          > Er ... can document.load() still "load" the SVG document even though it
          > is already loaded in the left frame?
          >
          > Thanks
          >
          >
          > - Olumide
          >[/color]

          Comment

          • Olumide

            #6
            Re: Read SVG (using JavaScript) H - E- L - P ! ! !


            Jason Davis wrote:
            [color=blue]
            > Can't you just go:
            >
            > top.leftframena me.document
            >
            > And reference the SVG document that way? With the Adobe SVG Viewer you
            > might have to rely on method calls (I don't have much experience with
            > the ASV DOM implementation) , but in Mozilla you should be able to access
            > the SVG document like that, and use standardized DOM interfaces (DOM2
            > Core and the SVG DOM for example) to manipulate it on the fly.[/color]



            Can anyone provide a hint or (web) link showing how this can be done?

            Thanks

            - Olumide

            Comment

            Working...