Re: XSLT and DTD
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
On Apr 9, 10:02 am, Martin Honnen <[email protected]> wrote: > [email protected] wrote: > > href=document.location.href; > > xslprocessor.importStylesheet(xslhttprequest.responseXML); > > xslprocessor.setParameter(null,"uri",href); > > xhtml=xslprocessor.transformToFragment(xmlhttprequest.responseXML,document); > > while(document.hasChildNodes())document.removeChild(document.lastChild); > > document.appendChild(xhtml.firstChild);document.close > > document.close is a method so if you wanted to call it you would need > document.close() > However I don't see why you would need to call document.close() as you > don't use document.write() anywhere. > As for inserting the fragment child nodes into the document I think you want > document.appendChild(xhtml); > as that appends all children of the fragment into the document. If you > have a DOCTYPE node and a root element in the fragment then doing only > document.appendChild(xhtml.firstChild); > will only insert the DOCTYPE node into the document but not other nodes > (like the root element). > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/ Martin Thanks for your reply. I agree with both of your points but after modifying the js as follows if (xslhttprequest.status==200 || xslhttprequest.status==0) { href = document.location.href; xslprocessor.importStylesheet(xslhttprequest.responseXML); xslprocessor.setParameter(null, "uri", href); xhtml=xslprocessor.transformToFragment(xmlhttprequest.responseXML,document); // Replace HTML page with XHTML //This works in Mozilla (not with DTD) and Opera and Apollo while (document.hasChildNodes()) { document.removeChild(document.lastChild); } document.appendChild(xhtml); } For <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="build_page.js" type="text/javascript"></script> </head> <body onload="transform('canobie_series');"> test </body> </html> Firefox 2.0 renders it in quirk mode but for <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/TR/xthml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="build_page.js" type="text/javascript"></script> </head> <body onload="transform('canobie_series');"> test </body> </html> Firefox 2,0 does not render it in normal mode where the xslt is the same and has the following xsl:output <xsl:output method="xml" version="1.0" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="no"/> in both cases Changing the xsl:output method to "html" makes no different in either case in that the one without the DTD renders and the one with does not. John Perkins