无效更改后,带有DTD的XML文件在Web浏览器中可以正常显示 [英] XML file with DTD displays fine in web browser after invalid change

查看:173
本文介绍了无效更改后,带有DTD的XML文件在Web浏览器中可以正常显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是XML和DTD的新手。我已经用DTD编写了XML文件。

I am new to XML and DTD. I have written an XML file with DTD. Here is it.

<?xml version="1.0"?>
<!DOCTYPE  note[
     <!ELEMENT note (page , author ,company)>
     <!ELEMENT page (#PCDATA)>
     <!ELEMENT author (#PCDATA)>
     <!ELEMENT company (#PCDATA)>
     <!ATTLIST note type CDATA #IMPLIED>
]>

<note typ="single">
    <page>1000</page>
    <author>devan</author>
    <author>devan</author>
    <company>IDM</company>
</note>

工作正常。但是我的问题是,如果将 note 属性设置为 typ ,它将在Web浏览器中很好地显示结果。但是在DTD中,它定义了<!ATTLIST注释类型CDATA#IMPLIED>

It works fine. But my problem is, if you set the note attribute as typ it displays the result in the web browser just fine. But in the DTD it defines <!ATTLIST note type CDATA #IMPLIED>.

xml < pag&fhdh< / pag> 中的标记在网络浏览器中显示就很好。
然后我的问题是为什么我们要定义DTD?

And whenever I change the tags in xml <pag>fhdh </pag> it displays in the web browser just fine. My problem is then why do we define DTD?

推荐答案

DTD本身仅定义有效XML的外观。

DTD by itself only defines what a valid XML looks like.

如果您通过XML验证程序运行问题中的示例XML,则对于您在DTD中指定的DTD,无效将被视为无效。问题。

If you run the sample XML in the question through an XML validator, it will not be considered valid for the DTD you specified in the question.

这篇关于无效更改后,带有DTD的XML文件在Web浏览器中可以正常显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆