0% found this document useful (0 votes)
12 views

Experiment 12

Uploaded by

Anurag Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Experiment 12

Uploaded by

Anurag Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment - 12

Objective : Writing program in XML for creation of DTD, which specifies set of rules. Create a style
sheet in CSS/ XSL & display the document in internet explorer.

Theory :
XML (eXtensible Markup Language) is a markup language used to store and transport data. It is designed
to be both human-readable and machine-readable. Unlike HTML, which defines how to display data, XML
focuses on how to structure, store, and transport data. Basic XML Structure :
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Explanation:
1.<?xml version="1.0" encoding="UTF-8"?>: This is the XML declaration. It
specifies the XML version and the character encoding used.
2.<note>: The root element that contains all other elements.
3. <to>, <from>, <heading>, <body>: Child elements containing data. These tags describe the information
they hold.
To ensure that XML documents follow a specific structure, schema as like DTD (Document Type Definition)
or XML Schema (XSD) can be used to define the rules and structure of XML documents.
DTD
A Document Type Definition (DTD) defines the structure and rules for an XML document. It specifies the
allowed elements, attributes, and their relationships within an XML file. The DTD ensures that the XML
document follows a specific format and contains the required data in the correct structure.

<!DOCTYPE books [
<!ELEMENT books (book+)>
<!ELEMENT book (title, author, publisher, edition, price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>]>

Source Code : XML

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE books [
<!ELEMENT books (book+)>
<!ELEMENT book (title, author, publisher, edition, price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>]>
<?xml-stylesheet type="text/css" href="Rule.css"?>
<books>
<heading>Welcome</heading>
<book>
<title>Title -: Introduction to Algorithms</title>
<author>Author -: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest,
Clifford Stein</author>
<publisher>Publisher -: MIT Press</publisher>
<edition>Edition -: 3</edition>
<price>Price -: 800</price>
</book>
<book>
<title>Title -: Sapiens: A Brief History of Humankind</title>
<author>Author -: Yuval Noah Harari</author>
<publisher>Publisher -: Harper</publisher>
<edition>Edition -: 1</edition>
<price>Price -: 500</price>
</book>
<book>
<title>Title -: Thinking, Fast and Slow</title>
<author>Author -: Daniel Kahneman</author>
<publisher>Publisher -: Farrar, Straus and Giroux</publisher>
<edition>Edition -: 1</edition>
<price>Price -: 450</price>
</book>
<book>
<title>Title -: Pride and Prejudice</title>
<author>Author -: Jane Austen</author>
<publisher>Publisher -: Penguin Classics</publisher>
<edition>Edition -: 2</edition>
<price>Price -: 300</price>
</book>

<book>
<title>Title -: A Brief History of Time</title>
<author>Author -: Stephen Hawking</author>
<publisher>Publisher -: Bantam Books</publisher>
<edition>Edition -: 2</edition>
<price>Price -: 350</price>
</book>
</books>
CSS
books {
color: white;
background-color : gray;
width: 100%;
}
heading {
color: green;
font-size : 40px;
background-color : powderblue;
}
heading, title, author, publisher, edition, price {
display : block;
}
title {
font-size : 25px;
font-weight : bold;
}

Output :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy