Click to See Complete Forum and Search --> : Trouble Using XMLHttpRequest with XHTML in IE


billk
08-21-2005, 12:57 AM
Hi,

I am trying to implement what I guess would be considered an HTML templating type of design using XHTML and Javascript. Basically, I would like there to be a flat-file XHTML document which contains all of the HTML needed for the elements in a page. Then, I would like to use the XMLHttpRequest object to retrieve the responseXML of this document, which I can then use to parse out specific elements, manipulate them, and then insert them into the DOM.

However, I am running into a pretty big problem just trying to get IE to recognize the XHTML file and provide the responseXML. I am using the following XHTML DTD in my XHTML file which is named html_template.xml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The responseXML seems to be returned fine in Mozilla and I can view the XML DOM tree in the browser. But when I try to view the XHTML template in IE, I receive the following error message:

Use of default namespace declaration attribute in DTD not supported

After looking into this a little further, it seems like IE does not like the seeing the DOCTYPE in the XML source. But if I remove it, the page starts complaining about undefined elements that were previously defined in the DTD.

Does anyone know of a way to formulate XHTML in a way that will make it possible for me to read the responseXML of the page through the XMLHttpRequest object in Javascript? Any help here would be greatly appreciated!

Thanks

sheila
08-21-2005, 06:36 AM
It sounds like its a problem in your DTD, not with the Doctype declaration in your XML source.

Charles
08-21-2005, 07:01 AM
Use XSLT instead of JavaScript.

billk
08-21-2005, 02:14 PM
It's not a problem with the DTD, I'm using the xhtml1-strict.dtd provided by the W3C. See the discussion about this issue here: http://www.siteexperts.com/forums/viewConverse.asp?d_id=16642&start=4

Specifically, see this post:

The XHTML DTD actually declares default namespace attributes, which is completely valid.
IE simply refuses to parse that DTD (watch the error message: "... not supported"). Call it unsupported, I call it a bug. 8)

sheila
08-21-2005, 06:25 PM
If there's some reason why you can't use XSLT and if you know what the problem is with the W3C's DTD then why not write your own DTD (or schema) based on theirs but adjusted to get around the problem?