Web Technology - Old Questions
2. Explain the use of XML in web development. Write internal and external DTD to describe "mail" as a root element and "to", "from", and "subject", and "message" as child elements.
Extensible markup Language (XML) plays a significant role in the present world of web development, it is perfectly useful for those who wish to make use of web technologies for distributing information across the web. Like HTML, XML is also being used to format a document with a web browser. It is an influential and effectual tool to process a document’s contents and therefore, creating own tags is possible with XML. It gels well with any operating system and maintains a great amount of flexibility, which is very essential for the web development scenario.
Uses:
- XML is used to separate data from presentation
- XML is used to store and transport data.
- XML is used to separate data from HTML.
- XML data is stored in text format. This makes it easier to expand or upgrade to new operating systems, new applications, or new browsers, without losing data
- XML can be used to create new internet languages. For e.g. XHTML, WSDL
Now,
Internal DTD for given elements
//mail.dtd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mail[
<!ELEMENT mail(to, from, subject, message)>
<!ELEMENT to(#PCDATA)>
<!ELEMENT from(#PCDATA)>
<!ELEMENT subject(#PCDATA)>
<!ELEMENT message(#PCDATA)>
]>
<mail>
<to>Jayanta</to>
<from>Sagar</from>
<subject>webtech</subject>
<message> Never miss the web tech class</message>
</mail>
External DTD for given elements
//mail.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mail SYSTEM "mail.dtd">
<mail>
<to>Jayanta</to>
<from>Sagar</from>
<subject>webtech</subject>
<message> Never miss the web tech class</message>
</mail>
//mail.dtd
<!ELEMENT mail(to, from, subject, message)>
<!ELEMENT to(#PCDATA)>
<!ELEMENT from(#PCDATA)>
<!ELEMENT subject(#PCDATA)>
<!ELEMENT message(#PCDATA)>