André, > no, you need the importNode() thing, otherwise FF3 (all kinds: alpha and > beta and definitive) will not append your content. it doesn't harm FF2 > because FF2 already supports this method. i expect opera to do it too.
I take your word for it and I confirm that Opera does it. So I get this: addDoc(evt,document.importNode (xmlRequest.responseXML.documentElement,true)); and it works both local and remote (FF 2 and 3, Opera 9.2 and Safari) simply with if (xmlRequest.status == 200) disabled. Here the very last visible difference between the two routines is the event passing, and, by Jove, it just comes to my mind!... something I read a while back on an Ajax developers list that explained why passing the event was necessary. But that's all I can recall and I didn't take note, I just applied the mod. > your loop through the imported XML isn't needed because you don't > necessarily need an <svg>-element, you can also import fragments (they > just need to be consistent, closed elements and so on) The loop is necessary for ASV because if the file has comments before the <svg> ASV returns "object Comment" for node (retested so to avoid red herrings. BTW, perhaps at this point red herrings should be classified as a known, existing and consumable species. Given the great number we catch we could be in business:)) and doesn't import. But I agree the condition should be extended to accept any valid fragment, or better, modified to just ignore the comments. I guess I'll keep it for the time being. Domenico --- In [email protected], "andre m. winter" <[EMAIL PROTECTED]> wrote: > > hi Domenico > > no, you need the importNode() thing, otherwise FF3 (all kinds: alpha and > beta and definitive) will not append your content. it doesn't harm FF2 > because FF2 already supports this method. i expect opera to do it too. > your loop through the imported XML isn't needed because you don't > necessarily need an <svg>-element, you can also import fragments (they > just need to be consistent, closed elements and so on) > > my question was about the xmlRequest.status. in an html environment it > shows 200, in local environment only 0. how to handle this in mixed > environments? > > andré > > > > I didn't know it could work in local mode, thanks! I tested and for > > me it works both local and remote with Opera AND FF. I'm using this > > slightly different routine: > > > > ... > > else if (window.XMLHttpRequest) { > > function XMLHttpRequestCallback() { > > if (xmlRequest.readyState == 4) { > > // if (xmlRequest.status == 200) { > > addDoc(evt,xmlRequest.responseXML.documentElement); > > // } > > } > > } > > var xmlRequest = null; > > xmlRequest = new XMLHttpRequest(); > > xmlRequest.overrideMimeType("text/xml"); > > xmlRequest.open("GET",url,true); > > xmlRequest.onreadystatechange = XMLHttpRequestCallback; > > xmlRequest.send(null); > > } > > } > > function addDoc(evt,node) { > > var newdoc = node; > > while (newdoc != null && newdoc.nodeName != "svg") { > > newdoc = newdoc.nextSibling; > > } > > if (newdoc == null) { > > alert("Cannot find <svg> element in " + node.parent.nodeName); > > return; > > } > > myDestination.appendChild(newdoc); > > } > > > > I only tested with Opera 9.24 and FF 2.0.0.10 > > > > The last parameter of: > > document.getElementById(myDestination).appendChild (document.importNode > > (myReq.responseXML.documentElement,true)); > > > > is omitted, but I'm not sure that is what makes it happen. Apart from > > that difference, one other I can see is "document.importNode" > > > > Domenico > > > > > > > > --- In [email protected], "andre m. winter" > > <ml.winter@> wrote: > > > >> hi, > >> > >> in firefox (2 & 3) the condition (myReq.status == 200) never gets > >> > > true > > > >> in a local, non-http environment. that's the reason why i don't use > >> > > it > > > >> when developping or teaching SVG as most of my students don't run a > >> webserver. so what's this condition about? any way to have a > >> > > generic > > > >> function that properly works both offline and online? below the > >> > > function > > > >> as it works in online mode. > >> > >> thank you for hints, > >> andré > >> > >> > >> > >> function myAddXML(myURL,myDestination,myEncoding){ > >> if (window.XMLHttpRequest) { > >> var myReq = new XMLHttpRequest(); > >> if(myReq) { > >> myReq.overrideMimeType('text/xml'); > >> myReq.open('GET', myURL, true); > >> myReq.onreadystatechange = function(){ > >> if (myReq.readyState == 4){ > >> if (myReq.status == 200){ // REMOVE FOR > >> > > LOCAL WORK > > > >> > >> document.getElementById(myDestination).appendChild > >> > > (document.importNode(myReq.responseXML.documentElement,true)); > > > >> > >> } > >> } > >> } > >> myReq.send(null); > >> } > >> return; > >> } else if (window.getURL){ > >> //... > >> } > >> } > >> > >> > >> -- > > > > > -- > ___________________________________________________________________ > andre m. winter, > cartography for internet and multimedia applications > schiessstand 4/1, a6091 goetzens, tyrol, austria > tel.: ++43.5234.32732 > http://www.vectoreal.com/ SVG consulting and development > http://www.geotrace.net/ geo-localized high quality photographs > http://www.carto.at/ print and online touristic map solutions > ----- 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/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> 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/

