Re: [svg-developers] when or when not to DOM
hi, serverside line per line and templated based generation are probably best. regarding client side DOM manipulations with SVG there is no big difference in performence between 1) elem = document.createElement(elem_type); elem.setAttribute(NS,attr_1,val_1 [...] elem.setAttribute(NS,attr_n,val_n); doc.appendChild(elem); and 2) doc.appendChild(parseXML(elem_type attr1_1='val_1' [...] attr1_n='val_n'/,doc)); ressource demanding is only the DOM manipualtion itself and this is the append line in both cases. when not adding elements but changing them, long chains of getElementById(id).setAttribute(NS,attr,val) are often easier to write, but erasing, rebuilding and reappending it could be quicker. andré -- ___ andre m. winter, http://www.carto.net/ http://www.vectoreal.com/ http://tirolatlas.uibk.ac.at/ Brady, Phillip schrieb: Greetings everyone out there in SVG land! I have an SVG / XML / DOM question I was hoping maybe you folks could offer some opinions on. Basically it is simply when or when not to use DOM to manipulate XML (in this case SVG... but also generically speaking)? As an example, I put together a little application in which I am periodically (15 seconds) constructing an XML file for data output to other processes. I originally wrote this app building the xml file using the dom to create elements, append them, etc... piece by piece. This was also a simple educational process for me to learn about the dom. I then stepped back and looked at the output from the perspective of a simple text string and had the realization that I could create the same xml file much cleaner and simpler (in code at least) simply by building the file line by line, string by string... without using the dom at all... So, my question to you is this... in the context of building an xml file... what benefits does using the dom offer that simply constructing a text file does not? In case I didn't explain myself very well, let me offer an example. var dom; dom = new ActiveXObject(Microsoft.XMLDOM); dom.async = false; dom.validateOnParse = false; dom.resolveExternals = false; var node = dom.createProcessingInstruction(xml, version='1.0'); dom.appendChild(node); var root = dom.createElement(root); var attr = dom.createAttribute(created); var d = new Date(); attr.value = d.toLocaleString(); root.setAttributeNode(attr); dom.appendChild(root); just to create ?xml version=1.0? root created=Friday, September 17, 2004 12:45:20 PM/ versus var fso, tf; fso = new ActiveXObject(Scripting.FileSystemObject); tf = fso.CreateTextFile(c:\\test.xml, true); tf.WriteLine(?xml version=1.0?) ; tf.WriteLine(root created=Friday, September 10, 2004 12:45:20 PM/) ; tf.Close(); granted... I didn't actually run that code to verify my syntax on everything... but you get the idea... using dom it seems the process can get a bit convoluted versus simply outputting what you want the XML to be as a string. [Non-text portions of this message have been removed] - To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click edit my membership Yahoo! Groups Links Yahoo! Groups Sponsor ~-- $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM ~- - To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click edit my membership Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Re: [svg-developers] when or when not to DOM
Hello, My perspective may be a bit different than most. I started using XML around the time that the original 1.0 Recommendation became solid. Although I have used DOM, SAX, and other APIs to manipulate XML that I read, I have almost always used text output for writing. In some cases, I've built tools to enforce well-formed issues. The one place that I've used DOM-like approaches have been when my data closely conforms to the exact structure of the XML I'm sending. Since this is exceedingly rare (at least, in the work I've done), I normally don't bother. G. Wade On Fri, 17 Sep 2004 13:49:40 -0700 Brady, Phillip [EMAIL PROTECTED] wrote: Greetings everyone out there in SVG land! I have an SVG / XML / DOM question I was hoping maybe you folks could offer some opinions on. Basically it is simply when or when not to use DOM to manipulate XML (in this case SVG... but also generically speaking)? As an example, I put together a little application in which I am periodically (15 seconds) constructing an XML file for data output to other processes. I originally wrote this app building the xml file using the dom to create elements, append them, etc... piece by piece. This was also a simple educational process for me to learn about the dom. I then stepped back and looked at the output from the perspective of a simple text string and had the realization that I could create the same xml file much cleaner and simpler (in code at least) simply by building the file line by line, string by string... without using the dom at all... So, my question to you is this... in the context of building an xml file... what benefits does using the dom offer that simply constructing a text file does not? In case I didn't explain myself very well, let me offer an example. var dom; dom = new ActiveXObject(Microsoft.XMLDOM); dom.async = false; dom.validateOnParse = false; dom.resolveExternals = false; var node = dom.createProcessingInstruction(xml, version='1.0'); dom.appendChild(node); var root = dom.createElement(root); var attr = dom.createAttribute(created); var d = new Date(); attr.value = d.toLocaleString(); root.setAttributeNode(attr); dom.appendChild(root); just to create ?xml version=1.0? root created=Friday, September 17, 2004 12:45:20 PM/ versus var fso, tf; fso = new ActiveXObject(Scripting.FileSystemObject); tf = fso.CreateTextFile(c:\\test.xml, true); tf.WriteLine(?xml version=1.0?) ; tf.WriteLine(root created=Friday, September 10, 2004 12:45:20 PM/) ; tf.Close(); granted... I didn't actually run that code to verify my syntax on everything... but you get the idea... using dom it seems the process can get a bit convoluted versus simply outputting what you want the XML to be as a string. [Non-text portions of this message have been removed] Yahoo! Groups Sponsor ~-- Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/1U_rlB/TM ~ - - To unsubscribe send a message to: [EMAIL PROTECTED] visit http://groups.yahoo.com/group/svg-developers and click edit my membership Yahoo! Groups Links -- Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories? Yahoo! Groups Sponsor ~-- Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/1U_rlB/TM ~- - To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click edit my membership Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/