简体   繁体   English

从XHTML提取文档类型定义(DTD)是什么意思?

[英]What does it mean to extract Document Type Definition (DTD) from XHTML?

I know what a DTD is, as described in this question . 正如这个问题所述,我知道DDT是什么。 I was reading a paper, and they were talking about extracting the DTD from a XHTML document or its schema. 我正在阅读一篇论文,他们正在谈论从XHTML文档或其模式中提取DTD。 I was wondering what does it mean? 我想知道这是什么意思? Can anybody give me an example for clarification? 有人可以给我举个例子吗?

A DTD is a schema, since it describes the structure of the data; DTD 一种模式,因为它描述了数据的结构。 it's analogous to a class. 它类似于一个类。 One XHTML document is one instance , analogous to an object. 一个XHTML文档是一个实例 ,类似于一个对象。 XHTML is also XML. XHTML也是XML。 So you could generate a DTD (or a XML Schema) which describes the contents of elements and attributes based on that document only, and the generated DTD or XML Schema will validate it. 因此,您可以生成仅基于该文档描述元素和属性内容的DTD(或XML Schema),并且生成的DTD或XML Schema将对其进行验证。

But there is no guarantee that this generated schema will validate other XHTML documents. 但是,不能保证此生成的架构将验证其他XHTML文档。 If you add an extra <p> to your instance, or if you use a valid XHTML tag that was not present in the instance you used to generate the DTD, then validation will fail for this second document. 如果您在实例中添加了额外的<p> ,或者使用了用于生成DTD的实例中不存在的有效XHTML标记,则此第二份文档的验证将失败。

If you have another schema that validates your XHTML, for example, the W3C XML Schema for XHTML, then you can generate from it a DTD that will validate all XHTML instances you create (in this case, download or use the DTD available at W3C). 如果您有另一个验证XHTML的模式(例如,用于XHTML的W3C XML Schema),则可以从中生成一个DTD,该DTD将验证您创建的所有XHTML实例(在这种情况下,下载或使用W3C上可用的DTD) 。

There are several tools that generate DTDs from XML Schemas or from documents. 有几种工具可以从XML模式或文档生成DTD。 If you search you will find several free and commercial options. 如果您进行搜索,您会发现一些免费的和商业的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM