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

3 XML DTD and XSLT Assignment No 31

The document discusses XML, DTD, and XSLT. It defines the technologies, provides examples of their usage, and outlines steps for creating XML pages, applying DTDs for validation, and using XSLT to transform XML documents into HTML format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

3 XML DTD and XSLT Assignment No 31

The document discusses XML, DTD, and XSLT. It defines the technologies, provides examples of their usage, and outlines steps for creating XML pages, applying DTDs for validation, and using XSLT to transform XML documents into HTML format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Web Technology Lab Manual

Assignment No. : 3

TITLE
Title: XML,DTD and XSLT.

PROBLEM STATEMENT
Write a program to design XML page for student and validate the structure using DTD and show
The output using in HTML format using XSLT.

OUTCOMES

Students will be able to,


1. Design static webpage using XML.
2. Apply DTD to XML pages.
3. Apply XSLT to XML pages

SOFTWARE & HARDWARE REQUIREMENTS

Software: Notepad, Any Browser, Eclipse(for DTD)

THEORY-CONCEPT

XML stands for Extensible Markup Language. It is nothing but the text-based markup language
which is derived from Standard Generalized Markup Language(SGML).

XML tags identify the data and are used to store and organize the data, rather than specifying
how to display it like HTML tags, which are used to display the data. XML is not going to
replace HTML in the near future, but it introduces new possibilities by adopting many
successful features of HTML.

There are three important characteristics of XML that make it useful in a variety of systems and
solutions −
Web Technology Lab Manual

 XML is extensible − XML allows you to create your own self-descriptive tags, or
language, that suits your application.

 XML carries the data, does not present it − XML allows you to store the data irrespective
of how it will be presented.

XML is a public standard − XML was developed by an organization called the World Wide
Web Consortium (W3C) and is available as an open standard.

TECHNOLOGY/TOOL

The XML document have an XML declaration, but it is optional, and it is written as−
<? xml version = "1.0" encoding = "UTF-8"?>
Where version is nothing but the version of an XML document and UTF specifies the character-
encoding used in the document.
Each XML-element needs to be closed either with start or with end elements as shown below −
<element>………</element>
An XML document can have only one root element.
<root>
<x>...</x>
<y>...</y>
</root>
XML Attributes:
Using a name/value pair, an attribute specifies a single property for an element. An XML-
element can have one or more attributes. For example −

<a href = "http://www.google.com/">XMLTutorial</a>

Here href is the attribute name and http://www.google.com/ is attribute value.

DTD

A DTD is a Document Type Definition.

A DTD defines the structure and the legal elements and attributes of an XML document.
Web Technology Lab Manual

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.

An Internal DTD Declaration

If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:

XML document with an internal DTD

<?xml version="1.0"?>

<!DOCTYPE note [

<!ELEMENT note (to,from,heading,body)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT heading (#PCDATA)>

]>

<note>

<to>Neha</to>

<from>Amit</from>

<heading>Reminder</heading>

</note>

The DTD above is interpreted like this:

!DOCTYPE note defines that the root element of this document is note

!ELEMENT note defines that the note element must contain four elements: "to,from,heading"

!ELEMENT to defines the to element to be of type "#PCDATA"

!ELEMENT from defines the from element to be of type "#PCDATA"

!ELEMENT heading defines the heading element to be of type "#PCDATA"


Web Technology Lab Manual

An External DTD Declaration

If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference
to the DTD file:

<?xml version="1.0"?>

<!DOCTYPE note SYSTEM "note.dtd">

<note>

<to>Tove</to>

<from>Jani</from>

<heading>Reminder</heading>

</note>

XSLT

XSL (eXtensible Stylesheet Language) is a styling language for XML.

XSLT stands for XSL Transformations.


The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or
<xsl:transform>.

Note: <xsl:stylesheet> and <xsl:transform> are completely synonymous and either can be used!

The correct way to declare an XSL style sheet according to the W3C XSLT Recommendation is:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Create an XSL Style Sheet

Then you create an XSL Style Sheet ("stud.xsl") with a transformation template:

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


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
Web Technology Lab Manual

<h2>Student</h2>
<table border="1">
<tr> <th>RollNo</th>
<th>Name </th>
</tr>
<xsl:for-each select="Student/stud">
<tr>
<td><xsl:value-of select="rno"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Link the XSL Style Sheet to the XML Document

Add the XSL style sheet reference to your XML document ("student.xml"):

<?xml version="1.0" ?>


<?xml-stylesheet type="text/xsl" href="stud.xsl"?>

If you have an XSLT compliant browser it will nicely transform your XML into XHTML.

DESIGN/EXECUTION STEPS

Following steps are used to Create and Execute web applications,


1. Write the XML code in notepad and save with .xml extension.
2. Write the DTD in notepad and save with .dtd extension (For external DTD)
3. Write a XSLT code in notepad and save using .xsl extension.
4. Open XML page in the browser for running simple XML or XML using XSLT.
5. To run internal/external dtd open Eclipse and run the code using validate.

TEST CASES

Manual testing is used to check whether XSLT gets applied or not.


Eclipse validate function used to check whether DTD gets applied or not.
Web Technology Lab Manual

CONCLUSION/ANALYSIS

Hence, we have designed static web pages using XML ,XSLT and DTD

ORAL QUESTIONS

1. Explain difference between HTML and XML?


2. What is XML DOM?
3. Explain difference between CDATA and PCDATA?
4. What is mean by simple element and complex element?
5. What is DTD?
6. Explain XSL and XSL

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