Another important part of XML is the Document Type Definition (DTD), a file associated with SGML and XML documents that defines how markup tagsshould be interpreted by the application reading the document. A DTD is what turns XML from a metalanguage to a true language designed for a specific task.
A DTD is a text document that contains a set of rules, formally known as"entity, element, and att-list (attribute) declarations," that define an XML markup language. It names new elements and describes the type of data or other elements that an element may contain. It also lists attributes for each element.
A Simple DTD
For example, if you were creating recipes to be accessed over the Web, you might create your own language called RML, or Recipe Markup Language. RML would have tags like <title> and <body>, but also RML-specific tags such as <ingredients>, <prep-time>, and <nutritionalInformation>. These tags would be established in a DTD for the new language. The DTD imparts detailed information about what data should be found in each tag. A DTD for Recipe Markup Language might have a line like this:
The first line declares an element called ingredients. An ingredients tag can contain an li element and text. The plus sign (+) after li indicates that an ingredients element will have one or more li elements within it. The question mark after text shows that text is optional. The Recipe Markup Language DTD would also specify the li element:<!ELEMENT li (#PCDATA)>
This element contains text only (PCDATA stands for "parsed character data" and is used to indicate text that may contain other tagged elements).
When an XML document conforms to all the rules established in the DTD, it is said to be valid, meaning that all the elements are used correctly.
A well-formed document is not necessarily valid, but if a document proves to be valid it follows that it is also well-formed.
When your document uses a DTD, you can check it for mistakes using avalidating parser. The parser checks the document against the DTD forcontextual errors, such as missing elements or improper order of elements. Most of the best validating parsers are free. Some common parsers are Xerces from the Apache XML Project and Microsoft MSXML.
When to Use a DTD
DTDs are not required and actually come with a few disadvantages. A DTD is useful when you have specific markup requirements to apply across a large number of documents. A DTD can ensure that certain data fields are present or delivered in a particular format. You may also want to spend the timepreparing a DTD if you need to coordinate content from various sources and authors. Having a DTD makes it easier to find mistakes in your code.
The disadvantages to DTDs are that they require time and effort to develop and are inconvenient to maintain (particularly while the XML language is in flux). DTDs slow down processing times and may be too restrictive on the user's end. Another problem with DTDs is that they are not compatible with the namespace convention. Elements and attributes from another namespace won't validate under a DTD unless the DTD explicitly includes them (whichdefeats the purpose of namespaces in the first place). If you are creating just a few XML documents or if you are using namespaces, a DTD is undesirable.
Web Designing Related Interview Questions
|HTML Interview Questions||HTML 5 Interview Questions|
|Flash Interview Questions||Graphic Design Interview Questions|
|Illustrator Interview Questions||Dreamweaver Interview Questions|
|UI Developer Interview Questions||Dreamweaver CS3 Interview Questions|
|CSS Advanced Interview Questions||Web Developer Guide Interview Questions|
|Log Shipping Interview Questions||Spring Boot Interview Questions|
|UI Designer Interview Questions||Bootstrap 4 Interview Questions|
Web Designing Related Practice Tests
|HTML Practice Tests||HTML 5 Practice Tests|
|Flash Practice Tests||Graphic Design Practice Tests|
|Illustrator Practice Tests||Dreamweaver Practice Tests|
|UI Developer Practice Tests||Dreamweaver CS3 Practice Tests|
|Web Developer Guide Practice Tests||Advanced jQuery Practice Tests|
Web Designing Tutorial
Designing For A Variety Of Browsers
Designing For A Variety Of Displays
Web Design Principles For Print Designers
A Beginners Guide To The Server
Printing From The Web
Structural Html Tags
Adding Images And Other Page Elements
Specifying Color In Html
Cascading Style Sheets
Server Side Includes
Designing Graphics With The Web Palette
Audio On The Web
Video On The Web
Flash And Shockwave
Introduction To Smil
Introduction To Dhtml
Introduction To Xml
Wap And Wml
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.