开发者

How to make Sarissa use a DTD when parsing XML?

I am using Sarissa to convert a string of XML into a DOM document object. Everything is working except that Sarissa is completely ignoring my DTD. Deviations from the DTD rules are not noticed, nor do I see any messages about the DTD not being found.

My XML starts like this:

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE workspace SYSTEM "dtd/config.dtd">

and my JavaScript looks like this:

function toXML(str) {
    var responseDoc = (new DOMParser()).parseFromString(str, "text/xml");
    ...
}

How can I get 开发者_如何学运维Sarissa to use the DTD?


Sarissa's source code does not have any very special parsing code for DOMParser(). It basically wraps IE's, Safari's, or the Firefox/Opera native implementation, which may not parse DTDs in the browser you are using, since external DTD parsing is sadly an optional aspect of XML (even for entities), and validation is even less certain. The web kind of forces a person to work with server-side substitutions (or possibly internal document subset definitions which may still be ignored as far as validation).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜