0% found this document useful (0 votes)
51 views12 pages

Chapter 6 FNL

Uploaded by

animehv5500
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)
51 views12 pages

Chapter 6 FNL

Uploaded by

animehv5500
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/ 12

Extensible Markup Language (XML)

XML, or Extensible Markup Language, is a widely-used markup language designed to store and
transport data in a structured format. Here's a brief discussion on XML:
1. Structure: XML documents consist of nested elements organized in a hierarchical tree-
like structure. Each element contains data or other elements, similar to the structure of
HTML documents.
2. Tags: XML uses tags to define elements. Tags are enclosed in angle brackets (< and >),
and each tag can have an opening tag (<element>) and a closing tag (</element>), or be
self-closing (<element />) for empty elements.
3. Attributes: XML elements can have attributes, which provide additional information
about the element. Attributes are specified within the opening tag and consist of a name
and value pair (name="value").
4. Data: XML can store various types of data within elements, including text, numbers,
dates, and even structured data like arrays or objects.
5. Extensibility: One of the key features of XML is its extensibility. Users can define their
own custom elements and attributes to represent data specific to their needs, making
XML suitable for a wide range of applications and industries.
6. Readability: XML documents are human-readable and self-descriptive, making them
easy to understand and work with for both humans and machines.
7. Usage: XML is commonly used for data interchange between different systems and
platforms. It is widely used in web services, configuration files, data storage, and various
other applications where structured data representation is required.
8. XML Schema: XML Schema Definition (XSD) is a recommendation from the World
Wide Web Consortium (W3C) that defines the structure, content, and data types of XML
documents. XML Schema provides a way to formally describe the structure of an XML
document, allowing for validation and ensuring compliance with specified rules.
9. XPath and XQuery: XPath is a query language for selecting nodes from an XML
document, while XQuery is a query and functional programming language used to extract
and manipulate data from XML documents.
10. Limitations: While XML is versatile and widely used, it has some limitations, such as
verbosity (repetition of tags can make documents large), complexity in handling
namespaces, and lack of support for hierarchical data storage.
In summary, XML provides a flexible and standardized way to represent structured data, making
it suitable for a wide range of applications where data interchange and interoperability are
essential. Despite some limitations, XML remains a fundamental technology in the realm of data
representation and exchange.
Difference between HTML and XML
HTML XML

It was written in 1993. It was released in 1996.

HTML stands for Hyper Text Markup XML stands for Extensible Markup
Language. Language.

HTML is static in nature. XML is dynamic in nature.

It was developed by Worldwide Web


It was developed by WHATWG.
Consortium.

It is neither termed as a presentation nor a


It is termed as a presentation language.
programming language.

XML provides a framework to define


HTML is a markup language.
markup languages.

HTML can ignore small errors. XML does not allow errors.

It has an extension of .html and .htm It has an extension of .xml

HTML is not Case sensitive. XML is Case sensitive.

HTML tags are predefined tags. XML tags are user-defined tags.

There are limited number of tags in HTML. XML tags are extensible.

HTML does not preserve white spaces. White space can be preserved in XML.

XML tags are used for describing the data


HTML tags are used for displaying the data.
not for displaying.
HTML XML

In HTML, closing tags are not necessary. In XML, closing tags are necessary.

HTML is used to display the data. XML is used to store data.

XML carries the data to and from the


HTML does not carry data it just displays it.
database.

IN XML, the objects are expressed by


HTML offers native object support.
conventions using attributes.

XML document size is relatively large as


HTML document size is relatively small. the approach of formatting and the codes
both are lengthy.

An additional application is not required for DOM(Document Object Model) is required


parsing of JavaScript code into the HTML for parsing JavaScript codes and mapping
document. of text.

Some of the tools used for HTML are:


Some of the tools used for XML are:
 Visual Studio Code
 Oxygen XML
 Atom
 XML Notepad
 Notepad++
 Liquid Studio
 Sublime Text
and many more.
and many more.

XML Document Type Definitions (DTDs)


A DTD is a Document Type Definition.
A DTD defines the structure and the legal elements and attributes of an XML document.
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.
The DTD above is interpreted like this:

There are two type of XML DTD:


1. Internal
<!DOCTYPE mail
[
<!ELEMENT mail (to,from,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>

<!ELEMENT body (#PCDATA)>


<!ENTITY writer "writer:saurabh">
]>
<mail>
<to>[email protected]</to>
<from>[email protected]</from>
<body>hello &writer;</body>
</mail>
2. External

DTD
<!DOCTYPE mail
[
<!ELEMENT mail (to,from,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>

<!ELEMENT body (#PCDATA)>

]>

XML<!DOCTYPE mail SYSTEM "c.dtd">


<mail>
<to>[email protected]</to>
<from>[email protected]</from>
<body>hello webtech </body>

</mail>

XML Schemas
An XML Schema describes the structure of an XML document.
The XML Schema language is also referred to as XML Schema Definition (XSD).
The purpose of an XML Schema is to define the legal building blocks of an XML document:
 the elements and attributes that can appear in a document
 the number of (and order of) child elements
 data types for elements and attributes
 default and fixed values for elements and attributes

One of the greatest strength of XML Schemas is the support for data types.
 It is easier to describe allowable document content
 It is easier to validate the correctness of data
 It is easier to define data facets (restrictions on data)
 It is easier to define data patterns (data formats)
 It is easier to convert data between different data types
Another great strength about XML Schemas is that they are written in XML.
 You don't have to learn a new language
 You can use your XML editor to edit your Schema files
 You can use your XML parser to parse your Schema files
 You can manipulate your Schema with the XML DOM
 You can transform your Schema with XSLT
Example
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="mail">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Save as mail.xsd

<?xml version="1.0"?>
<mail
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema mail.xsd">
<to>[email protected]</to>
<from>[email protected]</from>

<body>Webtech Class!</body>
</mail>
.

XML Object Models


The XML DOM defines a standard way for accessing and manipulating XML documents. It
presents an XML document as a tree-structure.

All XML elements can be accessed through the XML DOM.

The XML DOM is:


 A standard object model for XML
 A standard programming interface for XML
 Platform- and language-independent
 A W3C standard

In other words: The XML DOM is a standard for how to get, change, add, or delete XML
elements.

Presenting and using XML

Presenting and using XML involves both displaying XML data in a human-readable format and
leveraging it programmatically for various purposes. Here's a brief discussion on presenting and
using XML:
1. Human-Readable Presentation:
 Text Editors and IDEs: XML documents can be viewed and edited using text
editors or integrated development environments (IDEs) that provide syntax
highlighting and code folding for XML syntax.
 Web Browsers: Modern web browsers can render XML documents using built-in
XML parsers, displaying the document structure and content in a tree-like format
with collapsible elements.
 XML Editors: Specialized XML editors offer features tailored for working with
XML, such as validation, XPath querying, XSLT transformations, and schema
design tools.
2. Transformation and Rendering:
 XSLT (Extensible Stylesheet Language Transformation): XSLT is used to
transform XML documents into other formats, such as HTML, plain text, or
different XML structures, using XSLT stylesheets.
 XSL-FO (Extensible Stylesheet Language Formatting Objects): XSL-FO is
used to define the layout and formatting of XML documents for printing or
rendering to PDF.
3. Data Exchange and Integration:
 Web Services: XML is commonly used for data exchange between web services
using protocols such as SOAP (Simple Object Access Protocol) and REST
(Representational State Transfer).
 Middleware and Integration Platforms: XML serves as a common data format
for communication between disparate systems and applications in enterprise
middleware and integration platforms.
4. Data Storage and Serialization:
 File Formats: XML is used as a data interchange format for storing structured
data in files, configuration files, and data exchange formats like RSS feeds and
Atom feeds.
 Serialization: XML serialization libraries in programming languages convert
objects or data structures into XML format for storage or transmission, and vice
versa.
5. Data Processing and Analysis:
 Parsing: XML parsers in programming languages parse XML documents into a
tree-like structure, allowing programmatic access to elements and attributes.
 XPath and XQuery: XPath and XQuery languages provide powerful querying
capabilities for extracting specific data from XML documents based on patterns
and conditions.
6. Web Technologies Integration:
 HTML Integration: XML can be embedded within HTML documents using
inline XML syntax, allowing for the inclusion of structured data or custom
elements.
 Ajax (Asynchronous JavaScript and XML): XML is used as a data format for
exchanging asynchronous data between web clients and servers, although JSON
(JavaScript Object Notation) has become more prevalent for this purpose due to
its lightweight and human-readable format.
In summary, presenting and using XML involves a combination of displaying XML data in a
human-readable format for editing and visualization, as well as leveraging it programmatically
for data exchange, transformation, integration, storage, and analysis in various applications and
contexts.

XML processors
XML processors, such as DOM (Document Object Model) and SAX (Simple API for XML), are
two commonly used approaches for parsing and processing XML documents in programming.
Here's a brief discussion on each:
1. DOM (Document Object Model):
 Structure: DOM parses the entire XML document and creates a tree-like structure in
memory, representing all elements, attributes, and text nodes as objects. This structure
can be manipulated and traversed using programming language APIs, typically provided
by libraries or frameworks.
 Usage:
 Traversal: DOM allows easy navigation and manipulation of XML elements
using methods such as getElementById, getElementsByTagName, and
getAttribute.
 Modification: Developers can add, remove, or modify elements and attributes
within the DOM tree, reflecting changes directly in memory.
 Full Document Access: Once parsed, the entire XML document is available in
memory, enabling random access to any part of the document.
 Memory Usage: DOM parsers load the entire XML document into memory, which can
be memory-intensive for large documents. This makes DOM less efficient for memory-
constrained environments or when processing very large XML files.
 Programming Language Support: DOM implementations are available in many
programming languages, including Java, JavaScript, Python, and C#, typically as part of
standard libraries or third-party packages.
2. SAX (Simple API for XML):
 Event-Driven Parsing: SAX parses XML documents sequentially and generates events
as it encounters elements, attributes, text nodes, and other XML constructs. Developers
implement event handlers to respond to these events.
 Usage:
 Streaming Parsing: SAX operates in a streaming fashion, processing XML
documents incrementally without loading the entire document into memory. This
makes SAX suitable for parsing large XML files efficiently.
 Low Memory Footprint: SAX parsers consume minimal memory, as they
process XML documents on-the-fly and do not require storing the entire
document in memory.
 Read-Only Access: SAX provides read-only access to XML data as it streams
through the document, making it suitable for read-only processing or when
memory constraints are a concern.
 Complexity: SAX requires developers to write event handlers to respond to XML
parsing events, which can be more complex compared to navigating a DOM tree.
However, this approach offers better performance and lower memory usage for large
XML documents.
 Programming Language Support: SAX is available in many programming languages,
often provided as a library or module. Developers can find SAX implementations in Java,
Python, C++, and other languages.
In summary, DOM and SAX are two widely used XML processors, each offering distinct
advantages and trade-offs. DOM provides a convenient tree-based API for manipulating XML
documents in memory, while SAX offers efficient streaming parsing with lower memory usage.
Developers choose between DOM and SAX based on factors such as the size of the XML
document, memory constraints, performance requirements, and ease of programming.

Dynamic HTML
Dynamic HTML (DHTML) refers to a combination of technologies used to create interactive and
dynamic web pages. Here's a brief discussion on Dynamic HTML:
1. HTML, CSS, and JavaScript: At its core, DHTML leverages standard web technologies
like HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JavaScript
to create dynamic and interactive web pages.
2. Dynamic Content: DHTML allows web developers to dynamically manipulate and
update the content of web pages in response to user actions, such as mouse clicks,
keyboard inputs, or changes in the browser environment.
3. DOM Manipulation: One of the key features of DHTML is the ability to manipulate the
Document Object Model (DOM) using JavaScript. This allows developers to add,
remove, or modify HTML elements and attributes on the fly, enabling dynamic updates to
the page content.
4. Event Handling: DHTML enables event-driven programming, where JavaScript code
can respond to various events triggered by user actions or browser events. Common
events include mouse clicks, keyboard inputs, form submissions, page load, and window
resize.
5. Animation and Effects: DHTML allows for the creation of animated and visually
appealing effects using CSS transitions, animations, and JavaScript libraries like jQuery
or GSAP (GreenSock Animation Platform). These effects can include animations, fades,
slides, and other dynamic visual elements.
6. AJAX (Asynchronous JavaScript and XML): DHTML facilitates asynchronous
communication with the server using AJAX, enabling web pages to retrieve and update
data without requiring a full page reload. This allows for smoother and more responsive
user experiences.
7. Browser Compatibility: While DHTML is supported by modern web browsers,
developers need to consider browser compatibility issues when implementing dynamic
features, as different browsers may interpret HTML, CSS, and JavaScript code
differently.
8. Performance Considerations: Implementing complex DHTML features can impact
page performance, especially on older devices or browsers with limited resources.
Developers should optimize code and minimize unnecessary DOM manipulations to
ensure smooth user experiences.
9. Accessibility: It's essential to ensure that DHTML features are accessible to users with
disabilities. Developers should follow best practices for accessible web design, including
providing alternative text for dynamic content, keyboard accessibility, and semantic
HTML markup.
In summary, Dynamic HTML (DHTML) enables web developers to create interactive and
dynamic web pages using HTML, CSS, and JavaScript. By leveraging DOM manipulation, event
handling, animations, and AJAX, DHTML allows for the creation of engaging user experiences
on the web. However, developers should consider factors such as browser compatibility,
performance, and accessibility when implementing DHTML features.

You might also like