0% found this document useful (0 votes)
6 views10 pages

unit 2 last few topic

Web services are XML-based systems for application-to-application interaction over the Internet, utilizing a standardized XML messaging system. They involve service publication through WSDL, service discovery via UDDI, and service invocation using SOAP messages, followed by processing and response generation. Additionally, event handling in JavaScript can be done using HTML attributes, addEventListener, or direct assignment, while XML documents can be validated using DTDs, which can be internal or external.

Uploaded by

gangak23022005
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)
6 views10 pages

unit 2 last few topic

Web services are XML-based systems for application-to-application interaction over the Internet, utilizing a standardized XML messaging system. They involve service publication through WSDL, service discovery via UDDI, and service invocation using SOAP messages, followed by processing and response generation. Additionally, event handling in JavaScript can be done using HTML attributes, addEventListener, or direct assignment, while XML documents can be validated using DTDs, which can be internal or external.

Uploaded by

gangak23022005
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/ 10

1)What is Web Service? Explain how it works?

 Web services are XML-based information exchange systems that use the
Internet for direct application-to-application interaction. These systems can
include programs, objects, messages, or documents
 A web services is a piece of software that makes itself to available over
the internet and uses a standardized XML messaging system

working

 Service Publication:

 The web service provider creates a WSDL (Web Services Description


Language) document that describes the service's functionality, such as the
operations it can perform, the data formats it accepts, and the network
endpoint (URL) where the service can be accessed.
 This description is made available to potential consumers, either by
publishing it in a directory or by sharing it directly with clients.

 Service Discovery:

 Clients can discover available services by querying a service registry like


UDDI (Universal Description, Discovery, and Integration). UDDI provides
metadata about available web services, including details about the service
provider, capabilities, and access endpoints.
 This directory service helps clients find and understand services they might
want to use without needing direct contact with the service provider.

 Service Invocation:

 Once a client identifies a service, it initiates a service request by creating a


SOAP message.
 The message specifies the operation the client wants to perform (like
"getWeather" for a weather service) and any input data required for that
operation, formatted as XML.

 Message Transmission:

 The SOAP message is then sent to the service provider’s endpoint over the
network, typically using HTTP or HTTPS for secure transmission.
 The HTTP protocol ensures the request is correctly routed to the service
provider’s server.

 Service Processing:

 When the server receives the SOAP request, it reads the message, extracts
the requested operation, and performs the necessary processing.
 This processing may involve looking up data, running calculations, or
interacting with databases or other services as part of the service logic.

 Response Generation:

 The provider constructs a SOAP response message, which contains the


results of the client’s request or any data that needs to be returned.
 If there’s an error, the response message will include an error code or
message to inform the client.

 Message Transmission (Response):

 This response is transmitted back to the client over the same communication
protocol, typically HTTP/HTTPS.
 The client uses the same mechanisms it used to send the request, making the
communication channel consistent.

 Response Handling:

 The client application processes the returned SOAP response, parsing the
XML data to retrieve the requested information.
 This data is then used by the client application, which could mean displaying
it to the user, using it for further calculations, or combining it with other
data.

2. What are the different ways of Registering an Event Handler?

1. Using the on Attribute in HTML

 This method involves adding an event attribute directly within the HTML
tag of an element, specifying both the event (like onclick) and the function
to execute.
 This approach is easy to understand and quick to implement for small,
simple projects.
 Limitations: In larger projects, inline event handling mixes JavaScript with
HTML, making code less modular, harder to maintain, and more challenging
to debug.

Example:

html
Copy code
<button onclick="myFunction()">Click me</button>

 Here, myFunction() is executed when the button is clicked. The event


handler is tied directly to the HTML, making the code less flexible.

2. Using addEventListener in JavaScript (DOM Event Handlers)

 The addEventListener method is part of the DOM Level 2 Events API and
allows for a more flexible way of handling events in JavaScript.
 Advantages:
o Multiple event handlers can be added to the same event.
o Event handlers can be removed using removeEventListener.
o Allows event capturing (useful in complex interfaces with nested
elements).
 Example:

javascript
Copy code
var button = document.getElementById("myButton");
button.addEventListener("click", myFunction);

 Here, myButton is the button’s ID, and myFunction is the function executed
on the click event. With this approach, you can easily add multiple listeners
and manage event flow (bubbling or capturing).

3. Using Event Handler Properties (Direct Assignment)

 This method assigns a function directly to an event property of a DOM


element (like onclick for a button).
 It’s somewhat similar to the HTML attribute method but is defined in
JavaScript, allowing separation of HTML and JavaScript code.
 Limitations:
o Only one event handler can be registered per event type, as each new
assignment overwrites the previous one.
 Example:

javascript
Copy code
var button = document.getElementById("myButton");
button.onclick = myFunction;

 In this example, the onclick property is assigned the myFunction function,


which runs when the button is clicked. This approach allows for code
modularity but lacks the flexibility of addEventListener when multiple
handlers are needed.

3.Explain DTD and its type?

A Document Type Definition (DTD) is a set of rules that defines the structure,
elements, and attributes for an XML document. It specifies what elements and
attributes can appear in the document, their data types, and their relationships to
each other. DTDs help ensure that XML documents adhere to a specific structure,
which is essential for data validation, interoperability, and consistency across
applications.

1. Internal DTD

 An Internal DTD is defined within the XML document itself, inside the <!
DOCTYPE> declaration.
 It is suitable for smaller XML documents or when the DTD is specific to a
single XML file and unlikely to be reused.

Example:

xml
Copy code
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

 In this example, the DTD defines the structure for the <note> element and its
children directly within the document.

2. External DTD

 An External DTD is stored outside the XML document, in a separate file.


This allows multiple XML files to use the same DTD, promoting reusability.
 The external DTD file can be linked to the XML document using the
SYSTEM or PUBLIC keyword in the <!DOCTYPE> declaration.

Example:

xml
Copy code
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

 Here, the XML document references an external DTD file named note.dtd.
The note.dtd file would contain the DTD structure:

Contents of note.dtd:
xml
Copy code
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

An XML document is structured with elements and tags, and has a few key components:

1. XML Declaration:
o Indicates that the document is XML and specifies the XML version and encoding
type.
o Example:

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

2. Root Element:
o Every XML document must have a single root element that contains all other
elements.
o Example:

xml
Copy code
<books> ... </books>

3. Child Elements:
o Elements within the root element, each represented by an opening and closing tag.
o Example:

xml
Copy code
<books>
<book>
<title>Web Programming</title>
<author>Srikanth S</author>
</book>
</books>
4. Empty Elements:
o Represented with a self-closing tag if they contain no content.
o Example:

xml
Copy code
<author/>

5. Attributes:
o Provide additional information about an element and are written as name/value
pairs within the opening tag.
o Example:

xml
Copy code
<book type="technical">

6. Comments:
o Begin with <!-- and end with -->.
o Example:

xml
Copy code
<!-- This file contains book information -->

XML Syntax Rules:

1. Single Root Element:


o Each XML document must have one root element that contains all other elements.
o Example:

xml
Copy code
<root> ... </root>

2. Case Sensitivity:
o XML tags are case-sensitive; <Author> is different from <author>.
3. Closing Tags:
o All elements must have a closing tag or be self-closed.
o Example:

xml
Copy code
<p>Paragraph text</p>

4. Proper Nesting:
o Elements must be correctly nested within one another.
o Example:
xml
Copy code
<b><i>Bold and italic text</i></b>

5. Quoted Attribute Values:


o Attribute values must be enclosed in quotes.
o Example:

xml
Copy code
<book type="technical">

6. Special Character Escaping:


o Certain characters like <, >, and & must be replaced with &lt;, &gt;, and &amp;
respectively.
7. Naming Rules for Tags:
o Tag names must start with a letter or underscore, can contain numbers, and must
not include spaces.

Difference between Well-Formed and Valid XML Documents:

1. Well-Formed Document:
o Adheres to the basic XML syntax rules (single root element, properly nested
elements, case sensitivity, and escaped special characters).
o Any XML document that meets these requirements is considered well-formed and
can be processed by XML parsers.
2. Valid Document:
o Must be well-formed but also conforms to a specified DTD or XML Schema.
o Validation ensures the document follows a predefined structure, including
allowed elements, attributes, and their organization.
o Valid documents offer a higher level of consistency and are ideal for strict data
requirements.

Or

1. Well-Formed Document: • A well-formed XML document adheres to the syntax rules of XML.
• It must satisfy the basic structural requirements, such as having a single root element,
properly nested elements, correct usage of tags and attributes, and proper handling of special
characters
• Well-formedness is a prerequisite for an XML document to be processed by XML parsers.
• All XML documents must be well-formed to be considered valid for processing.
2. Valid Document: •
A valid XML document not only meets the criteria for being well-formed but also conform to a
specific Document Type Definition (DTD) or XML Schema.
• It must adhere to the rules and structure defined in the DTD or XML Schema, including the
allowed elements, attributes, and their arrangement.
• Validation ensures that the document complies with the constraints and rules specified in the
DTD or XML Schema, providing a higher level of structural integrity and data consistency. •
Validation can be performed using an internal DTD, an external DTD, or an XML Schema.

what is event propogation ? explain the types of event in Dom2 event model?

Event propagation is the sequence by which events travel through the Document Object Model
(DOM) when triggered on an element, potentially affecting parent and child elements. There are
two main types of event propagation in the DOM Level 2 Event Model: capturing and
bubbling.

Types of Event Propagation in DOM Level 2 Event Model

1. Capturing (Event Capturing Phase):


o In capturing, also known as the "trickle-down" phase, the event starts from the
topmost ancestor (usually the document object) and moves downward through
each parent element until it reaches the target element.
o In capturing, the top-level element (e.g., document) processes the event first,
moving down the hierarchy toward the actual element that triggered the event.
o Example: If you have an img inside a p, which is inside a div, when a user clicks
the image, the event is captured starting from the document to div, then p, and
finally to img.

<div>

<P>

<img src=”abc”> </img>

</P>

</div>

2. Bubbling (Event Bubbling Phase):


o In bubbling, the event is first handled by the target element (the one where the
event originated), and then it "bubbles up" the DOM tree to its parent, then the
parent's parent, continuing up until it reaches the root (document) or is stopped.
o Example: If you have an img inside a p, which is inside a div, when a user clicks
the img, the event first processes at the img, then bubbles up to p, then to div, and
finally up to document.
Simple api for xml(SAX) and DOM Parsers in XML

XML parsers are tools for reading and processing XML documents. They scan XML documents,
identifying elements and making them available for applications to work with. Two primary
methods for parsing XML are SAX (Simple API for XML) and DOM (Document Object
Model).

Key Differences Between SAX and DOM Parsers

Feature DOM SAX

Parsing Builds an in-memory tree structure for Event-driven, processes document


Method the entire document sequentially

Memory Memory-intensive, especially for large Memory-efficient as it doesn’t store the


Efficiency documents entire document

Allows random access to nodes and Does not allow random access, processes
Accessibility
supports document modification elements as they are read

Allows modification of document content Does not allow modification as it reads,


Modification
and structure mainly used for reading purposes

Faster as it only processes the document


Slower for large documents due to high
Performance sequentially without building a memory
memory consumption
structure

Suitable for small to medium documents Suitable for large documents that need to be
Ideal Use Case requiring frequent access and processed efficiently without modifying
manipulation content

You might also like