0% found this document useful (0 votes)
65 views47 pages

Understanding XML: Features and Uses

Uploaded by

shivangidhama02
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)
65 views47 pages

Understanding XML: Features and Uses

Uploaded by

shivangidhama02
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

XML

XML stands for Extensible Markup Language. It is a type of markup language


and file format used to store, transport, and recreate arbitrary data.

Meaning of XML in Web technology:

XML is a markup language similar to HTML, but without predefined tags to use.
Instead, you define your own tags designed specifically for your needs. This is a
powerful way to store data in a format that can be stored, searched, and shared

1
Main Benefit
We can use it to take data from a program like Microsoft SQL, convert it into
XML then share that XML with other programs and platforms.

- The main thing which makes XML truly powerful is its international
acceptance.

Other benefits are:


- XML separates data from HTML
- XML simplifies data sharing(in simple text format)
- XML simplifies Platform change
- XML increases data availability
- XML simplifies data transport
- XML is Often a Complement to HTML
2 main uses of XML:
• XML is often used in front-end web development.
• It's also is used in back-end web development because some APIs use it to transfer data
in a standard format.

Real time applications of XML:


• XML has a wide range of use cases and applications across various industries, including
web services, document storage and management, configuration files, data serialization
and deserialization and GIS data

Best XML Editors in 2024

Editix, Liquid Studio, Notepad++, Oxygen XML Editor, Stylus Studio, Sublime Text,
Visual Studio Code, XMLBlueprint, XMLPad, XML Spy, XML ValidatorBuddy

3
Who created XML?
• In the late 1990s a group of people including Jon Bosak, Tim Bray, James Clark and others
came up with XML, eXtensible Markup Language.

• Like SGML(standard generalized markup language), XML is not itself a markup


language, but a specification for defining markup languages.
Main features of XML:
• Xml was released in late 90’s.
• It was created to provide an easy to use and store self describing data(data that describes both
its content and structure)

• XML became a W3C Recommendation on February 10, 1998.


• XML doesn’t depend on the platform and programming language( ie. platform independent
& language independent)
• XML is designed to carry data, not to display data. 4
Cons/drawback of using XML:

• XML requires a processing application.


• Its syntax is similar to another alternative 'text-based' data transmission
formats, which is sometimes confusing.
• No intrinsic data type support
• The XML syntax is redundant.
Differences between HTML and XML

SNo HTML(Hyper Text Markup Language) XML(eXtensible Markup Language)


It is a s/w and h/w independent tool used to
1 Used to display data & focuses on how data looks.
transport and store data. It focuses on what data is.
2 HTML is not a case sensitive language XML is case sensitive language

3 HTML is a markup language itself. Provides a framework to define markup languages.

4 HTML is static because it is used to display data. XML is dynamic because it is used to transport data.

5 Closing tag in optional Closing tag is mandatory

6 HTML has its own predefined tags. We can define tags according to our need.

7. File Extension .html or .htm File Extension is .xml

8. Size is comparatively large. Size is comparatively small


XML Related Technologies
Sno Technology Meaning
1) XHTML Extensible html

2) XML DOM XML document object


model
3) XSL Extensible style sheet
it contain three parts: language
i) XSLT (xsl transform)
ii) XSL
iii)XPath

4) XQuery XML query language


5) DTD Document type definition

6) XSD XML schema definition


(A) XML Example
XML documents create a hierarchical structure looks like a tree so it is known as XML Tree
that starts at "the root" & branches to "the leaves".
Example: XML documents uses a self-describing and simple syntax:
<?xml version="1.0" encoding="ISO-8859-1"?> // XML declaration. It
defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/West European
character set).

<note> //root element of the document


<to>Abhi</to>
<from>Avi</from> //4 lines describe 4 child elements of the root (to, from, heading, & body).
<heading>Wishes</heading>
<body>Have a great life ahead!</body>
</note> // defines the end of the root element
Cont….

• XML documents must contain a root element and it is "the parent" of all other elements.
• Elements in an XML document form a document tree.
• The tree starts at the root and branches to the lowest level of the tree.
• All elements can have sub elements (child elements).
• The terms parent, child, and sibling are used to describe the relationships b/w elements.
• Children on the same level are called siblings (brothers or sisters).
• All elements can have text content and attributes (just like in HTML).
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
(B) Example of XML: basic XML structure that represents a book's details.
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<bookstore> root element: <bookstore>
<book>
<title>XML Basics</title> All elements in the document are contained
<author>Abhi</author> within <bookstore>
<year>2024</year>
<price>299</price> The <book> element has 4 children: <title>,<
</book> author>, <year> and <price>.
<book>
<title>Learn XML</title>
<author>Avi</author>
<year>2023</year>
<price>200</price>
</book>
</bookstore>
XML Attributes
• XML elements can have attributes that add the information about the element.
• Attribute for an element is placed after the tag name in the start tag.
• We can add more than one attribute for a single element.
• XML attributes enhance the properties of the elements.
• XML attributes must always be quoted(single or double quote).

Metadata should be stored as attribute and data should be stored as element.


<Organisation>
<company name=“XYZ Holdings" location=“India">
<chairman>Mr. Abhishek</chairman>
<gm>Mr. Vansh</gm>
</company>
There are two attributes in the company element, i.e. name and location.
XML Comments

XML comments are just like HTML comments. Although XML is known as self-describing
data but sometimes XML comments are necessary.

Syntax : <!-- Write your comment-->

XML Comments Example


<?xml version="1.0" encoding="UTF-8" ?>
<!--Students marks are uploaded by months-->
<students>
<student>
<name>Ratan</name>
<marks>70</marks>
</student>
</students>
XML Tree Structure
• An XML document has a self descriptive structure which forms a tree structure and referred as an XML tree.
• Its tree structure makes easy to describe an XML document. It contains root element (as parent), child element and so on.
• It is very easy to traverse all succeeding branches and sub-branches and leaf nodes starting from the root.
Example of an XML document The tree-structure representation of given example:

<?xml version="1.0"?>
<college>
<student>
<firstname>Anu</firstname>
<lastname>Bhatt</lastname>
<contact>07899044992</contact>
<email>[Link]@[Link]</email>
<address>
<city>Haldwani</city>
<state>Uttarakhand</state>
<pin>201206</pin>
</address>
</student> Line 1: XML declaration( defines the XML version 1.0.
</college> Line 2: Root element (college).
Line 3: Inside root element, there is one more element: student
<student> : contains 5 branches- <firstname>, <lastname>, <contact>, <Email>, <address>.
Line 8: <address> branch contains 3 sub-branches named <city>, <state> and <pin>.
Note: DOM parser represents the XML document in Tree structure.
XML with a Complex Structure
<?xml version="1.0" encoding="UTF-8"?>
<university>
<student id="001">
<name>Anna Lee</name>
<courses>
<course code="CS101" credits="3">Computer Science</course>
<course code="MA102" credits="4">Mathematics</course>
</courses>
<graduationYear>2024</graduationYear>
</student>
<student id="002">
<name>Mark Liu</name>
<courses>
<course code="PH103" credits="3">Physics</course>
<course code="CS101" credits="3">Computer Science</course>
</courses>
<graduationYear>2023</graduationYear>
</student>
</university>
Types of XML:
2 ways to describe an XML document: XML Schemas and DTDs.

DTD in XML with an example:


• DTD is a document-type definition.
• DTD contains a set of rules that defines the structure and content of XML document.
• When any XML file refers DTD file, it validates against those rules.
• It specifies the elements, attributes, and entities that are allowed in the document and the
relationships between them.

Purpose of the DTD:


• To define the legal building blocks of an XML document.
• Defines the document structure with a list of legal elements.
• A DTD can be declared inline in your XML document, or as an external reference.

15
Types of DTD- Internal and External DTD:
• XML documents can contain a DTD, which can either be embedded within the
document itself (known as an internal DTD) or stored in a separate file (an
external DTD).
• Internal DTDs can result in larger XML documents, while external DTDs keep
them smaller.
Difference between external and internal data:
• Internal data is the information generated from within a business, including areas
such as operations, maintenance, personnel, and finance.
• External data comes from the market, such as surveys, questionnaires, research, and
customer feedback.
How to make an xml file without using internal or external dtd

For this, simply avoid including any DOCTYPE declarations in your XML content.
In XML, DTDs are optional. Unless you explicitly add a DOCTYPE declaration, your XML file will not reference any DTD.

16
1) Internal Declaration
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT pnote (to,from,heading,body)>
1) Internal
<!ELEMENT to (#PCDATA)> • !DOCTYPE note: defines that the root
element of this document is note.
Declaration <!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)> • It has one parent <pnote>
• !ELEMENT pnote: defines that the
<!ELEMENT body (#PCDATA)> pnote element contains 4 elements:
]> "to,from,heading,body".
<note>
<pnote>
<to>Raju</to> • <!ELEMENT to: The to element is
#PCDATA typed. (parse-able data type).
<from>Ravi</from> ….and so on.
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</pnote>
</note>
2) External DTD [Link]
<!ELEMENT pnote (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<?xml version="1.0"?> <!ELEMENT body (#PCDATA)>
<!DOCTYPE note SYSTEM "[Link]"> ]>
<note>
<pnote>
[Link]
<to>Raju</to>
<from>Ravi</from>
<heading>Reminder</heading> In this example:
<body>Don't forget me this weekend</body> 1. DOCTYPE declaration: refers to an external
</pnote> DTD file.
2. <!DOCTYPE employee : root element of the
<pnote>
document is employee.
<to>Raju</to>
3. The external DTD file is to be referred
<from>Ravi</from>
here.(in [Link])
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</pnote>
</note>
XML CSS
Purpose of CSS in XML:
• CSS (Cascading Style Sheets) can be used to add style and display information to an XML
document. It can format the whole XML document.
Link XML file with CSS : syntax: <?xml-stylesheet type="text/css" href="[Link]"?>

XML CSS Example xml file using CSS and DTD : [Link]
DTD file : [Link]
[Link] <?xml version="1.0"?>

note <!ELEMENT note <?xml-stylesheet type="text/css" href="[Link]"?>


{ (to,from,heading,body)> <!DOCTYPE note SYSTEM "[Link]">
background-color: pink;
<!ELEMENT to (#PCDATA)> <note>
}
to, from, heading, body <!ELEMENT from (#PCDATA)> <pnote>
{ <!ELEMENT heading (#PCDATA)> <to>Raju</to>
font-size:25px; <!ELEMENT body (#PCDATA)> <from>Ravi</from>
display:block;
]> <heading>Reminder</heading>
color: blue;
margin-left: 50px; <body>Don't forget me this weekend</body>
} </pnote>
</note>
CSS is not generally used to format XML file. W3C recommends XSLT instead of CSS.
XML schema
• It is defined as an XML language
• Uses namespaces to allow for reuses of existing definitions
• Supports large number of built in data types & definition of
derived data types

Understanding Namespaces
• As defined by the W3C Namespaces in XML Recommendation , an XML namespace is a collection of XML
elements and attributes identified by an Internationalized Resource Identifier (IRI); this collection is often
referred to as an XML "vocabulary.“
• A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions,
variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name
collisions that can occur especially when your code base includes multiple libraries.
XML Schema – XSD (XML Schema Definition)
Ø The XML Schema language is also referred to as XML Schema Definition (XSD).
Ø XSD is used to define the possible structure and contents of an XML format.
Ø A validating parser can then check whether an XML instance document conforms to an XSD
schema or a set of schemas.

• Similar to DTD, XML Schema is also used to check whether the given XML document is
“well formed” and “valid”.
• XML schema is an alternative to DTD.
• An XML document is considered “well formed” and “valid” if it is successfully validated
against XML Schema.

Why is it necessary to validate XML?


- When sending data from a sender to a receiver, it is essential that both parts have the same
"expectations" about the content.
- With XML Schemas, the sender can describe the data in a way that the receiver will
understand.
XML Validation
- XML document ( a well- formed) can be validated against DTD or Schema.
- A well-formed XML document (valid XML document) is an XML document with correct syntax.

Valid XML document


It must be well formed (satisfy all the basic syntax condition). It should be behave according to
predefined DTD or XML schema

Rules for well formed XML


• Must begin with the XML declaration.
• Must have one unique root element.
• All start tags of XML documents must match end tags.
• Tags are case sensitive.
• All elements must be closed.
• Elements must be properly nested.
• All attributes values must be quoted.
• XML entities must be used for special characters.
Steps to Create XML with XSD

Creating an XML file that conforms to an XSD involves two parts:


1. Creating the XSD file: The XSD defines the structure, constraints,
and data types for our XML file, ie. The schema for XML file.

2. Creating the XML file: This XML File follows the rules in the XSD
file.
Optionally, Validate the XML against the XSD to ensure it adheres to
the schema.
1. Creating an XSD File: [Link] that defines the structure of a book catalog:
This XSD defines that:
<?xml version="1.0"?>
<xs:schema xmlns:xs="[Link] This code is an XML Schema Definition (XSD) used to
<xs:element name="catalog"> define the structure of XML documents.
<xs:complexType>
<xs:sequence> Simple explanation :
<xs:element name="book" maxOccurs="unbounded"> 2. `<xs:schema
<xs:complexType> xmlns:xs="[Link]
<xs:sequence>
This line starts the XML Schema definition and defines
<xs:element name="author" type="xs:string"/>
<xs:element name="title" type="xs:string"/> the namespace for the schema, which is a way of
<xs:element name="genre" type="xs:string"/> uniquely identifying the XML Schema elements and
<xs:element name="price" type="xs:decimal"/> attributes.
<xs:element name="publish_date" type="xs:date"/>
3. `<xs:element name="catalog">`: an element named
</xs:sequence>
"catalog". This is the root element of the XML document
<xs:attribute name="id" type="xs:string"
use="required"/> that will be validated against this schema.
</xs:complexType> 4. `<xs:complexType>`: This specifies that the "catalog"
</xs:element> element contains other elements inside it (it is not a
</xs:sequence>
simple element with just text).
</xs:complexType>
</xs:element> 5. `<xs:sequence>`: This means that the child elements of
"catalog" should appear in a specific sequence.
</xs:schema>
Cont…
6. `<xs:element name="book" maxOccurs="unbounded">`: Inside "catalog", there can be multiple "book" elements.
The `maxOccurs="unbounded"` means there can be any number of "book" elements.
7. `<xs:complexType>`: each "book" element also contains other elements inside it.
8. `<xs:sequence>`: the child elements of each "book" element must appear in a specific order.
9. `<xs:element name="author" type="xs:string"/>`: "author" element, and its content should be a string.
10. `<xs:element name="title" type="xs:string"/>`: "title" element, and its content should be a string.
11. `<xs:element name="genre" type="xs:string"/>`: "genre" element, and its content should be a string.
12. `<xs:element name="price" type="xs:decimal"/>`: "price" element, and its content should be a decimal number.
13. `<xs:element name="publish_date" type="xs:date"/>`: "publish_date" element, and its content should be a
date.
14. `<xs:attribute name="id" type="xs:string" use="required"/>`: Each "book" element must have an attribute
named "id", and it should be a string. This attribute is required for every "book" element.
15. `</xs:schema>`: This line closes the schema definition.

In summary, this schema defines a structure for an XML document where the root element is "catalog", which can
contain multiple "book" elements. Each "book" must have specific child elements ("author", "title", "genre", "price",
and "publish_date") and a required "id" attribute.
2. Creating an XML File That Conforms to the XSD (`[Link]` schema)
Explanation:
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:xsi="[Link]
2. <catalog
instance"
xmlns:xsi="[Link]
xsi:noNamespaceSchemaLocation="[Link]">
<book id="bk101"> instance"
<author>Gambardella, Matthew</author> xsi:noNamespaceSchemaLocation="[Link]">`: This is
<title>XML Developer's Guide</title> the root element of the XML document.
<genre>Computer</genre> - `xmlns:xsi="[Link]
<price>44.95</price> instance"`: Declares the XML Schema Instance namespace,
<publish_date>2000-10-01</publish_date> which is used for schema-related attributes.
</book>
<book id="bk102"> - `xsi:noNamespaceSchemaLocation="[Link]"`:
<author>Ralls, Kim</author> Indicates the location of the XML Schema (XSD) file that
<title>Midnight Rain</title> defines the structure and rules for this XML document.
<genre>Fantasy</genre> Here, it's named "[Link]".
<price>5.95</price>
3. `<book id="bk101">`: This is a "book" element with an
<publish_date>2000-12-16</publish_date>
attribute `id="bk101"`. It represents a single book entry in
</book>
the catalog.
</catalog>
4. Inside the `<book>` element, there are several child elements:
- `<author>Gambardella, Matthew</author>`: The author of the book.
- `<title>XML Developer's Guide</title>`: The title of the book.
- `<genre>Computer</genre>`: The genre of the book.
- `<price>44.95</price>`: The price of the book.
- `<publish_date>2000-10-01</publish_date>`: The publication date of the book.

5. `<book id="bk102">`: Another "book" element with a different ID (`id="bk102"`). This represents another book entry in
the catalog.

6. Inside this `<book>` element, you have:


- `<author>Ralls, Kim</author>`: The author of this book.
- `<title>Midnight Rain</title>`: The title of this book.
- `<genre>Fantasy</genre>`: The genre of this book.
- `<price>5.95</price>`: The price of this book.
- `<publish_date>2000-12-16</publish_date>`: The publication date of this book.

7. `</catalog>`: This closes the "catalog" element, ending the XML document.

In summary, this XML document is a catalog that contains information about two books, including details like the author,
title, genre, price, and publication date for each book. The schema file referenced (`[Link]`) would define the rules and
structure for these elements.
XML Entities
• a way of representing special characters. The ENTITY statement is used to define entities in the DTD, for use in both the
XML document associated with the DTD and the DTD itself.
• An ENTITY provides an abbreviated entry to place in your XML document.

Why XML Entities required?


• Some characters (such as ", & <, and so on) are reserved in XML. They are referred to as special characters and cannot be
directly used for other purposes.

• For example, the < and > symbols a used for tags. You cannot directly type from the keyboard for less than and greater
than signs. Instead, you need to use entities.

Character Description Entity Name Usage

some of the popular XML entities. " Quotation mark (double quote) quot &quot;

& Ampersand amp &amp;

' Apostrophe (single quote) apos &apos;

< Less than sign lt &lt;

> Greater than sign gt &gt;


<friend>
Example: <name>My friends are Vinny &amp; Anu.</name>
</friend>
XML Schema Data types
In XML schema an element belongs to either of the following two types:
(1) simpleType, (2) complexType

(1)simpleType – Such type of element can contain text, they do not contain
other elements and cannot be left empty.
the elements- to, from, heading and body are simpleType element.

2. complexType – Such type of element can contain attributes, other


elements, and text and can be left empty.
the element: catalog is of type complexType because it contains other
elements.
DTD vs XSD
The important differences are given below:
SNo DTD XSD
1) Stands for Document Type Definition. Stands for XML Schema Definition.

2) Derived from SGML(standard generalized) syntax. Are written in XML.

3) Doesn't support datatypes. Supports datatypes for elements & attributes.

4) Doesn't support namespace. Supports namespace.

5) Doesn't define order for child elements. Defines order for child elements.

6) Not extensible. It is extensible.


7) Provides less control on XML structure. Provides more control on XML structure.

8) The extension of document type is .dtd. The extension of Schema file is .xsd.
Advantages of using XML Schema over DTD

1. Schema uses XML as language so don’t require to learn new syntax.

2. XML schema supports data types and namespaces.

3. XML parser can be used to parse the XML schema as well.

4. It is extensible i.e., we can reuse the schema in other schema.

5. More than one schemas can be referred in a single XML document.


CDATA vs PCDATA
CDATA (Stands for “Unparsed Character Data”)
It means that the content within a CDATA section is treated as raw text. This section:
• Does not get parsed by the XML processor. OP:
• Allows characters like <, >, and & to be included without escaping them.

As the CDATA is used just after the element


Example: <message> to make the data/text unparsed, so
<message> it will give the output :
<![CDATA[ Hello <world>! ]]>
</message>
<message>
<![CDATA[ Hello <world>! ]]>
</message>
<message>

In this example, <world> is included as literal text, and no


escaping is required.
PCDATA:
PCDATA: (Parsed Character Data): Text that is parsed by the XML processor. This means that
special characters like <, >, and & are treated as markup or entity references and need to be
escaped.

Example:

<?xml version="1.0"?>

<message>Hello &lt;world&gt;!</message> OP:

In this example, &lt; is used to represent < and &gt; is


used for >. The XML processor will convert these to their
respective characters.:

<message>Hello <world>!</message>
XML Parsers
- It is a software library or package that provides interfaces for client applications
to work with an XML document.

- It is designed to read the XML and create a way for programs to use XML.

- It validates the document and check that the document is well formatted.

Working of XML parser :


Types of XML Parsers
These are the two main types of XML Parsers: (1) DOM (2) SAX

(1) XML DOM

• DOM is an acronym stands for Document Object Model.


• Defines a standard way to access and manipulate documents.
• It is a programming API for HTML and XML documents.
• Defines logical structure of documents and the way a document is accessed & manipulated.
• The DOM Parser implements a DOM API. This API is very simple to use.

• The XML DOM makes a tree-structure view for an XML document.


• We can access all elements through the DOM tree.
• We can modify or delete their content and also create new elements.
• The elements, their content (text and attributes) are all known as nodes.
The DOM represents this table like this:
Advantages
For example, consider this table,
1) It supports both read and
taken from an HTML document:
write operations and the API
is very simple to use.
<TABLE>
<ROWS>
2) It is preferred when random
<TR>
access to widely separated parts
<TD>A</TD>
of a document is required.
<TD>B</TD>
</TR>
Disadvantages
<TR>
1) It is memory inefficient.
<TD>C</TD>
(consumes more memory
<TD>D</TD>
b e ca u s e t h e w h o l e X M L
</TR>
document needs to loaded
</ROWS>
into memory).
</TABLE>
2) It is comparatively slower
than other parsers.
SAX (Simple API for XML)

A SAX Parser implements SAX API. This API is an event based API and less intuitive.

Features of SAX Parser


• It does not create any internal structure.
• Clients does not know what methods to call, they just overrides the methods of the API
and place his own code inside method.
• It is an event based parser, it works like an event handler in Java.

Advantages
1) It is simple and memory efficient.
2) It is very fast and works for huge documents.

Disadvantages
1) It is event-based so its API is less intuitive.
2) Clients never know the full information because the data is broken into pieces.
[Link]. SAX PARSER DOM PARSER
01. It is called a Simple API for XML Parsing. It is called as Document Object Model.

02. It’s an event-based parser. It stays in a tree structure.

03. SAX Parser is slower than DOM Parser. DOM Parser is faster than SAX Parser.

04. Best for the larger sizes of files. Best for the smaller size of files.

05. Internal structure can’t be created by SAX Parser. Internal structure can be created by DOM Parser.

06. It is read-only. It can insert or delete nodes.

07. Backward navigation is not possible. Backward and forward search is possible

08. Suitable for efficient memory. Suitable for large XML document.

09. Small part of XML file is only loaded in memory. It loads whole XML documents in memory.
XSL and XSLT
• XSL stands for EXtensible Stylesheet Language. It is a styling language for XML just like CSS
is a styling language for HTML.

• XSLT stands for XSL Transformation. It is used to transform XML documents into other
formats (like transforming XML into HTML).
• World Wide Web Consortium (W3C) developed XSL to understand and style an XML
document, which can act as XML based Stylesheet Language.
• An XSL document specifies how a browser should render an XML document.

Main parts of XSL Document


• XSLT: It is a language for transforming XML documents into various other types of documents.
• XPath: It is a language for navigating in XML documents.
• XQuery: It is a language for querying XML documents.
• XSL-FO: It is a language for formatting XML documents.
[Link]
[Link]
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
<?xml version = "1.0"?> xmlns:xsl = "[Link]
<?xml-stylesheet type = "text/xsl" href = "[Link]"?> <xsl:template match = "/">
<class> <html>
<body>
<employee id = "001"> <h2>Employee</h2>
<firstname>Aryan</firstname> <table border = "1">
<lastname>Gupta</lastname> <tr bgcolor = "pink">
<th>ID</th>
<nickname>Raju</nickname> <th>First Name</th>
<salary>30000</salary> <th>Last Name</th>
</employee> <th>Nick Name</th>
<th>Salary</th>
<employee id = "024"> </tr>
<firstname>Sara</firstname> <!-- for-each processing instruction
<lastname>Khan</lastname> Looks for each element matching the XPath expression
-->
<nickname>Zoya</nickname> <xsl:for-each select="class/employee">
<salary>25000</salary> <tr>
</employee> <td>
<!-- value-of processing instruction
<employee id = "056"> process the value of the element matching the XPath expression
<firstname>Peter</firstname> -->
<lastname>Symon</lastname> <xsl:value-of select = "@id"/>
</td>
<nickname>John</nickname> <td><xsl:value-of select = "firstname"/></td>
<salary>10000</salary> <td><xsl:value-of select = "lastname"/></td>
</employee> <td><xsl:value-of select = "nickname"/></td>
<td><xsl:value-of select = "salary"/></td>
</class> </tr>
</xsl:for-each>
</table> </body> </html> </xsl:template> </xsl:stylesheet>
DHTML
• DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.

• Dynamic HTML is not a markup or programming language but it is a term that combines
the features of various web development technologies for creating the web pages dynamic
and interactive.

• The DHTML application was introduced by Microsoft with the release of the 4th version of
IE (Internet Explorer) in 1997.

Components of Dynamic HTML

DHTML consists of the following four components or languages:

1. HTML 4.0 2. CSS 3. JavaScript 4. DOM.


Difference between HTML and DHTML
HTML (Hypertext Markup language) DHTML (Dynamic Hypertext Markup language)

1. HTML is simply a markup language. 1. It is not a language, but it is a set of


technologies of web development.
2. Used to develop &creating web pages. 2. Used for creating and designing the
animated and interactive web sites or pages.
3. Creates static web pages. 3. Creates dynamic web pages.

4. Does not contain any server-side scripting 4. May contain code of server-side scripting.
code.
5. Their files are stored with the .html 5. The files are stored with the .dhtm
or .htm extension in a system. extension in a system.
6. A simple page which is created by a user 6. A page which is created by a user using
without using the scripts or styles called as the HTML, CSS, DOM, and JavaScript
an HTML page. technologies called a DHTML page.
7. This markup language does not need 7. This concept needs database connectivity
database connectivity. because it interacts with users.

You might also like