Loading ...
Sorry, an error occurred while loading the content.

XML data islands in IE (and others) for SVG??

Expand Messages
  • David Dailey
    A recent discussion in the HTML WG about how to make SVG and MathML and other XML languages coexist with where the WHATWG/HTMLWG would like HTML5 to go, got me
    Message 1 of 52 , Apr 1, 2008
    • 0 Attachment
      A recent discussion in the HTML WG about how to make SVG and MathML
      and other XML languages coexist with where the WHATWG/HTMLWG would
      like HTML5 to go, got me wondering:

      there is that goofy <xml> tag in IE (so far as I know it is only in
      IE) that allows "data islands" in which XML can be incorporated into
      HTML. I wondered a) whether anybody has experimented with those as an
      alternative way of getting SVG into HTML in IE, since it would allow,
      in theory, a type of inline content?

      b) whether this might provide a broader solution to some of the
      gnarly cross browser issues involved in getting html with ist lax
      grammar to allow SVG snippets (with their tighter grammar) to work
      and play nicely together. (Apparently this is difficult for browser
      makers to figure out.)

      So I tried the following little experiment (conclusions and questions
      to follow):

      <html>
      <head>
      <title>Including SVG data in an HTML document</title>
      <script>
      function display(){
      D=document.getElementById("ChunkOfSVG")
      R=D.firstChild.firstChild.nextSibling

      EM=document.getElementById("E")
      SVE=EM.getSVGDocument()
      DE=SVE.documentElement

      RT=SVE.createElement("text")
      RT.setAttribute("x",40)
      RT.setAttribute("y",60)
      RT.setAttribute("font-size","20")
      TT=SVE.createTextNode(R.firstChild.nodeValue);
      RT.appendChild(TT)
      DE.appendChild(RT)
      //the above works fine

      //the below doesn't
      RC=R.cloneNode("true")
      alert(RC.nodeName) //this identifies the nodeName of the
      clone as being <text>
      DE.appendChild(RC) //this fails

      }
      </script>
      </head>

      <body><input type=button onclick="display()" value="display">
      <xml id="ChunkOfSVG">
      <svg>
      <rect width="100%" height="100%" fill="#888"/>
      <text x="100" y="30" font-size="35px" font-family="Impact" fill="#706">
      Hello from SVG data island</text>
      </svg>
      </xml><div align="center">
      <embed id="E" width="400" height="400" src="../svg/empty.svg" />

      </body>

      1. The data island is indeed retrievable and the above succeeds in
      scribbling content from it back into the embedded SVG document.

      2. Trying to clone the textnode from the data island and insert it
      into the SVGdocument directly, just didn't work. Any reasons you can
      think of? Any workarounds?

      3. This doesn't work if the document empty.svg does not in fact
      exist. Does anyone know a way in IE to make an HTML document contain
      an SVGDocument that is entirely built from scratch -- namely without
      starting with a real second file -- without resorting to the arcania
      that is inline SVG in IE?

      4. Is there anyway to replace the entire DOM tree of the SVG document
      by the DOM tree discovered in the data island?

      5. If there were ways to do this, would wrapping inline SVG inside an
      <xml> for IE and then stripping the <xml> for the other browsers
      provide any sort of solution to the inlining problem?

      cheers,
      David
    • Frank Bruder
      Hi, Sujana, have you seen this post: http://tech.groups.yahoo.com/group/svg-developers/message/60214 Looks to me like Bruce Rindahl already has a solution for
      Message 52 of 52 , Apr 5, 2008
      • 0 Attachment
        Hi, Sujana,
        have you seen this post:
        http://tech.groups.yahoo.com/group/svg-developers/message/60214

        Looks to me like Bruce Rindahl already has a solution for what you
        are trying.

        Regards
        Frank


        --- In svg-developers@yahoogroups.com,
        "sujana_jyothi" <sujana_jyothi@...> wrote:
        >
        > Hi Helder Magalhães,
        > Thanks for your code snippet. I still havent tried out if it
        works
        > or not. I will try it and will get back to you. And apologies if my
        > previous message was abrupt. I thought, I did speak in a requesting
        > way and I did say "please suggest me".......
        >
        > Anyways, Thanks once again....
        > Sujana.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.