0% found this document useful (0 votes)
9 views14 pages

Web Sematics Mid

The document provides examples of XML, DTD, and XSD for a bookstore and student data. It explains the differences between internal and external DTDs, and outlines the parsing methods for XML, including DOM and SAX. Additionally, it discusses the evolution of the web from Web 1.0 to Web 4.0, highlighting the Semantic Web and its significance.

Uploaded by

Varshini Reddy
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)
9 views14 pages

Web Sematics Mid

The document provides examples of XML, DTD, and XSD for a bookstore and student data. It explains the differences between internal and external DTDs, and outlines the parsing methods for XML, including DOM and SAX. Additionally, it discusses the evolution of the web from Web 1.0 to Web 4.0, highlighting the Semantic Web and its significance.

Uploaded by

Varshini Reddy
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/ 14

SET1 (4.QUESTION ),SET2(1.QUESTION),SET3(1.

QUESTION1a,1b)

a)Write an XML code for bookstore,internal and external dtd?

Internal / Embedded DTD.

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

<!DOCTYPE student [

<!ELEMENT student (id, name, age, addr, email, ph)>

<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT age (#PCDATA)>

<!ELEMENT addr (#PCDATA)>

<!ELEMENT email (#PCDATA)>

<!ELEMENT ph (#PCDATA)> ]>

<student>

<id>543</id>

<name>Ravi</name>

<age>21</age>

<addr>Guntur</addr>

<email>[email protected]</email>

<ph>9855555</ph>

<gender>male</gender>

</student>
) External DTD.

“student.dtd”

<!ELEMENTstudent (id, name, age, addr, email, ph)>

<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT age (#PCDATA)>

<!ELEMENT addr (#PCDATA)>

<!ELEMENT email (#PCDATA)>

Save the above code as “student.dtd” and prepare “student.xml” as follows... “student.xml”

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

<!DOCTYPE student SYSTEM "student.dtd">

<student>

<id>543</id>

<name>Ravi</name>

<age>21</age>

<addr>Guntur</addr>

<email>[email protected]</email>

</student>

In the above example we are using <!DOCTYPE student SYSTEM "student.dtd"> which is used to
provide “student.dtd” code in our “student.xml” file. If the above xml code follows the exact rules
defined in DTD then we can conclude that our xml document is a valid document. Otherwise it is an
invalid document.

b)Write an xml code for bookstore schema ?


<?xml version="1.0"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

<xsd:element name="bookstore">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="name" type="xsd:string"/>

<xsd:element name="location" type="xsd:string"/>

<xsd:element name="email" type="xsd:string"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

The following example shows the employe xml document or xml instance for the above
ebookstore schema. bookstore.xml

<?xml version="1.0"?>

<bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespacSchemaLocation="./bookstore.xsd">

<name>Readers' Haven</name>

<location>Hyderabad</location>

<email>[email protected]</email>

</bookstore>

c) explain about DOM & SAX Parsers ?


XML parsing is the process of reading an XML document and providing an interface to the user
application for accessing the document. An XML parser is a software apparatus that accomplishes
such tasks.

An XML parser is a software library or package that provides interfaces for client

applications to work with an XML document.

XML parser validates the document and check that the document is well formatted. The Parser could
be categorized as validating and non-validating

Validating Parser: It needs a Document type Declaration to parse and gives an error if the
respective document doesn’t match with DTD and constraints.

Non-Validating: This Parser eliminates DTD and the parser checks for the well-formed document.
Types of Parsers:There are three common ways to parse an XML document: by using the Simple API
for XML (SAX), by building a Document Object Model (DOM), and by employing a new technique
called pull parsing.

SAX is a style of parsing called event-based parsing where each information class in the instance
document generates a corresponding event in the parser as the document is traversed.

SAX parsers are useful for parsing very large XML documents or in low-memory

environments.

Pull parsing is a new technique that aims for both low-memory consumption and high performance.

Pull parsing is also an event-based parsing technique; however, the events are read by the
application (pulled) and not automatically triggered as in SAX.

The majority of applications use the DOM approach to parse XML.

3.23. What Is the Document Object Model (DOM)?

The Document Object Model (DOM) is a language-neutral data model and application

programming interface (API) for programmatic access and manipulation of XML and HTML.

The Document Object Model is an in-memory representation of an XML or HTML

document and methods to manipulate it.

DOMs can be loaded from XML documents, saved to XML documents, or dynamically generated by a
program.

The DOM has provided a standard set of classes and APIs for browsers and

programming languages to represent XML and HTML.

The DOM is represented as a set of interfaces with specific language bindings to those interfaces.

Unlike XML instances and XML schemas, which reside in files on disk, the DOM is an in-memory
representation of a document.

The model for this memory representation is object-oriented programming (OOP).

Object-oriented programming introduces two key data modelling concepts: classes and objects.

A class is a definition or template describing the characteristics and behaviors of a realworld entity
or concept.

From this description, an in- memory instance of the class can be constructed, which is called an
object.
SET 3 (1C)

Explain about XML Schema?

XML Schema Example

The following example shows the employe schema for employee details.

employee.xsd

1. <?xml version="1.0"?>

2. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

3. <xsd:element name="employee">

4. <xsd:complexType>

5. <xsd:sequence>

6. <xsd:element name="firstname" type="xsd:string"/>

7. <xsd:element name="lastname" type="xsd:string"/>

8. <xsd:element name="email" type="xsd:string"/>

9. </xsd:sequence>

10. </xsd:complexType>

11. </xsd:element>

12. </xsd:schema>

The following example shows the employe xml document or xml instance for the above employee
schema. employee.xml

1. <?xml version="1.0"?>

2. <employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

3. xsi:noNamespacSchemaLocation="./employee.xsd">

4. <firstname>vimal</firstname>

5. <lastname>jaiswal</lastname>

6. <email>[email protected]</email>

7. </employee>

What is semantic web? and explain about the levels of W3C with neat diagram?

The Semantic Web definition given by Tim Berners-Lee in 1999 is

“The first step is putting data on the Web in a form that machines can naturally understand, or
converting it to that form. This creates a Semantic Web—a web of data that can be processed

directly or indirectly by machines.”

The Semantic Web as a logical extension of the current Web instead of a distant possibility.

The Semantic Web is both achievable and desirable.

According to the vision of Tim Berners-Lee we can define the Semantic Web as a machine

processable web of smart data.

We can also further define smart data as data that is application-independent, composable,

classified, and part of a larger information ecosystem (ontology).

The World Wide Web Consortium (W3C) has established an Activity dedicated to

implementing the vision of the Semantic Web.The following diagram shows an example of

Semantic Web with Web of documents and Web of data.

1.2 The Evolution of the Web

The World Wide Web, commonly known as the web, has become an integral part of modern

society. It has revolutionized the way we communicate, work, and access information. However,

the web we know today has evolved significantly since its inception in 1989. In this section we are

going to see an overview of the evolution of the web, from its early days to the current era of web

4.0.

Web 1.0: The Static Web


In the first-generation web technology, we can read and share information on web pages.

 This is based on bookmarking and hyperlinking. There is a concept of static pages.

 The web as we know it today began in 1989 when Tim Berners-Lee, a British computer

 scientist, proposed a new system for sharing information over the internet.

 This system, which he called the World Wide Web, was based on a simple set of protocols
that allowed users to access and share information using hypertext links. The first website,
which was created by Berners-Lee, went live in 1991.

 In the early days of the web, websites were primarily static pages that provided information
to users.

 These pages were created using HTML (Hypertext Markup Language), a markup language
that allowed developers to structure web pages using tags. Websites were primarily created
by developers and were often difficult for users to navigate.

 Web 2.0: The Dynamic Web

In the second-generation web, we can read, write, and interact with each other. This web
2.0 dynamic page and user-generated content replace the static pages.
 The next stage in the evolution of the web was the emergence of Web 2.0 in the early
2000s. This era was characterized by the emergence of user-generated content and social
media platforms.

 The term Web 2.0 was coined by Tim O’Reilly, a technology entrepreneur and writer, to
describe a new generation of web-based applications that were more interactive and
dynamic.

 Web 2.0 was characterized by the emergence of social media platforms such

as Facebook, Twitter, and LinkedIn.

 These platforms allowed users to create and share content with each other, and they
became a central part of everyday life for many people.

 The emergence of Web 2.0 also saw the rise of e-commerce, with companies such as

Amazon and eBay becoming dominant players in the online retail space

Web 3.0: The Semantic Web


In the third-generation web,

 machines can think of information rather than humans.This web 3.0 is also known as the
semantic web.

 The next stage in the evolution of the web is Web 3.0, also known as the Semantic Web.

 The Semantic Web is characterized by a shift from the current web, which is focused on
content, to a web that is focused on meaning.

 The Semantic Web aims to create a more intelligent web that can understand and interpret
the meaning of information, making it easier for users to find what they are looking for.

 The Semantic Web is based on a set of technologies and standards, including RDF

(Resource Description Framework) and OWL (Web Ontology Language), which allow data to be
represented in a machine-readable format.

 This allows machines to understand the meaning of information and to make intelligent
decisions based on that information.
Web 4.0: The Intelligent Web

In the fourth-generation web is also known as the Symbiotic web. With this, humans and machines
can interact with each other. Web 4.0, also known as the Intelligent Web, is the next stage in the
evolution of the web.

This era is characterized by the emergence of artificial intelligence (AI) and machine
learning (ML) technologies, which are being used to create more intelligent and
personalized web experiences for users.

The Intelligent Web is based on a combination of AI and ML technologies, including


natural language processing (NLP), image recognition, and predictive analytics. These
technologies allow websites to provide personalized recommendations, automate tasks, and interact
with users in a more human-like way.

The Intelligent Web is already being used in a variety of industries, including healthcare, finance, and
e-commerce. For example, healthcare companies are using AI and ML to analyse patient data and to
develop personalized treatment plans.

E-commerce companies are using these technologies to provide personalized


recommendations to users based on their browsing and purchasing history.

b)Explain about XML,XSD,XLS,DTD with examples?

What Is XML?

XML has become the universal syntax and framework for exchanging data between organizations. By
agreeing on a standard schema, organization can produce these text documents that can be
validated, transmitted, and parsed by any application regardless of hardware or operating system.

XML provides universal accepted language for creating semantically rich new markup languages in a
particular domain.

In other words, we can apply XML to create new markup languages.

Any language created via the rules of XML, like the Math Markup Language

(MathML), CML (Chemical Markup Language) are called the applications of XML.

A markup language’s primary concern is how to add semantic information about the raw content in a
document; thus, the vocabulary of a markup language is the external “marks” to be attached or
embedded in a document.

XML Syntax:

Following is a complete XML document:

<?xml version="1.0"?>

<contact_info>

<name>Rajesh</name>

<company>TCS</company>

<phone>9333332354</phone>

</contact_info>

You can notice there are two kinds of information in the above example:

markup, like <contact-info> and the text, like Rajesh etc.

The following diagram depicts the syntax rules to write different types of markups and text in

an XML document.
XML DTD: (Document Type Definition)

An XML document with correct syntax is called "Well Formed".

An XML document validated against a DTD is both "Well Formed" and "Valid".

A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a
DTD.

DTD is the basic building block of XML.

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a
list of legal elements.

A document type definition defines the rules and the legal elements and attributes for an XML
document.

<!DOCTYPE book [

<!ELEMENT book (title, author, price)>

<!ELEMENT title (#PCDATA)> <!ELEMENT

author (#PCDATA)> <!ELEMENT price

(#PCDATA)> ]>

The DTD above is interpreted like this:

!DOCTYPE book defines that the root element of the document is book

!ELEMENT book defines that the book element must contain the elements:

"title, author, price”

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

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

!ELEMENT price defines the price element to be of type

"#PCDATA" Note: PCDATA: Parsed Character Data,

CDATA: Character Data.

There are two types of DTDs:

1) Internal / Embedded DTD.

2) External DTD.

1) Internal / Embedded DTD.

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

<!DOCTYPE student [

<!ELEMENT student (id, name, age, addr, email, ph)>


<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT age (#PCDATA)>

<!ELEMENT addr (#PCDATA)>

<!ELEMENT email (#PCDATA)>

<!ELEMENT ph (#PCDATA)> ]>

<student>

<id>543</id>

<name>Ravi</name>

<age>21</age>

<addr>Guntur</addr>

<email>[email protected]</email>

<ph>9855555</ph>

<gender>male</gender>

</student>

) External DTD.

“student.dtd”

<!ELEMENTstudent (id, name, age, addr, email, ph)>

<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT age (#PCDATA)>

<!ELEMENT addr (#PCDATA)>

<!ELEMENT email (#PCDATA)>

Save the above code as “student.dtd” and prepare “student.xml” as follows... “student.xml”

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

<!DOCTYPE student SYSTEM "student.dtd">

<student>

<id>543</id>

<name>Ravi</name>

<age>21</age>

<addr>Guntur</addr>
<email>[email protected]</email>

</student>

In the above example we are using <!DOCTYPE student SYSTEM "student.dtd"> which is used to
provide “student.dtd” code in our “student.xml” file. If the above xml code follows the exact rules
defined in DTD then we can conclude that our xml document is a valid document. Otherwise it is an
invalid document.

XSD:

You might also like