unit 2 last few topic
unit 2 last few topic
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:
Service Discovery:
Service Invocation:
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:
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.
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>
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).
javascript
Copy code
var button = document.getElementById("myButton");
button.onclick = myFunction;
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
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
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>
xml
Copy code
<book type="technical">
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.
<div>
<P>
</P>
</div>
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).
Allows random access to nodes and Does not allow random access, processes
Accessibility
supports document modification elements as they are read
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