Week-5: Date:
------------------------------------------------------------------------------------------------------------
AIM: Write
an XML file which will display the Book information.
It
includes the following:
1)
Title of the book
2)
Author Name
3)
ISBN number
4)
Publisher name
5)
Edition
6)
Price
Write a Document Type Definition
(DTD) to validate the above XML file.
Display the XML file as follows.
The contents should be displayed in
a table. The header of the table should be in color GREY. And the Author names
column should be displayed in one color and should be capitalized and in bold.
Use your own colors for remaining columns.
Use XML schemas XSL and CSS for the
above purpose.
DESCRIPTION:
DTD vs XML Schema
The DTD provides a
basic grammar for defining an XML Document in terms of the metadata that
comprise the shape of the document. An XML Schema provides this, plus a
detailed way to define what the data can and cannot contain. It provides far
more control for the developer over what is legal, and it provides an Object
Oriented approach, with all the benefits this entails.
Many systems
interfaces are already defined as a DTD. They are mature definitions, rich and
complex. The effort in re-writing the definition may not be worthwhile.
DTD is also established, and examples of
common objects defined in a DTD abound on the Internet -- freely available for
re-use. A developer may be able to use these to define a DTD more quickly than
they would be able to accomplish a complete re-development of the core elements
as a new schema.
Finally, you must also consider the fact
that the XML Schema is an XML document. It has an XML Namespace to refer to,
and an XML DTD to define it. This is all overhead. When a parser examines the
document, it may have to link this all in, interpret the DTD for the Schema, load
the namespace, and validate the schema, etc., all before it can parse
the actual XML document in question. If you're using XML as a protocol between
two systems that are in heavy use, and need a quick response, then this
overhead may seriously degrade performance.
·
Write a Document Type Definition
(DTD) to validate the XML file.
PROGRAM:
XML
document (bookstore.xml)
<bookstore>
<book>
<title>web
programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet
worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
XML
document Validation using DTD
DTD
document (bookstore.dtd)
<?xml version="1.0"
encoding="UTF-8"?>
<!ELEMENT bookstore (book+)>
<!ELEMENT book
(title,author,ISBN,publisher,edition,price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT price (#PCDATA)>
Bookstore.xml
<!DOCTYPE
bookstore SYSTEM "C:\Documents and Settings\Administrator\My
Documents\bookstore.dtd">
<bookstore>
<book>
<title>web
programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet
worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
XML
document Validation using DTD
XML
Schema (bookstore.xsd)
<?xml version="1.0"
encoding="UTF-8"?>
<xs:schema
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element
name="bookstore">
<xs:complexType>
<xs:sequence>
<xs:element name="book"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"></xs:element>
<xs:element name="author" type="xs:string"></xs:element>
<xs:element name="ISBN" type="xs:string"></xs:element>
<xs:element name="publisher" type="xs:string"></xs:element>
<xs:element name="edition" type="xs:int"></xs:element>
<xs:element name="price" type="xs:decimal"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Bookstore.xml
<bookstore
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\My
Documents\bookstore.xsd">
<book>
<title>web
programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet
worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
·
Display the XML file as follows.
PROGRAM:
XML:
<?xml
version="1.0"?>
<?xml-stylesheet
type="text/xsl" href="bookstore.xsl"?>
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De
Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
XSL:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template
match="/">
<html>
<body>
<h2> My Books
collection</h2>
<table
border="1">
<tr
bgcolor="red">
<th
align="left">title</th>
<th
align="left">author</th>
</tr>
<xsl:for-each
select="bookstore/book">
<tr>
<td><xsl:value-of
select="title"/></td>
<xsl:choose>
<xsl:when
test="price > 30">
<td
bgcolor="yellow"><xsl:value-of
select="author"/></td>
</xsl:when>
<xsl:when
test="price > 10">
<td
bgcolor="magneta"><xsl:value-of
select="author"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of
select="author"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
http://wikibrand.blogspot.in |
RESULT: Thus the XML
stylesheets are successfully used to display the content in a table format.
SOURCE:PVPSIT FOR JNTUK
This website mind blowing to giving super information about 5 xml to all local and national information about Sarkari Result
ReplyDeletecan u plzz tell how to validate xml using dtd ?? did u use any tools for it?
ReplyDeleteIts really awesome blog...thanks for sharing
ReplyDeleteSalarpuria Sattva Divinity
Codename Five Rings
Brigade Buena Vista
Sumadhura Acropolis
nice blog.thanks for sharing with us for financial services in hyderabad click.
ReplyDeleteHome Loans in Hyderabad
Hello Everybody,
ReplyDeleteMy name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) Thank you.
BORROWERS APPLICATION DETAILS
1. Name Of Applicant in Full:……..
2. Telephone Numbers:……….
3. Address and Location:…….
4. Amount in request………..
5. Repayment Period:………..
6. Purpose Of Loan………….
7. country…………………
8. phone…………………..
9. occupation………………
10.age/sex…………………
11.Monthly Income…………..
12.Email……………..
Regards.
Managements
Email Kindly Contact: urgentloan22@gmail.com
Nice blog and thanks for sharing the post.
ReplyDeleteKorres
Korres Natural Products
Name Badges Singapore
Name Badges Malaysia
Domed Stickers
Rubber Stamps Online
Rubber Stamps
Durable Online Singapore
Clarion Medical
Character + Design
Great Blog...thanks for sharing
ReplyDeleteAvast Antivirus Technical Support Australia
AVG Antivirus Support Australia
Find Financial Advisers and Planners
McAfee Antivirus Support Australia
Norton Support Number Australia
Trend Micro Technical Support in Australia
Study in Australia
Thanks for sharing the information with us!!
ReplyDeleteRamky One Galaxia
Prestige High Fields
Incor One City
Prestige Ivy League
How to create an HTML Document that will display a title of the book and its author?
ReplyDeleteNice Blog,I feel like all your ideas are incredible! Great job!!!
ReplyDeleteI have some information about:
Prestige High Fields
Brigade Citadel
Pbel City
Nice Blog and Thanks for sharing with us,
ReplyDeletePrestige Tranquil
Prestige High Fields
Urbanrise Spring Is In The Air
Spring Is In The Air
Ambience Courtyard
PBEL City
Indis Viva City
Ramky One Galaxia
The Botanika
Sumadhura Horizon
Nice...I really like your article...I think that you spent more time and effort on your blog...thanks for sharing this good information & i have some information about the Real Estate luxurious projects in Telangana.
ReplyDeleteThis Project will helpful for those who are looking to buy their Dream Home with low budget..
Thanks for Sharing..!.!
Sumadhura Horizon
Sark Town Homes
The Botanika
ReplyDeleteYour selection of topic is very good and also well written. Thanks for sharing. I feel like all your ideas are incredible! Great job!!!
I have some information about:
Brigade Citadel
Sri Aditya Athena
Ramky One Galaxia
Nice Blog...Thanks for sharing with us...and i have some information about The Botanika
ReplyDeleteand it is a new residential project located in Gachibowli, Hyderabad. This project offers 3 BHK Luxury Apartments in Affordable Prices. Contact Us@ 98492 05577
Nice Blog..Thanks for sharing this helpful information & i found some information about Sumadhura Horizon and it is a residential project developed by Sumadhura Infracon Pvt. Ltd. located in Kondapur, Hyderabad. It is provides 3BHK luxury residential flats.
ReplyDeleteNice Blog,I feel like all your ideas are incredible! Great job!!!
ReplyDeleteI have some information about:
Aspire Ameya
Aspire Ameya Miyapur
Aspire Ameya Hyderabad
Aspire Ameya Miyapur Hyderabad
Aspire Spaces Ameya
Nice content 👍
ReplyDeleteExcellent article and this helps to enhance your knowledge regarding new things. Waiting for more updates.
ReplyDeleteAngular 12 New Features
Angular Latest Version Features