What is DTD (Document Type Definition)?

Asked

Viewed 1,496 times

14

How this technology works and how it relates to other technologies currently used, such as DOM, Xpath and Xquery?

I’m not looking for something totally thorough, an overview, the way to create a DTD, and its relationship with other technologies can be exemplified with HTML or XML.

3 answers

7


A document type definition (DTD) is a set of markup statements that define a document type for an SGML family markup language (SGML, XML, HTML).

(Source: Wikepedia)

That is, it informs the document what rules the user Agents should follow, and what is not allowed in a particular version of an XML. It would be a way to tell them, what are the rules that the document intends to follow and what rules the browser should use when parsing (Parsing) the document. For this reason, the the choice of doctype influences the type of marking you will use.

A simple example of a DTO used to define an animal:

<!DOCTYPE animal [
   <!ENTITY header "Detalhe do animal">
   <!ELEMENT especie (#PCDATA)>
   <!ATTLIST tipoLocomocao (quadrupede | bipede) #required>
   <!ELEMENT alimentacao (#PCDATA)>
]>

In this example, the item header was first set to Detalhe do animal. The type of data #PCDATA means it can be any text value. Now ATTLIST provides options for a specific element. In this case, the type of locomotion of the animals is quadruped or bipedal.

This is a basic DTD that uses only a few data types. The document type definitions used for large XML databases can have thousands of lines and can include many other types of data. Fortunately, Dtds can be easily modified in a text editor whenever changes need to be made.

If you want to know more, in this website, which I used as a reference, is very well explained.

0

Roughly and informally, a DTD is a "schema" for a class of XML documents. When using a XML parser with validation and informing the DTD to the parser, it can then accept an XML document as valid or refuse as invalid, according to the given DTD.

I don’t know if Dtds are still used, or if their use is acceptable or encouraged, as the RELAX NG specification was later created, which is a "real" (though simple) schema language for XML.

  • I don’t think it’s informal...

0

This article from W3schools is very informative in this sense:

What is a DTD?

What is the DTD? The DTD is a Document Type Definition.

A DTD defines the Structure and the legal Elements and Attributes of an XML Document.

Why Use the DTD? With a DTD, Independent groups of people can agree on a standard DTD for interchanging data.

An application can use a DTD to Verify that XML data is Valid.

Can be used if your XML has sets of standards specific to your business or services.

Hope I helped, hugs!

  • 1

    This link may be a good suggestion, but your reply will not be valid if one day the link crashes. In addition, it is important for the community to have content right here on the site. It would be better to include more details in your response. A summary of the content of the link would be helpful enough! Learn more about it in this item of our Community FAQ: We want answers that contain only links?

  • Thanks for the tip! I will change the answer now and include more information

  • Hi welcome(a), thank you for the attention, I would like if possible, focus your answer, in the questions of the body of the post, the title is more a reference to technology to which I would like to understand, the functioning, syntax and if hj on time it is used and for which, this kind of thing just below the surface...

  • @Samamba hi, I edited my question, in order to make it more objective... The link you posted answers a part of my doubt, still lack information to make the connection with the other technologies cited...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.