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

RE: [svg-developers] Re: MSXML parser

Expand Messages
  • Mathias FATENE
    Hi ola, The week-en dis finishing. So i come with my suggestion (solution) as promised. ... SVG-Test
    Message 1 of 15 , Mar 7, 2004
      Hi ola,
      The week-en dis finishing. So i come with my suggestion (solution) as
      promised.

      --------------------------------- svgTest.html ===================
      <html>
      <head>
      <title>SVG-Test</title>
      <script type="text/javascript" src="svgTest.js"></script>
      </head>
      <body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"
      marginwidth="0" marginheight="0">

      <embed src="mainSVG.svg" width="1200" height="1200"
      pluginspage="http://www.adobe.com/svg/viewer/install/">
      </embed>

      </body>
      </html>

      ---------------------------------- mainSVG.svg ==============
      <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
      <?AdobeSVGViewer save="snapshot"?>
      <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/javascript" 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"/>

      <g id="dynamic">

      </g>
      </svg>

      -------------------------------- Test.svg
      <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
      <svg id="main2" width="100%" height="100%" version="1.1" viewBox="0 0 1000
      1000"
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      onmouseover="mouseOverRects(evt)">
      <script type="text/ecmascript" xlink:href="svgTest.js"/>
      <script type="text/javascript">
      <![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>

      ------------------------------------ svgTest.js (Here don't forget to change
      loadExt("./test.svg");) =============
      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("./test.svg");
      }

      function loadExt(testUrl){
      var nodeList;
      var currNode;
      try {
      // create an ActiveX object and load the data sheet
      xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
      xmlDoc.async = false;
      xmlDoc.resolveExternals = false;
      xmlDoc.validateOnParse = false;
      }
      catch (e) {
      alert(e.description);
      }
      if (xmlDoc != null){
      try {
      xmlDoc.load(testUrl);
      }
      catch (e) {
      alert(e.description);
      }
      }

      alert("Mathias gotten code :\n\n"+xmlDoc.xml)
      var externalSvg = svgDoc.createElementNS(SVGNS, "svg");
      externalSvg.setAttribute("id", "dynamic");
      externalSvg.setAttribute("x", "201");
      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.xml;
      var node=parseXML(objNodeList,document)
      svgDoc.getElementById("main").appendChild(node)
      // 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");
      }
      }

      ============================== E N D =====================

      Hope that help.
      I can suggest getURL/parseXML which are similar and faster.

      Mathias

      -----Original Message-----
      From: Tobias Lennartsson [mailto:ola_tobias@...]
      Sent: Thursday, March 04, 2004 10:54 PM
      To: svg-developers@yahoogroups.com
      Subject: [svg-developers] Re: MSXML parser


      I can wait, I'd really appreciate it!

      Thanks!

      /Tobias

      --- In svg-developers@yahoogroups.com, "Mathias FATENE"
      <mathias.fatene@w...> wrote:
      > Sorry,
      > i didn't have time to finish my suggestions.
      > The work is the section :
      > objNodeList = xmlDoc.documentElement.childNodes;
      > ...
      > ...
      > > -----
      > > To unsubscribe send a message to: svg-developers-
      > unsubscribe@yahoogroups.com
      > > -or-
      > > visit http://groups.yahoo.com/group/svg-developers and click "edit
      > my
      > > membership"
      > > ----
      > > Yahoo! Groups Links
      >
      >
      >
      >
      > -----
      > To unsubscribe send a message to: svg-developers-
      unsubscribe@yahoogroups.com
      > -or-
      > visit http://groups.yahoo.com/group/svg-developers and click "edit
      my
      > membership"
      > ----
      > Yahoo! Groups Links




      -----
      To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
      -or-
      visit http://groups.yahoo.com/group/svg-developers and click "edit my
      membership"
      ----
      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.