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

40558Re: MSXML parser

Expand Messages
  • gistobias
    Mar 2, 2004
    • 0 Attachment
      Extraordinarily fast reply Mathias!

      Of course, here are all the files i use

      =============================================================
      mainSVG.svg
      =============================================================
      <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
      <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG
      1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
      <svg version="1.1" id="main" xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink" onload="init(evt)">
      <script type="text/ecmascript" xlink:href="svgTest.js"/>
      <title>
      Test
      </title>
      <desc>
      Test of GetUrl, parseXml, appendNode
      </desc>
      <rect id="button" onclick="klickB(evt)" fill="black" stroke="red"
      line-width="4" x="0" y="0" width="100" height="100"/>
      </svg>

      =============================================================
      svgTest.html
      =============================================================
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
      4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>SVG-Test</title>
      <script src="svgTest.js"></script>
      </head>
      <body leftmargin="0" topmargin="0" rightmargin="0"
      bottommargin="0" marginwidth="0" marginheight="0">
      <embed src="mainSVG.svg" name="svgTest" width="100%"
      height="100%" type="image/svg-xml"
      pluginspage="http://www.adobe.com/svg/viewer/install/"></embed>
      </body>
      </html>

      =============================================================
      svgTest.js
      =============================================================
      var svgDoc;
      var xmlDoc;

      var SVGNS = "http://www.w3.org/2000/svg";
      var XLINKNS = "http://www.w3.org/1999/xlink";

      function init(evt){
      svgDoc=evt.target.ownerDocument;
      }

      function klickB(evt){
      loadExt("http://www.student.lu.se/~mat99tle/SVG/test.svg");
      }

      function loadExt(testUrl){
      xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
      var nodeList;
      var currNode;
      xmlDoc.async = false;
      xmlDoc.resolveExternals = false;
      xmlDoc.validateOnParse = false;
      xmlDoc.load(testUrl);
      if(xmlDoc.parseError.errorCode != 0){
      var myErr = xmlDoc.parseError;
      alert("You have error " + myErr.reason);
      }else{
      var externalSvg = svgDoc.createElementNS(SVGNS, "svg");
      externalSvg.setAttribute("id", "dynamic");
      externalSvg.setAttribute("x", "101");
      externalSvg.setAttribute("y", "1");
      externalSvg.setAttribute("width", "100");
      externalSvg.setAttribute("height", "100");
      externalSvg.setAttribute("viewbox", "0 0 100 100");
      svgDoc.getElementById("main").appendChild(externalSvg);
      objNodeList = xmlDoc.documentElement.childNodes;
      for(var i=0; i<objNodeList.length; i++){
      svgDoc.getElementById("dynamic").appendChild
      (objNodeList.item(i));
      }
      svgDoc.getElementById("pathElement").setAttribute
      ("fill", "green");
      }
      }

      function mouseOverRects(evt){
      var targetId=evt.getTarget().getAttribute("id");
      if(targetId=="rect1" || targetId=="rect2"){
      document.getElementById("group2").setAttribute
      ("fill", "green");
      }
      }

      =============================================================
      test.svg
      =============================================================
      <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
      <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG
      1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
      <svg width="100%" height="100%" version="1.1" viewBox="0 0 100 100"
      xmlns="http://www.w3.org/2000/svg" onmouseover="mouseOverRects(evt)">
      <script type="text/ecmascript">
      <![CDATA[
      function mouseOverRects(evt){
      var targetId=evt.getTarget().getAttribute("id");
      if(targetId=="rect1" || targetId=="rect2"){
      document.getElementById("group2").setAttribute
      ("fill", "green");
      }
      }
      ]]>
      </script>
      <desc>Two gruops of two rectangles (squares) each
      </desc>
      <g id="group1" fill="red">
      <rect id="rect1" x="20" y="20" width="20" height="20"/>
      <rect id="rect2" x="60" y="20" width="20" height="20"/>
      </g>
      <g id="group2" fill="blue">
      <rect id="rect3" x="20" y="60" width="20" height="20"/>
      <rect id="rect4" x="60" y="60" width="20" height="20"/>
      </g>
      <!--Mark the outer boundry with a square-->
      <path id="pathElement" d="M1 1L98 1L98 98L1 98Z" fill="none"
      stroke="blue" stroke-width="1"/>
      </svg>

      =============================================================


      --- In svg-developers@yahoogroups.com, "Mathias FATENE"
      <mathias.fatene@w...> wrote:
      > Can you give me a complete example please (code, xml file ...) ?
      >
      > Mathias
    • Show all 15 messages in this topic