Você está na página 1de 126

SKP Engineering College

Tiruvannamalai 606611

A Course Material On

Service Oriented Architecture

606611 A Course Material On Service Oriented Architecture By L.Sankaran Assistant Professor Computer Science and

By

L.Sankaran Assistant Professor Computer Science and Engineering Department

S.K.P. Engineering College, Tiruvannamalai

Quality Certificate

VII SEM

This is to Certify that the Electronic Study Material

Subject Code: IT6801

Subject Name: Service Oriented Architecture

Year/Sem:IV/VII

Being prepared by me and it meets the knowledge requirement of the University curriculum.

Signature of the Author

Name: L.Sankaran

Designation: Assistant Professor

This is to certify that the course material being prepared by Mr. L.Sankaran is of the adequate quality. He has referred more than five books and one among them is from abroad author.

Signature of HD

Name:K.Baskar

Seal:

Signature of the Principal

Name: Dr.V.Subramania Bharathi

Seal:

S.K.P. Engineering College, Tiruvannamalai

VII SEM

IT6801 SERVICE ORIENTED ARCHITECTURE

L T P C

3 0 0 3

OBJECTIVES:

The student should be made to:

Learn XML fundamentals. Be exposed to build applications based on XML. Understand the key principles behind SOA. Be familiar with the web services technology elements for realizing SOA. Learn the various web service standards.

 

UNIT I INTRODUCTION TO XML

9

XML document structure Well-formed and valid documents Namespaces DTD

XML Schema X-Files.

UNIT II BUILDING XML- BASED APPLICATIONS

Parsing XML using DOM, SAX XML Transformation and XSL XSL Formatting Modeling Databases in XML.

9

UNIT III SERVICE ORIENTED ARCHITECTURE

Characteristics of SOA, Comparing SOA with Client-Server and Distributed architectures Benefits of SOA -- Principles of Service orientation Service layers.

9

UNIT IV WEB SERVICES

Service descriptions WSDL Messaging with SOAP Service discovery UDDI

Message Exchange Patterns Orchestration Choreography WS Transactions.

9

UNIT V BUILDING SOA-BASED APPLICATIONS

Service Oriented Analysis and Design Service Modeling Design standards and guidelines --Composition WS-BPEL WS-Coordination WS-Policy WS-Security SOA support in J2EE

TOTAL : 45 PERIODS

OUTCOMES:

Upon successful completion of this course, students will be able to:

Build applications based on XML. Develop web services using technology elements. Build SOA-based applications for intra-enterprise and inter-enterprise applications.

9

S.K.P. Engineering College, Tiruvannamalai

TEXTBOOKS:

VII SEM

1. Ron Schmelzer et al. ―XML and Web Services‖, Pearson Education, 2002.

2. Thomas Erl, ―Service Oriented Architecture: Concepts, Technology, and Design‖, Pearson Education, 2005.

REFERENCES:

1. Frank P.Coyle, ―XML, Web Services and the Data Revolution‖, Pearson Education,

2002

2. Eric Newcomer, Greg Lomow, ―Understanding SOA with Web Services‖, Pearson

Education,2005

3. Sandeep Chatterjee and James Webber, ―Developing Enterprise Web Services: An

Architect's Guide‖, Prentice Hall, 2004. 4. James McGovern, Sameer Tyagi, Michael Stevens, Sunil Mathew, ―Java Web Services Architecture‖, Morgan Kaufmann Publishers, 2003

S.K.P. Engineering College, Tiruvannamalai

VII SEM

 

CONTENTS

S.No

Particulars

Page

1

Unit I

7

2

Unit II

38

3

Unit III

62

4

Unit IV

85

5

Unit V

113

S.K.P. Engineering College, Tiruvannamalai

Prerequisite

VII SEM

Following are the minimum prerequisites to get into SOA technology. Xml Xsl, Xslt Xpath Xsd (Xml Schema Definition) Wsdl Soap

Students without the required background may struggle to keep up with the lectures and assignments.

S.K.P. Engineering College, Tiruvannamalai

Unit I

Introduction To Xml

Part A

VII SEM

1. Define XML?.[ CO1 - L1]

XML stands for Extensible Markup Language much like HTML XML was designed to describe data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive XML is a W3C Recommendation

2. What are the major portions of an XML document structure?.[ CO1 - L1]

The XML declaration The Document Type Declaration The element data The attribute data The character data or XML content

3. What is meant by XML declaration?.[ CO1 - L1]

The first part of an XML document is the declaration. A declaration is exactly as it sounds: It is a definite way of stating exactly what the document contains. Example: The Declaration of Independence states that the United States planned to separate itself from Great Britain, the XML declaration states that the following document contains XML content.

4. Types of markup in an XML document.[ CO1 - L1]

Elements, Entity References, Comments, Processing Instructions, Marked Sections

5. Define Elements.[ CO1 - L1]

An XML document, elements are the most common form of markup. XML elements are either a matched pair of XML tags or single XML tags that are ―self-closing. Matching XML tags consist of markup tags that contain the same content, except that the ending tag is prefixed with a forward slash.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Example1: our shirt element begins with <shirt> and ends with </shirt>.

6.Define Entity References.[ CO1 - L1] There are times to introduce special characters or make use of content that is constantly repeated without having to enter it multiple times. This is the role of the XML entity.Entities provide a means to indicate to XML-processing applications that a special text string is to follow that will be replaced with a different literal value.Entity references are delimited by an ampersand at the beginning and a semicolon at the ending. The content contained between the delimiters is the entity that will be replaced. For example, the & lt;

7. Define Comments.[ CO1 - L1]

The character sequence <!-- begins a comment and --> ends the comment. Between these two delimiters, any text at all can be written, including valid XML markup.

Example: <!

The

below element talks about an Elephant I once owned…

>

8. Define Processing Instructions.[ CO1 - L1]

Processing instructions (PIs) perform a similar function as comments in that they are not

a textual part of an XML document but provide information to applications as to how the content should be processed. Processing instructions have the following form: <?instruction options?> Example: <?send-message ―process complete‖?>

9. Define Marked CDATA Sections.[ CO1 - L1]

Some documents will contain a large number of characters and text that an XML processor should ignore and pass to an application. These are known as character data

(or CDATA) sections. CDATA sections follow this general form: <![CDATA[content]]>

10. Define XML Content.[ CO1 - L1] The value of XML is greatly enhanced by the presence of content within the elements. •The content between XML elements is where most of the value lies in an XML document. XML elements are usually well defined and strict in their application. XML content can contain any characters, including any valid Unicode and international characters.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

11. What is meant by Well formed XML documents?.[ CO1 - L1 - Nov/Dec 2016]

An XML document is well formed if it follows all the preceding syntax rules of XML. On the other hand, if it includes inappropriate markup or characters that cannot be processed by XML parsers, the document cannot be considered well formed. It goes without saying that an XML document can‗t be partially well formed. And, by definition, if a document is not well formed, it is not XML. This means that there is no such thing as an XML document that is not well formed, and XML processors are not required to process these documents.

12. What do you meant by Valid Documents .[ CO1 - L1]

A well-formed XML document is considered valid only if it contains a proper Document Type Declaration and if the document obeys the constraints of that declaration. In most

cases, the constraints of the declaration will be expressed as a DTD or an XML Schema.

13. Comparison between well-formed XML documents and Valid XML

documents.[ CO1 L2] Well-formed XML documents are designed for use without any constraints, whereas valid XML documents explicitly require these constraint mechanisms. The possible elements and the ordering of those elements in a document, valid XML documents can take advantage of certain advanced features of XML that are not available to merely well-formed documents due to their lack of a DTD or XML Schema. The creation of well-formed XML is a simple process; the use of valid XML documents can greatly improve the quality of document processes. Valid XML documents allow users to take advantage of content management, business- to-business transactions, enterprise integration, and other processes that require the exchange of constrained XML documents.

14. What is XML namespace? .[ CO1 - L1 - Nov/Dec 2016]

XML allows document authors to create custom elements. This extensibility can result in

naming collisions (i.e. different elements that have the same name) among elements in an XML document. An XML namespace is a collection of element and attribute names. Each namespace has a unique name that provides a means for document authors to unambiguously refer to elements with the same name (i.e. prevent collisions).

15.What are the uses of XML?.[ CO1 - L1]

CML

Chemical Markup Language for chemical equations

MML

- Mathematical Markup Language for Mathematical equations and

derivations.

S.K.P. Engineering College, Tiruvannamalai

Used in bio medical line.

VII SEM

16. What is the use of XML .[ CO1 - L1]

Extensible Markup Language, derived from SGML (Standard Generalized Markup Language. XML is widely supported open technology (i.e. non-proprietary) for electronic data exchange and storage. XML is actually a language used to create other markup languages to describe data in a structured manner.

XML documents contain only data, not formatting instructions, so applications that process XML documents must decide how to manipulate or display the document‗s data.

17.What do you mean by DTD in XML?.[ CO1 - L1 - Nov/Dec 2016] DTD means Document Type Definition. DTD file is similar to CSS file, because DTD also contains only styles. DTD contains various styles which are to be applied in XML document. Like .CSS file .DTD file also should be linked with XML program. Styles in XML program should be save with .xsl (Xml Style Sheet Language) extension.

18. Define XML.[ CO1 - L1]

XML is a meta-markup language that provides a format for describing structured data. This facilitates more structured declarations of content and more meaningful search results across multiple platforms.

19. Define DTD.[ CO1 - L1]

A DTD is a set of rules that specifies how to use XML markup. It contains specifications for each element, including what the element\'s attributes are, what values the attributes can take on and what elements can be contained in others.

20. What are the XML rules for distinguishing between the content of a document

and the XML markup element? .[ CO1 - L1] The start of XML markup elements is identified by either the less than symbol (<) or the

ampersand (&) character Three other characters, the greater than symbol (>), the apostrophe or single quote (‗) and the double quotation marks (―) are used by XML for markup. To use these special characters as content within your document, you must use the corresponding general XML entity.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

21. What is XQuery?.[ CO1 - L1]

XQuery is a W3C initiative to define a standard set of constructs for querying and searching XML documents. XQuery brings database query processing to XML.

22.What is XForm?.[ CO1 - L1] XForm is an XML approach that overcomes the limitations of HTML forms. XForm includes a variety of buttons, scrollbars and menus. It generates XML form data as output. XForm\'s model has the capability to work with the variety of user interfaces

23.What is XPath?.[ CO1 - L1] Xpath is used to navigate XML tree structures. XPath gets its name from its use of a path notation to navigate through the hierarchical tree structure of an XML document. It is an important XML technology due to its role in providing a common syntax and semantics for functionality in both XSLT and XPointer.

24. What are complex types?.[ CO1 - L1]

Complex types are an important aspects of xml schema that allow application developers to define application-specific datatypes that can be checked by programs

that check XML document for validity. XML schema divides complex types into two categories: those with simple content & those with complex content.

25. What all are the presentation technologies?.[ CO1 - L1]

CSS - Cascading Syle Sheets XSL - provides users with ability to describe how xml data & document are to be formated. Xforms - it is a GUI toolkit for creating user interfaces & delivering the results in XML. Xhtml - it is used yo replace HTML with more flexable approach to display web content. VoiceXML - it is an emerging standard for speech enabled application.

26.What are all the Transformation techniques?.[ CO1 - L1] XSLT - it is an XML- based languages used to transform XML documents into others format such as HTML for web display. XLINK - highlighting that element or taking the user directly to that point in the document.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

XPATH - xpath gets its name from its use of a payh notation to navigate through the hierarchical tree structure of an XML document XQUERY - it is w3c initiative to define a standard set of constructs for querying & searching XML document.

27.Explain any two XForm implementations?.[ CO1 - L1] X-Smiles - it is a java based XML browser.it implements a large part of X-forms & uses X-form together with XSL-FO on user interface side. Mozquito Xforms preview - is an XML based Web development s/w that implements Xforms & gives current Web browser the ability to send, receive & process XML document.

28.What is metadata?.[ CO1 - L1] Literally data about data. XML element and attribute names are considered Metadata in that they may be used to describe the data contained in a document. Metadata isn‗t needed but it certainly helps.

29.What is XML? How it is different from HTML?.[ CO1 - L1 - Nov/Dec 2016] Xml is the text based make up language that stores the data in a structured format using meaningful tags. It allows computers to store and exchange data in a format that can be interpreted by any other computer with different hardware or software specification. XML HTML Language.2.Several languages are derived from xml & wml HTML can be derived from xml. Xml uses indefinite, user defined, meaningful set of tags which can be used to include XML data in the webpage. HTML uses a fixed set of tags which can be used to specify the appearance of the webpage.

30. Why DTD?.[ CO1 - L1]

XML documents are designed to be processed by computer programs If you can put just any tags in an XML document, it‗s very hard to write a program that knows how to process the tags

A DTD specifies what tags may occur, when they may occur, and what attributes they

may (or must) have

31. How to represent the XML Document?.[ CO1 - L1]

In any markup language, the first element to appear is called the "root element", which

defines what kind of document the file will be.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

In an HTML file, the <html> tag is the root element.

An HTML file will always have the HTML element as the root element, while in an XML file, it can be anything. Eg: <phonebook><number></number> <name></name></phonebook>

32. What is PCDATA in XML?.[ CO1 - L1]

Parsed Character Data (PCDATA) is a term used about text data that will be parsed by the XML parser. XML parsers normally parse all the text in an XML document.When an

XML element is parsed, the text between the XML tags is also parsed:

<message>This text is also parsed</message>

33. What is the purpose of the XML DTD?.[ CO1 - L1]

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

structure with a list of legal elements:

<!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)> ]>

34. What is RSS?.[ CO1 - L1]

Really Simple Syndication (RSS) is a lightweight XML format designed for sharing headlines and other Web content RSS defines an XML grammar (a set of HTML-like tags) for sharing news. Each story is defined by an <item>, which contains a headline TITLE, URL, and DESCRIPTION

35. Define XPath.[ CO1 - L1]

The XML Path Language (XPath) is a standard for creating expressions that can be used to find specific pieces of information within an XML document. XPath expressions are used by both XSLT (for which XPath provides the core functionality) and XPointer to locate a set of nodes. XPath expressions have the ability to locate nodes based on the nodes‗ type, name, or value or by the relationship of the nodes to other nodes within the XML document.

In addition to being able to find nodes based on these criteria, an XPath expression can

also return any of the following:

A node set

A Boolean value

A string value

A numeric value

S.K.P. Engineering College, Tiruvannamalai

VII SEM

36.

What are all the priorities available for evaluating XPath expressions?.[ CO1 -

L1]

Grouping Filters Path operations

37. Define XPath Syntax.[ CO1 - L1]

The basic syntax for an XPath expression:

axis::node test[predicate]

38. Define XPath Functions.[ CO1 - L1]

XPath functions are used to evaluate XPath expressions and can be divided into one of four main groups:

Boolean

Node set

Number

String

39. What are the types of XLink Attributes.[ CO1 - L1]

xlink:type

xlink:href

xlink:role

xlink:title

xlink:show

xlink:actuate

xlink:label

xlink:from

xlink:to

 

PART-B

1.

Explain the XML syntax rules in detail.[ CO1 L2]

XML XML stands for EXtensible Markup Language much like HTML XML was designed to describe data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive XML is a W3C Recommendation

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The Difference Between XML and HTML XML is not a replacement for HTML. XML and HTML were designed with different goals:

XML was designed to describe data, with focus on what data is HTML was designed to display data, with focus on how data looks HTML is about displaying information, while XML is about carrying information.

XML syntax rules 1.An XML document consists of markup and character data. 2.There are two types of markup: tags and references. 3.Tags begin with a less-than (<) character and end with a greater-than (>) character. Example: <name>This is a paragraph.</name> 4.References in an XML document begin with an ampersand (&) and are of two types:

character references (such as &#x20;) and entity references (such as &lt;). 5.All XML documents may make references to the entities lt, gt, amp, apos, and quot, which map to the characters less than (<), greater than (>), ampersand (&), single quote ('), and double quote ("), respectively. If not used to begin markup, the characters < and & must be escaped 6.Element tags are of three types: start tags, end tags (which begin with </), and empty- element tags (which end with />). 7.Character data may only appear within a non-empty element.

Example :

<empname>This is a character data.</empname> Start and end tags must be paired and must be properly nested with other pairs of start and end tags.

Example:

<b><i>This text is bold and italic</i></b> Attribute specifications may appear within start tags or empty-element tags. Every attribute specification consists of an attribute name followed by an equals sign (=) followed by a quoted attribute value.

Example:

<img src=‖flower.jpg‖ alt=‖flower‖ /> An attribute value may not contain the character <; if the character & appears, it must be the first character in a character or entity reference. A pair of either single quotes or double quotes may be used to quote an attribute value. Attribute specifications are white-space-separated from one another.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Element and attribute names are case sensitive. Example: <Message>This is incorrect</message> <message>This is correct</message> The XML white space characters are the same as in XHTML: space, carriage return, line feed, and tab.

2.Explain how a XML document can be displayed on a browser.[ CO1 L2]

Displaying XML documents in Browsers XSL stands for Extensible Stylesheet Language. CSS was designed for styling HTML pages, and can be used to style XML pages. Program 1- employee.xml <?xml version = "1.0" ?> <?xmlstylesheethref="empdetail.css"type="text/css"?><Employee-Detail> <Employee> <Emp_Id> 11032 </Emp_Id><Emp_Name> Geetha </Emp_Name> <Emp_E-mail>geetha@gmail.com </Emp_Email></Employee> <Employee> <Emp_Id> 11022 </Emp_Id><Emp_Name> sumalatha</Emp_Name> <Emp_E-mail> jsumalatha@gmail.com </Emp_Email></Employee> <Employee> <Emp_Id> 11011 </Emp_Id><Emp_Name> Lakshmanan </Emp_Name> <Emp_E-mail> lakshmimurugan@gmail.com </Emp_E-mail></Employee> </Employee-Detail> Program 2- empdetail.css Employee-Detail { color:orange; } Employee,Emp_Id, Emp_Name

{

display:block; font-size:25px; text-transform:capitalize; word-spacing:50px; }}

3. Explain in detail about XML document Structure?.[ CO1 L2 - Nov/Dec 2016] An XML document consists of a number of discrete components or sections. Although not all the sections of an XML document may be necessary, their use and inclusion helps to make for a well-structured XML document that can easily be transported between systems and devices. The major portions of an XML document include the following:

The XML declaration The Document Type Declaration The element data

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The attribute data The character data or XML content XML Declaration The first part of an XML document is the declaration. A declaration is exactly as it sounds: It is a definite way of stating exactly what the document contains. Example: The Declaration of Independence states that the United States planned to separate itself from Great Britain, the XML declaration states that the following document contains XML content.

not

required, the presence of the declaration explicitly identifies the document as an XML document and indicates the version of XML to which it was authored.The XML

declaration indicates the presence of external markup declarations and character encoding. Because a number of documents formats use markup similar to XML, the declaration is useful in establishing the document as being compliant with a specific version of XML without any doubt or ambiguity.

The XML declaration is a processing instruction of the form <?xml

?>.

It

is

In general, every XML document should use an XML declaration. As documents

increase in size and complexity, this importance likewise grows.Components of the XML

description:The standalone document declaration defines whether an external DTD will be processed as part of the XML document.When standalone is set to ―yes‖, only

internal DTDs will be allowed.When it is set to ―no‖, an external DTD is required and

an internal DTD becomes an optional feature.

Valid XML Declarations:

<?xml version=‖1.0‖ standalone=‖yes‖?> <?xml version=‖1.0‖ standalone=‖no‖?> <?xml version=‖1.0‖ encoding=‖UTF-8‖ standalone=‖no‖?> The first declaration defines a well-formed XML document, whereas the second defines a well-formed and valid XML document. The third declaration shows a more complete definition that states a typical use-case for XML.

Document Type Declaration The Document Type Declaration (DOCTYPE) gives a name to the XML content and

provides a means to guarantee the document‗s validity, either by including or specifying

a link to a Document Type Definition (DTD).SGML requires a Document Type

Declaration, XML has no restrictions of the sort, although one should be included to avoid an ambiguous understanding of document content.well-formed XML documents

S.K.P. Engineering College, Tiruvannamalai

VII SEM

don‗t require the inclusion of the DOCTYPE, valid XML documents do.Valid XML documents must declare the document type to which they comply, whereas well-formed XML documents can include the DOCTYPE to simplify the task of the various tools that will be manipulating the XML document. A Document Type Declaration names the document type and identifies the internal content by specifying the root element, in essence the first XML tag that the XML- processing tools will encounter in the document.A DOCTYPE can identify the constraints on the validity of the document by making a reference to an external DTD subset and/or include the DTD internally within the document by means of an internal DTD subset.

General forms of the Document Type Declarations:

<!DOCTYPE NAME SYSTEM ―file‖> <!DOCTYPE NAME [ ]> <!DOCTYPE NAME SYSTEM ―file‖ [ ]> The first declaration, the DOCTYPE is referring to a document that only allows use of an externally defined DTD subset. The second declaration only allows an internally defined subset within the document. The final listing provides a place for inclusion of an internally defined DTD subset between the square brackets while also making use of an external subset. In the preceding listing, the keyword NAME should be replaced with the actual root element contained in the document, and the ―file‖ keyword should be replaced with a path to a valid DTD.

Markup and Content

The six kinds of markup can occur in an XML document:

1. elements,

2. entity references,

3. comments,

4. processing instructions,

5. marked sections,

6. Document Type Declarations.

1.Elements

An XML document, elements are the most common form of markup. XML elements are either a matched pair of XML tags or single XML tags that are ―self-closing. Matching XML tags consist of markup tags that contain the same content, except that the ending tag is prefixed with a forward slash.

Example1:

our shirt element begins with <shirt> and ends with </shirt>.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Example2:

<on_sale/>. In this case, there would be no other matching element of the same name used in a different manner. These ―unmatched‖ elements are known as empty elements. The trailing ―/>in the modified syntax indicates to a program processing the XML document that the element is empty and no matching end tag should be sought. The XML is a hierarchical tree. This means that XML elements exist within other elements and can branch off with various children nodes. The nature of XML is to allow for the growth of these elements in a manner that‗s as ―wide‖ or ―deep‖ as possible. This means that a single XML element can contain any number of child elements, and the depth of the XML tree can consist of any number of nodes. XML elements can contain letters, numbers, and other characters, but names cannot start with a number or any punctuation character. XML names cannot contain spaces because white spaces, is used within an element to separate the various attribute sections. Also, XML elements cannot contain the greater-than or less-than characters for obvious reasons. XML elements cannot start with the letters ―xml‖ because they are reserved for future use. XML elements cannot contain the colon character because it is reserved for use in XML namespaces. Although punctuation marks (other than the colon) can be used within an XML element name, you should avoid the hyphen (-) and period (.) Element names can be as long as you like, with almost no real size limitation. This means that the element <wow_this_really_is_one_heck_of_a_long_element_name> is actually valid, but what programmer would want to type that element repeatedly or encode a software application to key on that particular element name. Also, some devices with constrained memory capabilities may not work well with overly long XML tag names. XML also allows for the use of non-English letters, such as á, é, and ò, in a document. In fact, XML allows all Unicode 2.3 characters. Attributes Attributes are name/value pairs contained within the start element that can specify text strings that modify the context of the element. Example: <price currency= ―USD‖>_</price>

2.Entity References There are times to introduce special characters or make use of content that is constantly repeated without having to enter it multiple times. This is the role of the XML entity

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Entities provide a means to indicate to XML-processing applications that a special text string is to follow that will be replaced with a different literal value. Each entity has a unique name that is defined as part of an entity declaration in a DTD or XML Schema. Entities are used by simply referring to them by name. Entity references are delimited by an ampersand at the beginning and a semicolon at the ending. The content contained between the delimiters is the entity that will be replaced. For example, the &lt; entity inserts the less-than sign (<) into a document. Elements can be encoded so they aren‗t processed or replaced by their entity equivalents in order to be used for display or encoding within other element values. For example, the string <element> can be encoded in an XML document as & lt; element & gt;, and it therefore will not be processed.

3.Comments

Comments are quite simple to include in a document. The character sequence <!-- begins a comment and --> ends the comment. Between these two delimiters, any text at all can be written, including valid XML

markup. The only restriction is that the comment delimiters cannot be used; neither can the literal string Comments can be placed anywhere in a document and are not considered to be part of the textual content of an XML document.

Example: <!

The

below element talks about an Elephant I once owned…

>

4. Processing Instructions

Processing instructions (PIs) perform a similar function as comments in that they are not

a textual part of an XML document but provide information to applications as to how the content should be processed. Processing instructions have the following form: <?instruction options?> The instruction name, called the PI target, is a special identifier that the processing application is intended to understand. Example: <?send-message ―process complete‖?>

5. Marked CDATA Sections

Some documents will contain a large number of characters and text that an XML processor should ignore and pass to an application. These are known as character data (or CDATA) sections.Within an XML document, a CDATA section instructs the parser to ignore all markup characters except the end of the CDATA markup instruction. This allows for a section of XML code to be ―escaped‖ so that it doesn‗t inadvertently disrupt XML processing. CDATA sections follow this general form: <![CDATA[content]]>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

In the content section, any characters can be included, with the necessary exception of the character string ]]>. <object_code> <![CDATA[ Function master(poltice integer){ If poltice<=3 then { IntMaster=poltice+IntToString(FindElement(―<chicken>‖));

}

}

]]></object_code>

6.Document Type Definitions Document Type Definitions (DTDs) provide a means for defining what XML markup can occur in an XML document. Basically, the DTD provides a mechanism to guarantee that

a given XML document complies with a well-defined set of rules for document structure

and content. These rules provide a framework for guaranteeing the ―validity‖ of a document. XML Content The value of XML is greatly enhanced by the presence of content within the elements. The content between XML elements is where most of the value lies in an XML document.XML elements are usually well defined and strict in their application.When a DTD or XML Schema is used, users can‗t change these portions of the document.XML

content can contain any characters, including any valid Unicode and international characters.The content can be as long as necessary and contain hundreds of megabytes of textual information, if required. The size of the content is an implementation decision.

4.Explain in detail about Well-Formed and Valid Documents?.[ CO1 L2] Well-Formed and Valid Documents XML documents can be well formed, and they can also be valid. Validity implies ―well- formed.

Well-Formed Documents An XML document is well formed if it follows all the preceding syntax rules of XML.

On the other hand, if it includes inappropriate markup or characters that cannot be processed by XML parsers, the document cannot be considered well formed.

It goes without saying that an XML document can‗t be partially well formed. And, by

definition, if a document is not well formed, it is not XML. This means that there is no such thing as an XML document that is not well formed, and XML processors are not required to process these documents.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Valid Documents A well-formed XML document is considered valid only if it contains a proper Document Type Declaration and if the document obeys the constraints of that declaration. In most cases, the constraints of the declaration will be expressed as a DTD or an XML Schema.

Comparison between well-formed XML documents and Valid XML documents:

Well-formed XML documents are designed for use without any constraints, whereas valid XML documents explicitly require these constraint mechanisms.

The possible elements and the ordering of those elements in a document, valid XML documents can take advantage of certain advanced features of XML that are not available to merely well-formed documents due to their lack of a DTD or XML Schema. The creation of well-formed XML is a simple process; the use of valid XML documents can greatly improve the quality of document processes.

Valid XML documents allow users to take advantage of content management, business- to-business transactions, enterprise integration, and other processes that require the exchange of constrained XML documents.

5. Explain the role of XML name spaces with example.[ CO1 L2] XML namespaces - XML Namespace is used to avoid element name conflict in XML document.The XML Namespace recommendation provides a mechanism for identifying each element and attribute name within a document with a specific XML vocabulary. An XML namespace is a collection of element and attribute names associated with a particular XML vocabulary (such as XHTML) through an absolute URI known as the namespace name

Default namespace :

<html xmlns="http://www.w3.org/1999/xhtml"> XML Namespace Declaration - An XML namespace is declared using the reserved XML attribute. This attribute name must be started with "xmlns".

XML namespace syntax:

<element xmlns:prefixname = "URI"> Namespace starts with keyword "xmlns". The word name is a namespace prefix. The URL is a namespace identifier.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Example <?xmlversion="1.0" encoding="UTF-8"?> <cont:contact xmlns:cont="http://sssit.org/contact-us"> <cont:name>VimalJaiswal</cont:name> <cont:company>SSSIT.org</cont:company> <cont:phone>(0120) 425-6464</cont:phone> </cont:contact> Namespace Prefix: cont Namespace Identifier: http://sssit.org/contact-us It specifies that the element name and attribute names with cont prefix belongs to http://sssit.org/contact-us name space. In XML, elements name are defined by the developer so there is a chance to conflict in name of the elements. To avoid these types of confliction we use XML Namespaces. The XML Namespaces provide a method to avoid element name conflict. Generally these conflicts occur when we try to mix XML documents from different XML application.

Table 1:

<table>

<tr>

<td>Aries</td>

<td>Bingo</td>

</tr>

</table>

Table 2:

This table carries information about a computer table. <table> <name>Computer table</name>

<width>80</width

><length>120</length>

</table> If you add these both XML fragments together, there would be a name conflict because both have <table>element. Although they have different name and meaning How to get rid of name conflict? 1) By Using a Prefix Table 1:<h:table> <h:tr><h:td>Aries</h:td> <h:td>Bingo</h:td></h:tr>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

</h:table> Table 2:<f:table> <f:name>Computer

table</f:name><f:width>80</f:width><f:length>120</f:length></f:table>

Note: In this example, you will get no conflict because both the tables have specific names. 2) By Using xmlns Attribute <root> <h:table xmlns:h="http://www.abc.com/TR/html4/"><h:tr> <h:td>Aries</h:td> <h:td>Bingo</h:td> </h:tr> </h:table> <f:table:xmlns:f="http://www.xyz.com/furniture"><f:name>Computer

table</f:name><f:width>80</f:width><f:length>120</f:length>

</f:table> </root> In the above example, the <table> element defines a namespace and when a namespace is defined for an element, the child elements with the same prefixes are associated with the same namespace.

<rootxmlns:h="http://www.abc.com/TR/html4/"

xmlns:f="http://www.xyz.com/furniture"><h:table> <h:tr> <h:td>Aries</h:td> <h:td>Bingo</h:td> </h:tr> </h:table> <f:table> <f:name>Computer table</f:name><f:width>80</f:width><f:length>120</f:length> </f:table> </root> Note: The Namespace URI used in the above example is not necessary at all. It is not used by parser to look upinformation. It is only used to provide a unique name to the Namespace identifier.

Uniform Resource Identifier (URI) Uniform Resource Identifier is used to identify the internet resource. It is a string of characters. The most common URI is URL (Uniform Resource Locator) which identifies

S.K.P. Engineering College, Tiruvannamalai

VII SEM

an internet domain address. There is also an URI name URN (Universal Resource Name) but it is not so common.

The Default Namespace The default namespace is used in the XML document to save you from using prefixes in all the child elements.The only difference between default namespace and a simple namespace is that: There is no need to use a prefix in default namespace.You can also use multiple namespaces within the same document just define a namespace against a child node.

Example of Default Namespace:

<tutorials xmlns="http://www.javatpoint.com/java-tutorial"><tutorial> <title>Java-tutorial</title><author>Sonoo Jaiswal</author>

</tutorial>

</tutorials>

You can see that prefix is not used in this example, so it is a default namespace. Note: If you define a namespace without a prefix, all descendant elements are

considered to belong to that namespace.

6.Briefly discuss about XML and DTD. Write a DTD for employee including employee name (firstname and lastname) Employee Date of birth (month, Date and Year) and address (city and state) .[ CO1 L2] XML and DTD

A DTD (Document Type Definition) describes the structure of one or more XML

documents. Specifically, a DTD describes:

Elements

Attributes, and

Entities

An XML document is well-structured if it follows certain simple syntactic rules An XML document is valid if it also specifies and conforms to a DTD

Why DTD?

A DTD allows the XML document to be verified (shown to be legal)

A DTD that is shared across groups and allows the groups to produce consistent XML

documents Parsers An XML parser is an API that reads the content of an XML document,Currently popular APIs are DOM (Document Object Model) and SAX (Simple API for XML) A validating parser is an XML parser that compares the XML document to a DTD and reports any errors.Most browsers don‗t use validating parser

S.K.P. Engineering College, Tiruvannamalai

VII SEM

An XML example

<novel>

<foreword>

<paragraph>This is the great American novel.</ paragraph></foreword>

<chapter number="1">

<paragraph>It was a dark and stormy night.</paragraph><paragraph>Suddenly, a shot rang out!</paragraph>

</chapter>

</novel>

An XML document contains (and the DTD describes):

Elements, such as novel and paragraph, consisting of tags and content

Attributes, such as number="1", consisting of a name and a value Entities (not used in this example)

A DTD example

<!DOCTYP E novel [ <!ELEMENT novel (foreword, chapter+)><!ELEMENT foreword(paragraph+)>

<!ELEMENT chapter (paragraph+)> <!ELEMENT paragraph(#PCDATA)> <!ATTLIST chapter number CDATA #REQUIRED> ]>

A novel consists of a foreword and one or more chapters, in that order

Each chapter must have a number attribute

A foreword consists of one or more paragraphs

A chapter also consists of one or more paragraphs

A paragraph consists of parsed character data (text that cannot contain any other

elements)

ELEMENT descriptions Suffixes:

?

optional

foreword?

+

one or more chapter+

*

zero or more appendix*

Separators:

both, in order foreword?, chapter+

| or

Grouping:

( )

Element Syntax

section chapter

grouping

(section |chapter)+

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Element defines tagname <!ELEMENT tagname (values)> Values defines child elements <!ELEMENT tagname (child1, child2)> The type of the element <!ELEMENT tagname (type)>Types? #PCDATA, EMPTY or ANY In the DTD: <!ELEMENT br EMPTY> In the XML: <br></br> or just <br /> In the XML, an empty element may not have any content between the start tag and the end tag. Attributes and entities The format of an attribute is: <!ATTLIST element-name Internal: DTD is part of the declaration and is embedded into the XML document. External: DTD is an external file and declaration links to the file.

Program 1- XML FILE <?xml version="1.0"?> <!DOCTYPE weather Report SYSTEM "http://www.mysite.com/mydoc.dtd"><employee> <employee_name><firstname>Geetha</firstname><lastname>Virdi</lastname></emplo yee_name><employee_dob><date>twenty

second</date><month>April</month><year>2000</year><employee_dob>

<address> <city>Villupuram</city> <state>Tamilnadu</state> </address> <employee> Program 2 DTD FILE for XML <!ELEMENT employee(employee_name, employee_dob, address)> <!ELEMENT employee_name(firstname, lastname)> <!ELEMENT firstname(#PCDATA)> <!ELEMENT lastname(#PCDATA)> <!ELEMENT employee_dob(date, month, year)> <!ELEMENT date (#PCDATA)> <!ELEMENT month(#PCDATA)> <!ELEMENT year(#PCDATA)> <!ELEMENT address(city, state)> <!ELEMENT city(#PCDATA)> <!ELEMENT state(#PCDATA)>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

7. Explain in detail and give example of XML Schema?.[ CO1 L2 - Nov/Dec 2016] What is an XML Schema? An XML Schema describes the structure of an XML document. The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.

An XML Schema:

Elements that can appear in a document Attributes that can appear in a document Which elements are child elements The order of child elements The number of child elements Whether an element is empty or can include text Data types for elements and attributes Default and fixed values for elements and attributes

Why Use XML Schemas? XML Schema is an XML-based alternative to DTD. XML Schemas are much more powerful than DTDs. The XML Schema language is also referred to as XML Schema Definition (XSD).

XML Schemas use XML Syntax Another great strength about XML Schemas is that they are written in XML. Some benefits of that XML Schemas 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

XML Schemas Secure Data Communication When sending data from a sender to a receiver, it is essential that both parts have the same "expectations" about the content. Example:

With XML Schemas, the sender can describe the data in a way that the receiver will understand. A date like: "03-11-2004" will, in some countries, be interpreted as 3.November and in other countries as 11.March.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

However, an XML element with a data type like this:

<date type="date">2004-03-11</date> ensures a mutual understanding of the content, because the XML data type "date" requires the format "YYYY-MM-DD". XML Schemas are Extensible XML Schemas are extensible, because they are written in XML. With an extensible Schema definition you can:

Reuse your Schema in other Schemas

Create your own data types derived from the standard types

Reference multiple schemas in the same document

XML Schema Valid XML Document for XML Schema (employee.xml) <?xml version="1.0"?> <Employee_Info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="employee.xs"> <Employee Employee_Number="105"> <Name>Masashi Okamura</Name> <Department>Design Department</Department>

<Telephone>03-1452-4567</Telephone>

<Email>okamura@xmltr.co.jp</Email> </Employee> <Employee Employee_Number="109"> <Name>Aiko Tanaka</Name> <Department>Sales Department</Department>

<Telephone>03-6459-98764</Telephone>

<Email>tanaka@xmltr.co.jp</Email>

</Employee>

</Employee_Info>

Employee Information XML Schema employee.xs<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ><xs:element name="Employee_Info" type="EmployeeInfoType" /> <xs:complexTypename="EmployeeInfoType"> <xs:sequence> <xs:element ref="Employee" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

</xs:complexType> <xs:element name="Employee" type="EmployeeType" /> <xs:complexType name="EmployeeType"> <xs:sequence > <xs:element ref="Name" /> <xs:element ref="Department" /><xs:element ref="Telephone" /> <xs:element ref="Email" /> </xs:sequence <xs:attribute name="Employee_Number" type="xs:int" use="required"/> </xs:complexType> <xs:element name="Name" type="xs:string" /> <xs:element name="Department" type="xs:string" /> <xs:element name="Telephone" type="xs:string" /> <xs:element name="Email" type="xs:string" /> </xs:schema>

Employee Information DTD (emp.dtd) <!ELEMENT Employee_Info (Employee)*> <!ELEMENT Employee (Name, Department, Telephone, Email)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Department (#PCDATA)> <!ELEMENT Telephone (#PCDATA)> <!ELEMENT Email (#PCDATA)> <!ATTLIST Employee Employee_Number CDATA #REQUIRED> <?xml version="1.0"?> <!DOCTYPE note SYSTEM "http://www.w3schools.com/dtd/emp.dtd"><note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body></note>

8.Explain in detail about X-Files.[ CO1 L2 - Nov/Dec 2016] The XML Path Language provides a standard syntax for querying an XML document for specific pieces of information. This syntax provides an independent mechanism for ―querying‖ or locating the desired elements or attributes within the XML document. XPath, itself, is a very powerful mechanism for finding the elements or attributes. XPath was createdto reduce the amount of time to find the elements and attributes desired by an author or developer.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

XLink allows an XML document to specify a link from the current document to another document in another location. XPointer expands on the functionality of XLink by building on the XPath specification and identifying a node or node set to link to in the target document. This provides much the same functionality as a foreign key within a table of a database.XPointers provide the same functionality within a group of XML documents.XPath The XML Path Language (XPath) is a standard for creating expressions that can be used to find specific pieces of information within an XML document.XPath expressions are used by both XSLT (for which XPath provides the core functionality) and XPointer to locate a set of nodes.XPath expressions have the ability to locate nodes based on the nodes‗ type, name, or value or by the relationship of the nodes to other nodes within the XML document.In addition to being able to find nodes based on these criteria, an XPath expression can also return any of the following:

1. A node set

2. A Boolean value

3. A string value

4. A numeric value

Operators and Special Characters XPath expressions are composed using a set of operators and special characters, each with its own meaning. Table lists the various operators and special characters used within the XML Path Language. The priority for evaluating XPath expressions is as follows:

1. Grouping

2. Filters

3. Path operations

XPath Syntax The XML Path Language provides a declarative notation, termed a pattern, used to select the desired set of nodes from XML documents. Each pattern describes a set of matching nodes to select from a hierarchical XML document. Each pattern describes a ―navigation‖ path to the desired set of nodes similar to the Uniform Resource Identifier (URI) syntax.

A location path is, itself, made up of one or more location steps. Each step is further comprised of three pieces:

An axis

A node test

A predicate

The basic syntax for an XPath expression:axis::node test[predicate]

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Axis The axis portion of the location step identifies the hierarchical relationship for the desired nodes from the current context. Every axis has a principal node type:

If an axis is an element, the principal node type is element; otherwise, it is the type of node the axis can contain. If the axis is attribute, the principal node type is attribute.

A node test may also contain a node name, or QName. In this case, a node with the

specified name is sought, and if found, it‗s returned in the node set. However, the nodes selected in this manner must be the principal node type sought and have an expanded name equal to the QName specified. This means that if the node belongs to a namespace, the namespace must also be included in the node test for the node to be selected.

For instance, ancestor::div and ancestor::test:div will produce two entirely different node sets. In this first case, only nodes that have no namespace specified and have a name

of div will be selected. In the second case, only those div nodes belonging to the test

namespace will be selected.

In addition to specifying an actual node name, other node tests are available to select

the desired nodes. Here‗s a list of these node tests:

comment()

node()

processing-instruction()

text()

The comment() node test selects comment nodes from an XML document. The node() node test selects a node of any type, whereas the text() node test selects those nodes that are text nodes. The processing-instruction() node test, because this node test will accept a literal string parameter to specify the name of a desired processing instruction.

Predicates The predicate portion of a location step filters a node set on the specified axis to create

a new node set. Each node in the preliminary node set is evaluated against the predicate to see whether it matches the filter criteria.

If it does, the node ends up in the filtered node set. Otherwise, it doesn‗t.

A predicate may consist of a filter condition that is applied to an axis that either directs

the condition in a forward or reverse direction.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

A forward axis predicate contains the current context node and nodes that follow the

context node.

A reverse axis predicate contains the current context node and nodes that precede the

context node. XPath Functions XPath functions are used to evaluate XPath expressions and can be divided into one of four main groups:

Boolean

Node set

Number

String

XPointer An XPointer uses location steps the same as XPath but with two major differences:

Because an XPointer describes a location within an external document, an XPointer can target a point within that XML document or a range within the target XML document. Because XPointer builds on the XPath specification, the location steps within an XPointer are comprised of the same elements that make up XPath location steps. The node tests already listed for XPath expressions

XPointer provides two more important node tests:

1. point()

2. range()

point can represent the location immediately before or after a specified character or the location just before or just after a specified node.

A range consists of a start point and an endpoint and contains all XML information

between those two points. An XPath expression, the result from a location step is known as a node set; for an

XPointer expression, the result is known as a location set.

To reduce the confusion, the XPointer specification uses a different term for the results

of an expression:

An XPointer expression can yield a result consisting of points or ranges, the idea of the node set had to be extended to include these types. Therefore, to prevent confusion,

theresults of an XPointer expression are referred to location sets. Four of the functions that return location sets, id(), root(), here(), and origin(). The id() function works exactly the same as the id() function for an XPath expression. The root() function works just like the / characterit indicates the root element of an XML document

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The next two functions, here() and origin(), are interesting functions in their own right. The here() function, as indicated, refers to the current element. Points Many times a link from one XML document into another must locate a specific point within the target document. Two different types of points can be represented using XPointer points:

1. Node points

2. Character points

Node points are location points in an XML document that are nodes that contain child nodes. For these node points, the index position indicates after which child node to navigate to. If 0 is specified for the index, the point is considered to be immediately before any child nodes. A node point could be considered to be the gap between the child nodes of a container node. When the origin node is a text node, the index position indicates the number of characters. These location points are referred to as character points. Because you are indicating the number of characters from the origin, the index specified must be an integer greater than or equal to 0 and less than or equal to the total length of the text within the text node.

Ranges An XPointer range defines just thata range consisting of a start point and an endpoint. A range will contain the XML between the start point and endpoint but does not necessarily have to consist of neat sub trees of an XML document. A range can extend over multiple branches of an XML document. The only criterion is that the start point and endpoint must be valid. Within the XPointer Language, a range can be specified by using the keyword to within the XPointer expression in conjunction with the start-point() and end-point() functions.

Abbreviating XPointer Notation

1. XPointer expressions, generally elements will be referenced by ID or by location. For just this reason, the XML Pointer Language added a few abbreviated forms of reference.

2. In addition to all the standard XPath abbreviations, XPointer goes one

step beyond that:

3. XPointer allows you to remove the [ and ] characters from the index position. Therefore, the expression

4. /People/Person[1]/Name[1] becomes this:

5. Overall, it‗s a much shorter expression. However, speaking from experience, this does

S.K.P. Engineering College, Tiruvannamalai

VII SEM

6. not tend to lend itself well to actual implementation.

7. The reasoning behind this goes back to what XML was designed for in the first place: to give meaning and structure to data.

8. By specifying the XPointer expression as 1/1/1, lose all documentation regarding what it is we‗re looking forhave to know, off the tops of our heads, that are going to be selecting the first <Name> element of the first <Person> element of the <People> element.

XLink

1. The anchor element, <a>, within HTML indicates a link to another resource on an HTML page. This could be a location within the same document or a document located elsewhere. In HTML terms, the anchor element creates a hyperlink to another location.

2. The hyperlink can either appear as straight text, a clickable image, or a combination of both.

3. The XML Linking Language creates a link to another resource through the use of attributes specified on elements, not through the actual elements themselves.

1. xlink:type:

The xlink:type attribute must contain one of the following values:

Simple - A value of simple creates a simple link between resources. Extended - A value of extended creates an extended link. Locator - A value of locator creates a link that points to another resource. Arc - A value of arc creates an arc with multiple resources and various traversal paths. Resource - A resource value creates a link to indicate a specific resource. Title - A value of title creates a title link none - a value of none for the xlink:type attribute, the parent element has no XLink meaning, and no other XLink-related content or attributes have any relationship to the element.

2.xlink:href:

The xlink:href attribute supplies the location of the resource to link to. This attribute is a URI reference that can be used to find the desired resource.

3.xlink:role:

The xlink:role attribute specifies the function of the link. This attribute may only be used for the following XLink types:

Extended

Simple

Locator

S.K.P. Engineering College, Tiruvannamalai

Resource

VII SEM

4.xlink:arcrole

The xlink:arcrole attribute may only be used with two types of XLinks:

Arc

Simple

5.xlink:title

The xlink:title attribute is completely optional and is provided for us to make some sense of and document, in a way, what a particular link is. If the xlink:title attribute is specified, it should contain a string describing the resource.

6.xlink:show

The xlink:show attribute is an optionally specified attribute for a link for the simple and arc XLink types and will accept the following values:

New- A value of new is specified, the resource will be loaded into a new window. Replace - A value of replace indicates that the resource should be loaded into the current window Embed - A value of embed will load the resource into the specified location and wrap the originating resource around it, as appropriate. Other - A value of other allows each application using XLinks to look for other indications within the XML document to determine what needs to be done. None - A value of none has essentially the same effect as specifying a value of other, with the exception that the application is not expected to look for other indications as to what to do to display the link.

7. xlink:actuate The xlink:actuate attribute is used to indicate when the linked resource should be loaded. This attribute will accept the following values:

Onload - A value of onLoad indicates that when the current resource is loading, the linked resource should be loaded as well. onRequest - A value of onRequest means the linked document should only be loaded when some post-loading event triggers a message for traversal. other - A value of other indicates, again, that the application should look for other indications as to what the desired behavior is. none - A value of none specifies that the application is free to handle the loading of the linked resource in whatever manner seems appropriate.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

8. xlink:label, xlink:from and xlink:to:

The xlink:label attribute is used to name resource and locator XLink types. This value will end up being used as values within the xlink:from and xlink:to attributes to indicate the starting and ending resources for an arc XLink type. The XML Linking Language offers two major types of links:

Simple - a simple link is a convenient, shorthand notation by which to associate two resources. These resourcesone local and one remoteare connected by an arc, always making a simple link an outbound link. Extended - An extended link associates any number of resources together. Furthermore, those resources may be both local and remote. Simple Links A simple link combines the functionality provided by the different pieces available through an extended link together into a short and notation.

1. A simple link consists of an xlink:type attribute with a value of simple and, optionally, an xlink:href attribute with a specified value.

2. A simple link may have any content, and even no content; it is up to the application to provide some means to generate a traversal request for the link.

3. If no target resource is specified with the xlink:href attribute, the link is simply considered―dead‖ and will not be traversable.

4. Simple links play multiple roles in linking documents. For instance, the simple link, itself, acts as a resource XLink type for the local document.

5. It is the combination of this functionality that shortens the XLink definition for a simple link.

6. simple links are just thatsimple.

7. They link exactly two resources together: one local and one remote. Therefore, if something more complex must be handled, an extended link is necessary.

Extended Links

a. The XML Linking Language, extended links gives the ability to specify relationships between an unlimited number of resources, both local and remote.

b. In addition, these links can involve multiple paths between the linked resources.

c. Local resources are part of the actual extended link, whereas remote resources identify external resources to the link.

d. An out-of-line link is created when there are no local resources at all for a link.It is up to individual applications to decide how to handle extended links; there‗s no magic formula for this one.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Unit - II

Building Xml- Based Applications

Part A

1. What are the different XSLT elements?.[ CO1 - L1]

Style sheet

Value-of

For-each

Sort

Text

2. What is XQuery?.[ CO1 - L1]

XQuery is a W3C initiative to define a standard set of constructs for querying and searching XML documents.XQuery brings database query processing to XML.

3.What is XForm?.[ CO1 - L1] XForm is an XML approach that overcomes the limitations of HTML forms. XForm includes a variety of buttons, scrollbars and menus. It generates XML form data as output. XForm\'s model has the capability to work with the variety of user interfaces.

4.What is XPath?.[ CO1 - L1] Xpath is used to navigate XML tree structures. XPath gets its name from its use of a path notation to navigate through the hierarchical tree structure of an XML document. It is an important XML technology due to its role in providing a common syntax and semantics for functionality in both XSLT and XPointer.

5.What are complex types?.[ CO1 - L1]

Complex types are important aspects of xml schema that allow application developers to define application-specific data types that can be checked by programs that check XML document for validity.

XML schema divides complex types into two categories: those with simple content & those with complex content.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

6.What all are the presentation technologies? .[ CO1 - L1] CSS - cascading style sheets XSL - provides users with ability to describe how xml data & document are to be formatted. Xforms - it is a GUI toolkit for creating user interfaces & delivering the results in XML. Xhtml - it is used to replace HTML with more flexible approach to display web content. VoiceXML - it is an emerging standard for speech enabled application.

7.What are all the Transformation techniques?.[ CO1 - L1 - Nov/Dec 2016] XSL - it is an XML- based languages used to transform XML documents into others format such as HTML for web display. XLINK - highlighting that element or taking the user directly to that point in the document. XPATH - Xpath gets its name from its use of a path notation to navigate through the hierarchical tree structure of an XML document XQUERY - it is w3c initiative to define a standard set of constructs for querying & searching XML document.

8.Explain any two XForm implementations?.[ CO1 - L1] X-Smiles - it is a java based XML browser. it implements a large part of X-forms & uses X-form together with XSL-FO on user interface side. Mozquito Xforms preview - is an XML based Web development s/w that implements Xforms & gives current Web browser the ability to send, receive & process XML document.

9. What are the Important of SAX?.[ CO1 - L1] SAX is an event driven. SAX supports processing pipelines. SAX requires programmers to maintain state.

10. What is metadata?.[ CO1 - L1] Literally data about data. XML element and attribute names are considered Metadata in that they may be used to describe the data contained in document.Metadata isn‗t needed but it certainly helps 11.Mention any 3 XML Parsers,SAX (Simple API for XML) Parser,DOM (Document Object Model) Parser and XSLT (XML Style Sheet) Parsers

12.What is XSL Programming?.[ CO1 - L1]

S.K.P. Engineering College, Tiruvannamalai

VII SEM

XSL (XML Style sheet) Programming is the Next Generation of the CSS (Cascading Style Sheet Programming).In CSS, users can use certain style tags which the browsers can understand and are predefined by W3 consortium. XSL takes to one step ahead and users can define any tags in the XML file. XML sheets can help in showing the same data in different formats. <?xml-stylesheet href="doc.xsl" type="text/xsl"?>

13.What is XSLT? .[ CO1 - L1 - Nov/Dec 2016] XSLT stands for XSL Transformations XSLT is the most important part of XSL XSLT transforms an XML document into another XML document XSLT uses XPath to navigate in XML documents XSLT is a W3C Recommendation

14.How is XML parsing done with SAX? .[ CO1 - L1] SAX parser is work differently with DOM parser, it either load any XML document intomemory nor create any object representation of the XML document. Instead, the SAX parser use callback function (org.xml.sax.helpers.DefaultHandler) to informs clients of the XML document structure. SAX Parser is faster and uses less memory than DOM parser.

15.What is the purpose of XSLT? .[ CO1 - L1] The XSLT language transforms XML into a format interpreted by an Internet browser. XML presents as a text document of XML code, which is not particularly useful. XML does not do anything on its own. It is luggage that carries information for you, but has no idea what to do with that information. It just knows you need it carry

16.What does XSLT mean? .[ CO1 - L1] XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents. XSLT stands for XSL Transformations. In this tutorial you will learn how to use XSLT to transform XML documents into other formats, like XHTML

17. Define DOM.[ CO1 - L1] The Document Object Model (DOM) provides a way of representing an XML document in memory so that it can be manipulated by your software. DOM is a standard application programming interface (API) that makes it easy for programmers to access elements and delete, add, or edit content and attributes.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

18.Why Do I Need DOM? .[ CO1 - L1] The main reason for using DOM is to create or modify an XML document programmatically.To create a document, first start by creating a root element and then add attributes, content, sub-elements, and so on. Finally write the document out to disk or send it over a network.The representation in memory is a tree structure that starts with a root element that contains attributes, content, and sub-elements.Traverse this tree, search for a specific node, and change its attributes or data. Also add attributes or elements anywhere in the tree, as long as you don‗t violate the rules of a well formed document. Finally write the modified document back out to disk or to the network.It is possible to process XML documents using other, simpler techniques, such XSLT.The problem is that XSLT is not always expressive enough to solve complex problems.

19.What are the Disadvantages of Using DOM.[ CO1 - L1]

One of the big issues is that DOM can be memory intensive.

A large document will require a large amount of memory to represent it.

Other parsing methods, such as SAX, don‗t read in the entire document, so they are

better in terms of memory efficiency for some applications. The DOM API is too complex.

20. Define DOM Traversal and Range.[ CO1 - L1] Traversal Traversal is a convenient way to walk through a DOM tree and select specific nodes. Range

Range interfaces provide a convenient way to select, delete, extract, and insert content.

A range consists of two boundary points corresponding to the start and the end of the

range.

21.Define SAX .[ CO1 - L1] SAX is an API that can be used to parse XML documents.

A parser is a program that reads data a character at a time and returns manageable

pieces of data. SAX provides a framework for defining event listeners, or handlers. These handlers are

written by developers interested in parsing documents with a known structure. The handlers are registered with the SAX framework in order to receive events. Events can include start of document, start of element, end of element, and so on. The handlers contain a number of methods that will be called in response to these events.

S.K.P. Engineering College, Tiruvannamalai

PART B

VII SEM

1. Explain how XML is processed with the help of SAX.[ CO1 L2]

When such an event occurs, the handler automatically calls back to a particular method

overridden by the client, and feeds as arguments the method what it sees SAX parser is event-based; it works like an event handler in Java.

The program consists of two classes:

Sample -- This class contains the main method; it Gets a factory to make parsers Gets a parser from the factory Creates a Handler object to handle callbacks from the parser

Tells the parser which handler to send its callbacks to Reads and parses the input XML

file

The following interfaces and classes used SAX Parser interface ContentHandler -- reports on document events interface ErrorHandlerreports on validity errors class DefaultHandler implements both of the above plus two others

public interface Content Handler

This is the main interface that most SAX applications implement: if the application.

needs to be informed of basic parsing events, it implements this interface and registers

an instance with the SAX parser using the set Content Handler method. The parser uses the instance to report basic document-related events like the start and end of elements and character data.

Handler -- This class contains handlers for three kinds of callbacks:

p start Element callbacks, generated when a start tag is seen

q end Element callbacks, generated when an end tag is seen

r characters callbacks, generated for the contents of an element

Default Handler is an adapter class that defines these methods and others as do-

nothing methods, to be overridden as desired

We will define three very similar methods to handle (1) start tags, (2) contents, and (3) end tags--our methods will just print a line Each of these three methods could throw a SAX Exception interface XML Reader -- defines parser behavior a This interface

allows an application to set and query features and properties in the parser, to register

event handlers for document processing, and to initiate a document parse.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

public void startDocument() throws SAXException //This is called just once, at the beginning of parsing public void endDocument() throws SAXException //This is called just once, and is the last method called by the parser

If the parser is namespace-aware,namespaceURI will hold the prefix (before the colon) localName will hold the element name (without a prefix) qualifiedName will be the empty stringIf the parser is not using namespaces,namespaceURI and localName will be empty strings qualifiedName will hold the element name (possibly with prefix) When SAX calls startElement, it passes in a parameter of type Attributes .Attributes is an interface that defines a number of useful methods; o getLength() returns the number of attributes getLocalName(index) returns the attribute‗s local name o getQName(index) returns the attribute‗s qualified name o getValue(index) returns the attribute‗s value As with elements, if the local name is the empty string, then the attribute‗s name is in the qualified name public void end Element()throws SAX Exception Receive notification of the end of an element

Program1- SAXCountEmployees.java Import javax.xml.parsers.SAXParserFactory; import org.xml.sax.XMLReader; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; class SAXCountEmployees { static public void main(String args[]) { try { String FEED_URL = "employee.xml";

SAXParserFactory saxFactory = SAXParserFactory.newInstance(); XMLReader parser = saxFactory.newSAXParser().getXMLReader(); parser.setContentHandler(new CountElementsHelper()); parser.parse(FEED_URL);

}

catch (Exception e)

{

e.printStackTrace();

}

return;

}

private static class CountElementsHelper extends CountElementsHelper() {

DefaultHandler { int numElements;

S.K.P. Engineering College, Tiruvannamalai

super();

}

VII SEM

public void startDocument() throws SAXException { numElements = 0; return; }

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException

{

if (qName.equals("Employee")) { numElements++;

}

return;

}

public void endDocument() throws SAXException

{

System.out.println("Input document has " + numElements + " 'Employee' elements."); return; }}}

Program 2 -- employee.xml <?xml version = "1.0" ?> <Employee-Detail> <Employee> <Emp_Id> 11032 </Emp_Id> <Emp_Name> Geetha </Emp_Name> <Emp_E-mail>geetha@gmail.com </Emp_E-mail> </Employee> <Employee> <Emp_Id> 11022 </Emp_Id> <Emp_Name> sumalatha</Emp_Name> <Emp_E-mail> jsumalatha@gmail.com </Emp_E-mail> </Employee> <Employee> <Emp_Id> 11011 </Emp_Id> <Emp_Name> Lakshmanan </Emp_Name> <Emp_E-mail> lakshmimurugan@gmail.com </Emp_E-mail> </Employee></Employee-Detail> Input document has 3 Employee elements

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Advantage:

It is simple. SAX supported in almost all programming languages Quantity of memory usage is low. (3) It works well in stream application Only for reading xml-documents

Disadvantage:

The data is broken into pieces and clients never have all the information as a whole unless they create their own data structure

Difference between SAX and DOM DOM reads the entire XML document into memory and stores it as a tree data structure SAX reads the XML document and calls one of your methods for each element or block of text that it encounters Consequences:DOM provides ―random access‖ into the XML document o SAX provides only sequential access to the XML documentDOM is slow and requires huge amounts of memory, so it cannot be used for large XML documents SAX is fast and requires very little memory, so it can be used for huge documents (or large numbers of documents)

2. Explain about DOM based XML processing.[ CO1 L2] Introduction to Parser-It reads a text-formatted XML file or stream and converts it to a document to be manipulated by the application.

DOM-Tree Based Parser The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents It defines the logical structure of documents and the way a document is accessed and manipulated

Properties of DOM Programmers can build documents, navigate their structure, and add, modify, or delete elements and content. Provides a standard programming interface that can be used in a wide variety of environments and applications. XML Parser The XML DOM contains methods (functions) to traverse XML trees, access, insert, and delete nodes. However, before an XML document can be accessed and manipulated, it must be loaded into an XML DOM object.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

An XML parser reads XML, and converts it into an XML DOM object that can be accessed with JavaScript. Most browsers have a built-in XML parser.

Program1- DOMCountEmployees.java // JAXP classes import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; // DOM classes import org.w3c.dom.Document; import org.w3c.dom.NodeList; // JDK classes import java.io.File; class DOMCountEmployees

{

static public void main(String args[])

{

try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = docBuilderFactory.newDocumentBuilder(); Document document = parser.parse(new File("employee.xml")); NodeList emplist = document.getElementsByTagName("Employee");

System.out.println("Input document has"+emplist.getLength() + " 'Employee' elements.");

}

catch (Exception e)

{

e.printStackTrace(); } return;

}

}

Program employee.xml <?xml version = "1.0" ?> <Employee-Detail> <Employee> <Emp_Id> 11032 </Emp_Id> <Emp_Name> Geetha </Emp_Name> <Emp_E-mail>geetha@gmail.com </Emp_E-mail> </Employee>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

<Employee> <Emp_Id> 11022 </Emp_Id> <Emp_Name> sumalatha</Emp_Name> <Emp_E-mail> jsumalatha@gmail.com </Emp_E-mail> </Employee> <Employee> <Emp_Id> 11011 </Emp_Id> <Emp_Name> Lakshmanan </Emp_Name> <Emp_E-mail> lakshmimurugan@gmail.com </Emp_E-mail> </Employee> </Employee-Detail>

Input document has 3 Employee elements

Advantage:

It is good when random access to widely separated parts of a document is required It supports both read and write operations

Disadvantage:

It is memory inefficient It seems complicated, although not really

3. Explain detail about Parsing XML Using Document Object Model.[ CO1 L2 - Nov/Dec 2016] The Document Object Model (DOM) provides a way of representing an XML document in memory so that it can be manipulated by your software. DOM is a standard application programming interface (API) that makes it easy for programmers to access elements and delete, add, or edit content and attributes.

What DOM Is Not DOM is not a mechanism for persisting, or storing, objects as XML documents. Think of it the other way: DOM is an object model for representing XML documents in your code. DOM is not a set of data structures; rather it is an object model describing XML documents. DOM does not specify what information in a document is relevant or how information should be structured. DOM has nothing to do with COM, CORBA, or other technologies that include the words objectmodel.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Why Do I Need DOM? The main reason for using DOM is to create or modify an XML document programmatically. To create a document, first start by creating a root element and then add attributes, content, sub-elements, and so on. Finally write the document out to disk or send it over

a network.

The representation in memory is a tree structure that starts with a root element that contains attributes, content, and sub-elements. Traverse this tree, search for a specific node, and change its attributes or data. Also

add attributes or elements anywhere in the tree, as long as you don‗t violate the rules of

a well formed document. Finally write the modified document back out to disk or to the network.

It is possible to process XML documents using other, simpler techniques, such XSLT.

The problem is that XSLT is not always expressive enough to solve complex problems.

Disadvantages of Using DOM

One of the big issues is that DOM can be memory intensive.

A large document will require a large amount of memory to represent it.

Other parsing methods, such as SAX, don‗t read in the entire document, so they are better in terms of memory efficiency for some applications.

The DOM API is too complex.

DOM Levels The DOM working group works on phases (or levels) of the specification. Level 1:

Allows traversal of an XML document as well as the manipulation of the content in that document. Level 2 :

Extends Level 1 with additional features such as namespace support, events, ranges, and so on. Level 3:

it is currently a working draft. This means that it is under active development and subject to change. DOM Core The DOM core is available in DOM Level 1 and beyond. It permits to create and manipulate XML documents in memory. DOM is a tree structure that represents elements, attributes, and content.

Simple XML Document

S.K.P. Engineering College, Tiruvannamalai

<purchase-order> <customer>James Bond</customer> <merchant>Spic</merhant> <items> <item>Night vision camera</item> <item>Vibrating massager</item> </items> </purchase-order>

VII SEM

Tree structure Parents, Children, and Siblings The DOM specification uses the words parents, children, and siblings to represent nodes and their relationships to one another. Parent nodes may have zero or more child nodes. Parent nodes themselves may be the child nodes of another parent node. The ultimate parent of all nodes is, of course, the root node. Siblings represent the child nodes of the same parent. These abstract descriptions of nodes are mapped to elements, attributes, text, and other information in an XML document.

DOM interfaces contain methods for obtaining the parent, children, and siblings of any node The root node has no parent, and there will be nodes that have no children or siblings. DOM Interfaces The DOM interfaces are defined in IDL so that they are language neutral.

SimpleWalker.java package com.madhu.xml; import java.io.*; import org.w3c.dom.*; import javax.xml.parsers.*; public class SimpleWalker { protected DocumentBuilder docBuilder; protected Element root; public SimpleWalker() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); docBuilder = dbf.newDocumentBuilder(); DOMImplementation domImp = docBuilder.getDOMImplementation(); if (domImp.hasFeature(―XML‖, ―2.0‖))

S.K.P. Engineering College, Tiruvannamalai

{

VII SEM

System.out.println(―Parser supports extended interfaces‖);

}

}

public void parse(String fileName) throws Exception {

Document doc = docBuilder.parse(new FileInputStream(fileName)); root = doc.getDocumentElement(); System.out.println(―Root element is ― + root.getNodeName());

}

public void printAllElements() throws Exception { printElement(―‖, root);

}

public void printElement(String indent, Node aNode)

{

System.out.println(indent + ―<‖ + aNode.getNodeName() + ―>‖);

Node child = aNode.getFirstChild(); while (child != null) {

printElement(indent + ―\t‖, child); child = child.getNextSibling();

}

System.out.println(indent + ―</‖ + aNode.getNodeName() + ―>‖);

}

public static void main(String args[]) throws Exception

{

SimpleWalker sw = new SimpleWalker(); sw.parse(args[0]); sw.printAllElements();

}

}

Output from SimpleWalker Parser supports extended interfaces Root element is library <library> <#text> </#text> <fiction> <#text> </#tex> <book> <#text> </#text> </book>

S.K.P. Engineering College, Tiruvannamalai

<#text>

</#text>

<book>

<#text>

</#text>

</book>

<#text>

</#text>

</fiction>

<#text>

</#text>

<biography>

<#text>

</#text>

<book>

<#text>

</#text>

</book>

<#text>

</#text>

</biography>

<#text>

</#text>

</library>

VII SEM

Modified printElement() Method

public void printElement(String indent, Node aNode) { if (aNode.getNodeType() == Node.TEXT_NODE)

{

System.out.println(indent + aNode.getNodeValue()); } else { System.out.println(indent + ―<‖ + aNode.getNodeName() + ―>‖); Node child = aNode.getFirstChild(); while (child != null) {

printElement(indent + ―\t‖, child); child = child.getNextSibling();

}

System.out.println(indent + ―</‖ + aNode.getNodeName() + ―>‖);

}

}

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Output After print Element() Modification Parser supports extended interfaces Root element is library <library> <fiction> <book> Moby Dick </book> <book> The Last Trail </book> </fiction> <biography> <book> The Last Lion, Winston Spencer Churchill </book> </biography> </library>

4. Explain in detail about Parsing XML Using SAX.[ CO1 L2 - Nov/Dec 2016] SAX is an API that can be used to parse XML documents.

A parser is a program that reads data a character at a time and returns manageable

pieces of data. SAX provides a framework for defining event listeners, or handlers. These handlers are written by developers interested in parsing documents with a known structure. The handlers are registered with the SAX framework in order to receive events. Events can include start of document, start of element, end of element, and so on. The handlers contain a number of methods that will be called in response to these events.

What SAX Is Not

SAX by itself is just an API, and a number of implementations are available from many

of the familiar sources

SAX was originally developed in Java, but similar implementations are available in other languages as well.

Why Do I Need SAX? SAX is completely free, so it can be embedded in a larger application without royalty fees or even copyright notices. Some SAX parsers can validate a document against a Document Type Definition (DTD). Validating parsers can also tell you specifically where validation has failed.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

SAX vs. DOM DOM is an in-memory tree structure of an XML document or document fragment. DOM is a natural object model of an XML document, but it‗s not always practical. Large documents can take up a lot of memory. SAX is, in many ways, much simpler than DOM. There is no need to model every possible type of object that can be found in an XML document. This makes the API easy to understand and easier to use. DOM contains many interfaces, each containing many methods. SAX is comprised of a handful of classes and interfaces. SAX is a much lower level API when compared with DOM. For these reasons, SAX parsers tend to be smaller than DOM implementations. SAX is an event-based API. SAX parsers send events continuously, telling what was found next. The DOM parses XML in space, whereas SAX parses XML in time. SAX can be significantly more efficient for large documents. SAX can also be faster.

Disadvantages SAX parsing is ―single pass,‖ so can‗t back up to an earlier part of the document any more than you can back up from a serial data stream. No random access at all. Handling Parent/child relationships can be more challenging as well. The current SAX implementations are read-only parsers. They do not provide the ability to manipulate a document or its structure. There is no way to validate a SAX parser or to determine whether it works correctly.

Advantages:

lightweight

simple

Easy to use.

SAX Versions The first version, SAX 1.0, was released in May 1998. It provided the basic functionality needed to read elements, attributes, text, and to manage errors. The current version, SAX 2.0, was released two years later in May 2000. Many of the SAX 2.0 interfaces are departures from SAX 1.0. Older interfaces are included, but deprecated, for backward compatibility.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

SAX Basics <?xml version=‖1.0‖ encoding=‖UTF-8‖?> <fiction> <book author=‖Herman Melville‖>Moby Dick</book> </fiction> Parse this document using SAX, you would build a content handler by creating a Java class that implements the Content Handler interface in the org.xml.sax package.

SAX Packages The SAX 2.0 API is comprised of two standard packages and one extension package. The two standard packages are, org.xml.sax - It contains the basic classes, interfaces, and exceptions needed for parsing documents. org.xml.helpers - It contains additional classes that can simplify some of coding and make it more portable. The one extension package is, org.xml.sax.ext- It is an extension that is not shipped with all implementations. It contains two handler interfaces for capturing declaration and lexical events.

5 Explain how XSLT transforms the document from one word type to other.[ CO1 L2 Nov/Dec 2016] XSL XSL is a language that allows one to describe a browser how to process an XML file. XSL can convert an XML file into another XML with different format. XSL can convert an XML file into a non-XML file. XSL consists of three languages:

XSLT (XSL Transformations) is a language used to transform XML documents into other kinds of documents (most commonly HTML, so they can be displayed)XPath is a language to select parts of an XML document to transform with XSLT XSL-FO (XSL Formatting Objects) is a replacement for CSS There are no current implementations of XSL-FO. A style sheet stores formatting options for a document, usually separately from document o E.g. an HTML style sheet may specify font colors and sizes for headings, etc. The XML Style sheet Language (XSL) was originally designed for generating HTML from XML XSLT is a general-purpose transformation language Can translate XML to XML, and XML to HTML

S.K.P. Engineering College, Tiruvannamalai

VII SEM

XSLT transformations are expressed using rules called templates Templates combine selection using XPath with construction of results

How does it work? The XML source document is parsed into an XML source tree You use XPath to define templates that match parts of the source tree You use XSLT to transform the matched part and put the transformed information into the result tree The result tree is output as a result document Parts of the source document that are not matched by a template are typically copied unchanged

XSLT templates <xsl:template match=―/bank-2/customer‖> <xsl:value-of select=―customer_name‖/> </xsl:template> <xsl:template match=―*‖/> The match attribute of xsl:template specifies a pattern in XPath Elements in the XML document matching the pattern are processed by the actions within the xsl:template element xsl:value-of selects (outputs) specified values (here, customer_name) For elements that do not match any template Attributes and text contents are output as is Templates are recursively applied on sub elements The <xsl:template match=―*‖/> template matches all elements that do not match any other template Used to ensure that their contents do not get output. If an element matches several templates, only one is used based on a complex priority scheme/user-defined priorities

6.Write XSLT code to display employee details in a table form which is stored is XML. [ CO1 L2] Program1- empdetail.xsl <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="Employee-Detail"> <html> <head> <title>XSLT Style Sheet</title>

S.K.P. Engineering College, Tiruvannamalai

</head> <body>

<h1>

<p align="center">Employee Details</p>

</h1>

<table border="2" width="50%" align="center"> <tr>bgcolor="LIGHTBLUE"> <th>Emp_Id</th> <th>Emp_Name</th> <th>Emp_E-mail</th> </tr> <xsl:for-each select="Employee"><tr> <td> <i> <xsl:value-of select="Emp_Id"/> </i> </td><td> <xsl:value-of select="Emp_Name"/> </td> <td><xsl:value-of select="Emp_E-mail"/></td> </tr></xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

VII SEM

Program 2 - employee.xml <?xml version = "1.0" ?> <?xml-stylesheet href="empdetail.xsl" type="text/xsl"?> <Employee-Detail> <Employee> <Emp_Id> 11032 </Emp_Id> <Emp_Name> Geetha </Emp_Name> <Emp_E-mail>geetha@gmail.com </Emp_E-mail> </Employee>

<Employee> <Emp_Id> 11022 </Emp_Id>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

<Emp_Name> sumalatha</Emp_Name> <Emp_E-mail> jsumalatha@gmail.com </Emp_E-mail> </Employee> <Employee> <Emp_Id> 11011 </Emp_Id> <Emp_Name> Lakshmanan </Emp_Name> <Emp_E-mail> lakshmimurugan@gmail.com </Emp_E-mail> </Employee> </Employee-Deta>

7.Explain in detail about XSL Formatting Objects.[ CO1 L2] The XSL technology is also composed of XSL Formatting Objects (XSL-FO). XSL-FO was designed to assist with the printing and displaying of XML data. The main emphasis is on the document layout and structure. This includes the dimensions of the output document, including page headers, footers, and margins. XSL-FO also allows the developer to define the formatting rules for the content, such as font style, color, and positioning. XSL-FO is a sophisticated version of Cascading Style Sheets (CSS).

XSL-FO Formatting Engines The XSL-FO formatting engines implement a subset of the XSL-FO specification. Engines are available that allow you to experiment with the basic features of XSL-FO. The Apache XSL-FOP formatter to convert the document to a PDF file. Apache XSL-FOP generating PDF documents. The following code snippet shows the basic document setup for XSL-FO:

<?xml version=‖1.0‖ encoding=‖utf-8‖?> <fo:root xmlns:fo=‖http://www.w3.org/1999/XSL/Format‖> <!-- layout master set --> <!-- page masters: size and layout --><!-- page sequences and content --> </fo:root> The element <fo:root> is the root element for the XSL-FO document.

An XSL-FO document can contain the following components:

Page master Page master set Page sequences Page Master:

<fo:page-master>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The page master describes the page size and layout. The <fo:simple-page-master> element defines the layout of a page. <fo:simple-page-master master-name=‖simple‖ page-height=‖11in‖ page-width=‖8.5in‖ margin-top=‖1in‖ margin-bottom=‖1in‖ margin-left=‖1.25in‖ margin-right=‖1.25in‖> </fo:simple-page-master>

Components of the page master The attributes for <fo:simple-page-master> define the height and width of the page, along with the size of the margins. Each page is divided into five regions. Regions serve as containers for the document content.

Five regions of a page. The size of the regions using the following elements:

<fo:region-before>

<fo:region-after>

<fo:region-body>

<fo:region-start>

<fo:region-end>

The region-before and region-after areas are commonly used for page headers and footers. The region-body area is the center of the page and contains the main content. The region-start and region-end sections are commonly used for left and right sidebars,

respectively. Page Master Set: <fo:page-master-set> A document can be composed of multiple pages, each with its own dimensions. The page master set refers to the collection of page masters. <fo:layout-master-set> <fo:simple-page-master master-name=‖simple‖ page-height=‖11in‖ page-width=‖8.5in‖ margin-top=‖1in‖ margin-bottom=‖1in‖ margin-left=‖1.25in‖ margin-right=‖1.25in‖> <fo:region-body margin-top=‖0.5in‖/> <fo:region-before extent=‖3cm‖/> <fo:region-after extent=‖1.5cm‖/> </fo:simple-page-master></fo:layout-master-set Page Sequences: <fo:page-sequence> A page sequence defines a series of printed pages. Each page sequence refers to a page master for its dimensions.The page sequence contains the actual content for the document. The <fo:page-sequence> element contains <fo:static-content> and <fo:flow> elements. The <fo:static-content> element is used for page headers and footers.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The <fo:flow> element contains a collection of text blocks. The <fo:flow> element is similar to a collection of paragraphs. A body of text is defined using the <fo:block> element. The <fo:block> element is a child element of <fo:flow> <!-- page sequences and content --><fo:page-sequence master-name=‖simple‖> <fo:flow flow-name=‖xsl-region-body‖> <!-- this defines a level 1 heading with orange background --><fo:block font-size=‖18pt‖ font-family=‖sans-serif‖ line-height=‖24pt‖ space-after.optimum=‖15pt‖ background- color=‖orange‖ color=‖white‖ text-align=‖center‖ padding-top=‖3pt‖> Ez Books Online </fo:block> <!-- Paragraph that contains info about the company --><fo:block font-size=‖12pt‖ font-family=‖sans-serif‖ line-height=‖15pt‖ space-after.optimum=‖14pt‖ text- align=‖justify‖>

Welcome to Ez Books Online, the world‗s smallest online book store.

Our company‗s mission is to sell books on Java, Thrillers and Romance.

We have something for everyone

you find a book of interest then send us an e-mail. Thanks for visiting!

so

we think. Feel free to browse our catalog and if

</fo:block> </fo:flow></fo:page-sequence> Generating a PDF Document Follow these steps to generate a PDF document from simple.fo:

Open an MS-DOS window.

Move to the directory <install_dir>\ch9_xsl\xsl_fo\.

Set up the Java classpath by typing setpaths.

Execute Apache-FOP by typing fop simple.fo simple.pdf.

The Apache-FOP formatter now reads the input file simple.fo and generates the output file simple.pdf. View the simple.pdf file in Adobe Acrobat Reader. Page Headers and Footers The <fo:static-content> element defines content that should appear on every page.The <fo:static-content> element is commonly used to set up page headers and footers. The <fo:static-content> element is a component of <fo:page-sequence>. The header is defined using the following code fragment: <fo:static-content flow-name=‖xsl-region- before‖> <fo:block text-align=‖end‖ font-size=‖10pt‖ font-family=‖serif‖ line- height=‖14pt‖ > Ez Books Catalog - page <fo:page-number/></fo:block>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

</fo:static-content> The footer is defined using the following code fragment:

<!-- footer --> <fo:static-content flow-name=‖xsl-region-after‖> <fo:block text-align=‖center‖ font-size=‖10pt‖ font-family=‖serif‖ line-height=‖14pt‖ > Visit our website http://www.ezbooks.web </fo:block> </fo:static-content> Graphics XSL-FO also allows for the insertion of external graphic images. The graphic formats supported are dependent on the XSL-FO formatting engine. The Apache-FOP formatting engine supports the popular graphics formats: GIF, JPEG, and BMP. The following code fragment inserts the image smiley.jpg:

<fo:block text-align=‖center‖> <fo:external-graphic src=‖smiley.jpg‖ width=‖200px‖ height=‖200px‖/> </fo:block>

Inserting a graphic image in a PDF document. Tables XSL-FO has rich support for structuring tabular data. In fact, there are many similarities between HTML tables and XSL-FO tables. The following code fragment defines the basic structure of the table:

<fo:table> <!-- define column widths -->< fo:table-column column-width=‖120pt‖/> <fo:table-column column-width=‖200pt‖/> <fo:table-column column-width=‖80pt‖/> <fo:table-header> <fo:table-row> <fo:table-cell> <fo:block font-weight=‖bold‖>Author</fo:block> </fo:table-cell><fo:table-cell> <fo:block font-weight=‖bold‖>Title</fo:block> </fo:table-cell><fo:table-cell> <fo:block font-weight=‖bold‖>Price (USD)</fo:block> </fo:table-cell></fo:table-row> </fo:table-header> <!-- insert table body and rows here --> </fo:table>

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Generating XSL-FO Tables Using XSLT Generating XSL-FO tables with XSLT. Generating a PDF Document 1.Open an MS-DOS window. 2.Move to the directory <install_dir>\ch9_xsl\xsl_fo\dynamic\table. 3.Set up the Java classpath by typing setpaths. 4.Execute Apache-FOP by typing the following: fop -xml booklist.xml -xsl booklist_table.xsldyntable.pdf 5.View the dyntable.pdf file in Adobe Acrobat Reader.

Web Application Integration: Java Servlets, XSLT, and XSL-FO 6.A Web application that integrates Java servlets, XSLT, and XSL-FO. Develop a Java servlet to pass an XML document and XSL style sheet to the Apache-FOP formatting engine. 7.The XML document 8.itis booklist.xml. The XSL style sheet, booklist_table.xsl, contains the XSL-FO template code to generate a table. The servlet will respond with the PDF document generated by the Apache-FOP formatting engine. 9.Web application integration: Java servlets, XSLT, and XSL-FO. 8.Describe in detail about Modeling Databases in XML Model a database; provide an external representation of the database contents. A sample program, utilize a database that contains information on rental properties. Model the rental property database as an XML document. Figure shows the desired output. Desired output for rental properties In the JAXB framework, we can parse XML documents into a suitable Java object. This technique is referred to as unmarshaling. JAXB marshaling and unmarshaling. JAXB is easier to use and a more efficient technique for processing XML documents than the SAX or DOM API. JAXB Solution It takes the JAXB binding schema and generate the appropriate Java classes.

1. Review the database schema.

2. Construct the desired XML document.

3. Define a schema for the XML document.

4. Create the JAXB binding schema.

5. Generate the JAXB classes based on the schema.

6. Develop a Data Access Object (DAO).

7. Develop a servlet for HTTP access.

S.K.P. Engineering College, Tiruvannamalai

Unit III

Service Oriented Architecture

Part A

VII SEM

1.What is architecture?.[ CO3 - L1 - Nov/Dec 2013] Architecture refers a systematic arrangement of computerized automation technological solutions. It is to an application development team, a blueprint to the team of construction workers. Different organizations document different levels of application architecture.

2. Define Service-oriented architecture?.[ CO3 - L1 - Nov/Dec 2013]

SOA is a form of technology architecture that adheres to the principles of service-

orientation. When realized through the Web services technology platform, SOA establishes the potential to support and promote these principles throughout the business process and automation domains of an enterprise.

3. Define contemporary SOA.[ CO3 - L1 - Nov/Dec 2016]

Contemporary SOA represents an architecture that promotes service-orientation through the use of web services. Contemporary SOA is an extended variation of service-oriented architecture which builds increasingly powerful XML and Web services support into current technology platforms.

4.List out some characteristics of contemporary SOA.[ CO3 - L1 - Nov/Dec 2016] Contemporary SOA is at the core of the services-oriented computing platform. Contemporary SOA increase quality of service. Contemporary SOA is fundamentally autonomous. Contemporary SOA is based on open standards. Contemporary SOA supports vendor diversity. Contemporary SOA fosters intrinsic interoperability. Contemporary SOA promotes discovery. Contemporary SOA promotes federation. Contemporary SOA promotes architectural compos ability. Contemporary SOA fosters inherent reusability.

5.What are the benefits of SOA?.[ CO3 - L1] Improved integration(and intrinsic interoperability)

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Inherent reuse Streamlined architectures and solutions Leveraging the legacy investment Establishing standardized XML data representation. Focused investment on communications infrastructure "Best-of-breed" alternatives Organizational agility(Flexibility)

6.What are the common mistakes/pitfalls of adopting SOA?.[ CO3 - L1] Building service oriented architecture like traditional distributed architectures Not standardizing SOA Not creating a transition plan Not starting with an XML foundation architecture Not understanding SOA performance requirements Not understanding web services security Not keeping in touch with product platforms and standards development

7. What are the requirements is needed to fill QoS gaps between contemporary and primitive SOA?.[ CO3 - L1] In a secure manner Reliably With appropriate performance Protecting business integrity Executing exception logic in case of failure

8.What is autonomous principle and expand UDDI?.[ CO3 - L1] Autonomous principle represents the ability of a service to carry out its logic independently of outside influences. UDDI stands for Universal Description Discovery and Integration.

9.List out the different levels of autonomy?.[ CO3 - L1] Runtime autonomy- Run time autonomy represents the amount of control a service has over its execution environment at runtime.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Design-time autonomy- Design-time autonomy represents the amount of governance control a service owner has over the service design.

10.What are the design characteristics require facilitating interoperability in contemporary SOA .[ CO3 - L1] The designs characteristics require to facilitate interoperability are Standardization Scalability Behavioral predictability Reliability

11.List out some of the characteristics of the reusable services in SOA? [ CO3 -

L1]

Reusable services have the following characteristics:

Define by an unbelievable functional context Logic is highly generic Has a generic and extensible contract Can be accessed concurrently

12.How is loosely coupling concept achieved in SOA? .[ CO3 - L1] The loosely coupling concept is achieved by implementing standardized service abstraction layers when service-orientation principles are applied to both business modeling and technical design.

13. What is referred as organizational agility? .[ CO3 - L1]

Organizational Agility refers to efficiency with which an organization can respond to change.

14. What is application architecture?.[ CO3 - L1 - May/June 2014]

Application architecture is a template for all others specifically explained the technology,

boundaries, rules, limitations, and design characteristics that apply to all solution based on the template.Application architecture is to an application development team what a blueprint is to a team of construction workers. Different organizations document different levels of application architecture. Some keep it high-level, providing abstract physical and logical representations of the technical blueprint. Others include more detail, such as common data models, communication flow diagrams, application-wide security requirements, and aspects of infrastructure.

15. What is Enterprise architecture? .[ CO3 - L1]

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Enterprise architecture is a creation of master specification when numerous, disparate and integrate application architectures exists within an organization. An enterprise architecture specification is to an organization what an urban plan is to a city.

16. What is single-tier client-server architecture? .[ CO3 - L1] Single-tier client-server architecture is an environment in which bulky mainframe back- ends server served the thin clients.

17.List out the primary characteristics of the two tier client server architecture?.[ CO3 - L1] Application logic Application processingTechnology Security and Administration

18.What is multi-tier client-server architecture?.[ CO3 - L1]

the

presentation, the application processing, and the data management are logically separate processes.

Multi-tier

architecture

is a

client-server architecture

in

which

19.List out the types of communication of mainframe systems?.[ CO3 L1] Synchronous communication- It allows the client and server to wait for each other to transfer the message. That is, the client will not continue until the server has received the message.Asynchronous communication- It allows the server to continuously receive messages from the client without waiting for the server to respond.

20.List out the types of service autonomy.[ CO3 - L1 ] Service level autonomy Pure autonomy

21.What are the key benefits of service reuse? .[ CO3 - L1]

Accommodate future requirements with less development effort.

Reduce the need for creating wrapper services

Reduction of cost by not just avoiding duplication of code

Reducing risks by reusing well-tested code and runtime environments.

22.State separation of concerns.[ CO3 - L1]

S.K.P. Engineering College, Tiruvannamalai

VII SEM

It is an established software engineering theory based on the idea of breaking down a large problem into a series of individual concerns.

23.What are the parts of automation logic? [ CO3 - L1 - May/Jun 2013] The four identified parts of automation login Messages=units of communication Operations=units of work Services=units of processing logic(collection of units of work Processes=units of automation logic(coordinated aggregation of units of works)

24.What is the use of RPC?.[ CO3 - L1]

The

remotecommunication between components residing on client workstations and servers.

remote

procedure

call

(RPC) connections are

used

for

25.Write down the advantages of RPC?.[ CO3 - L1]

Better load balancing: more evenly distributed processing

More scalable: only servers experiencing high demand need be upgraded. Multiple concurrent requests are processed.

26.Write down the disadvantages of RPC? .[ CO3 - L1]

p Heavily loaded network

q More distributed processing necessitates more data exchange

r Difficult to program and test due to increased complexity

27.What are the proprietary communication protocols promotes by distributed internet architecture for usage? .[ CO3 - L1 - Nov/Dec 2014] DCOM Distributed Component Object Model CORBA Common object request broker architecture

28. What’s the difference between services and components? .[ CO3 - L1] Services are logical grouping of components to achieve business functionality. Components are implementation approaches to make a service.

29.What is meant by Entity-centric business service?.[ CO3 - L1] Entity-centric business service is a service that encapsulates a specific business entity (such as an invoice or timesheet). Entity-centric services are useful for creating highly reusable and business process-agnostic services that are composed by an

S.K.P. Engineering College, Tiruvannamalai

VII SEM

orchestration layer or by a service layer consisting of task-centric business services (or both).

30.Define Coarse-Grained Services.[ CO3 - L1 - Nov/Dec 2012]

A service-based system controls the network access to the objects within the service

through a set of coarse-grained interfaces.

A service may still be implemented as a set of fine-grained objects, but the objects

themselves are not accessible over a network connection. A service implemented as objects has one or more coarse-grained objects that act as distributed look.

31.Define XSD?.[ CO3 - L1] SOA services communicate with messages formally defined via XML Schema Communication among consumers and providers or services typically happens in heterogeneous environments, with little or no knowledge about the provider. Messages between services can be viewed as key business documents processed in an enterprise.

32.What do you mean by Quality of Service? .[ CO3 - L1] Each SOA Services have QOS the key QoS elements are security requirements, such as authentication and authorization, reliable messaging, and policies regarding who can invoke services.

33.Define Service Proxy? .[ CO3 - L1] The service provider supplies a service proxy to the service consumer. The service consumer executes the request by calling an API function on the proxy. It then formats the request message and executes the request on behalf of the consumer.

34.List the Principles of service orientation.[ CO3 - L1 - Nov/Dec 2014] Services are reusable Services share a formal contract Services are loosely coupled Services abstract underlying logic Services are compos able Services are autonomous Services are stateless Services are discoverable

35.Define Service-Orientation and Interoperability.[ CO3 - L1]

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Service-oriented computing, is that services must be interoperable. Each of the eight SOA principles supports or contributes to interoperability in some man

36.Define service loose coupling.[ CO3 - L1] The Service Loose Coupling promotes the independent design and evolution of a service‘s logic and implementation while still guaranteeing baseline interoperability with consumers that have come to rely on the service‘s capabilities.

37.What are the logical components of web service frameworks?.[ CO3 - L1 - May/June 2012] Web Services Web Service operations SOAP Messages Activities.

38.How Contemporary SOA characteristics are influenced by services specifications and service oriented principles?.[ CO3 - L1 - May/June 2012] Fundamentally autonomous QoS capable Architecturally composable Vendor diversity Intrinsic interoperability Discoverability Promotes federation Inherent reusability

39.What are all the Unsupported SOA characteristics?.[ CO3 - L1] intrinsic interoperability extensibility enterprise-wide loose coupling service-oriented business modeling organizational agility layers of abstraction 40.What is meant by task centric business service? .[ CO3 - L1] Task-centric business service is a service that encapsulates business logic specific to a task or business process. This type of service generally is required when business

S.K.P. Engineering College, Tiruvannamalai

VII SEM

process logic is not centralized as part of an orchestration layer. Task-centric business services have limited reuse potential.

PART-B

1. Write briefly on Characteristics of Contemporary SOA.[ CO1 - L1 - MAY/JUNE

2012]

Definition of SOA:

Contemporary SOA represents an open, agile, extensible, federated, compostable architecture comprised of autonomous, QoS-capable, vendor diverse, interoperable, discoverable, and potentially reusable services, implemented as Web services.

Common characteristics of Contemporary SOA

Contemporary SOA increase quality of service.

Contemporary SOA is fundamentally autonomous.

Contemporary SOA is based on open standards.

Contemporary SOA supports vendor diversity.

Contemporary SOA fosters intrinsic interoperability.

Contemporary SOA promotes discovery.

Contemporary SOA promotes federation.

Contemporary SOA promotes architectural composability.

Contemporary SOA fosters inherent reusability.

Contemporary SOA emphasizes extensibility.

Contemporary SOA supports a service-oriented business modeling paradigm.

Contemporary SOA implements layers of abstraction.

Contemporary SOA promotes loose coupling throughout the enterprise.

Contemporary SOA Promotes organizational agility.

Contemporary SOA is a building block.

Contemporary SOA is an evolution.

A.Contemporary SOA is at the core of the services-oriented computing platform:

When a product, design, or technology is prefixed with ―SOA‖ it is something that was created in support of an architecture based on service-orientation principles. Contemporary SOA represents an architecture that promotes service-orientation through the use of Web services

S.K.P. Engineering College, Tiruvannamalai

VII SEM

B. Contemporary SOA increase quality of service:

Contemporary SOA is striving to fill the QoS gaps of the primitive SOA model with the following requirements,

In a secure manner

Reliably

With appropriate performance

Protecting business integrity

Executing exception logic in case of failure.

C. Contemporary SOA is fundamentally autonomous:

Autonomous principle:

Represents the ability of a service to carry out its logic independently of outside influences.

Message-level autonomy- Messages are ―intelligence-heavy‖ and control the way they are processed by recipients

Autonomy concept is expanded to solution environment and the enterprise i.e. applications. Levels of autonomy Runtime autonomy-represents the amount of control a service has over its execution environment at runtime. Design-time autonomy- represents the amount of governance control a service owner has over the service design. Primary benefits Increased reliability Behavioral predictability

D. Contemporary SOA is based on open standards:

Based on open standards, messages travel between services via a set of protocols that is globally standardized and accepted Messages format is standardized, too.

SOAP, WSDL, XML, and XML schema allow messages to be fully self-contained For services to communicate, they only need to know of each other‘s service description. This supports loose-coupling. Standard open technologies are used within and outside of solution boundaries.

E. Contemporary SOA supports vendor diversity:

The communications framework bridges the heterogeneity within and between

corporations Integration technologies encapsulate legacy logic through service adapters. Platform neutral communication such as .NET solution J2EE solution.

F. Contemporary SOA fosters intrinsic interoperability:

The design characteristics required to facilitate interoperability are

Standardization

S.K.P. Engineering College, Tiruvannamalai

Scalability

Behavioral predictability

Reliability

VII SEM

G. Contemporary SOA promotes discovery:

Universal description discovers and integration(UDDI) provided for service

registries.Some SOA systems used UDDI service registry or directory to manage service descriptions.

Services are supplemented with communication meta data by which they can be effectively discovered and interpreted.

Store Meta data in a service registry or profile documents

H. Contemporary SOA promotes federation:

Establishing and standardizing the ability to encapsulate legacy and non-legacy application logic and by exposing it via an open, common standard communications framework. Communication channels are all uniform and standardized. Services enable standardized federation of disparate legacy systems. I. Contemporary SOA promotes architectural composability:

Supports the automation of flexible, adaptable business process by composing loosely coupled services. Flexible service contracts to allow different types of data exchange requirements for similar functions Services are effective composition participants, regardless of the size and complexity of the composition. Ensures services are able to participate in multiple compositions to

solve multiple larger problems-related to reusability principle Advantages

Composite applications faster than writing a program from scratch. Building new

services and application becomes quicker and cheaper J. Contemporary SOA fosters inherent reusability Service-oriented design principles encourage reuse of software Services can be composed into larger services which in turn can be reused Services contain and express logic and can be positioned as reusable enterprise resources Reusable services have the following characteristics:

Defined by an agnostic functional context Logic is highly generic

Has a generic and extensible contract Can be accessed concurrently

K. Contemporary SOA emphasizes extensibility:

When encapsulating functionality through a service description, you are encouraged to think beyond a point-to-point solution. Extensibility can be achieved less significantly due to loosely coupled relationship fostered among all services.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

L.Contemporary SOA implements layers of abstraction:

SOA introduce layers of abstraction by positioning services as the sole access points to

a Variety of resources and processing logic. The abstraction is targeted at business and

application logic and the functionality is offered via the service interfaces. Application

logic created with proprietary technology can be abstracted through a dedicated service layer.

M. Contemporary SOA supports a service-oriented business modeling paradigm:

Partitioning business logic into services that can be composed has significant

implications as to how business processes can be modeled. BPM models, entity models and other forms of business intelligence can be accurately represented through coordinated composition of business-centric services.

A

collection (layer) of services encapsulating business process logic.

N.

Contemporary SOA promotes loose coupling throughout the enterprise:

The loose coupling concept is achieved by implementing standardized service abstraction layers when service-orientation principles are applied to both business modeling and technical design. Each domain are allowed to evolve more independently which result in an better accommodate business and technology-related change-quality environment known as organizational agility. Through the implementation of service layers that abstract business and application

logic, the loose coupling paradigm can be applied to the enterprise as a whole.

O. Contemporary SOA Promotes organizational agility:

Organizational agility refers to efficiency with which an organization can respond to

change. High dependency between parts of an enterprise means that changing software is more complicated and expansive, leveraging service business representation, service abstraction, and loose coupling promotes agility

P. Contemporary SOA is a building block:

Services are composed into larger services.Multiple SOA applications can be pulled into service-oriented integration technologies to help build a service-oriented Enterprise (SOE).An SOA consists of services within services, to the point that a solution based on SOA itself is one of many services within an SOE.

Definition of SOA after applying the above characteristics:

SOA can establish an abstraction of business logic and technology, resulting in a loose coupling between these domains‘. These changes foster service-orientation in support of a service-oriented enterprise.

Q. Contemporary SOA is an evolution:

S.K.P. Engineering College, Tiruvannamalai

VII SEM

SOA is a distinct architecture from the previous. It is influenced by concepts in service- orientation and web services Promotes reuse, encapsulation, componentization, and distribution of application logic like previous technologies

R. Contemporary SOA is still maturing:

Standards organization and vendors are continuing to develop new SOA technologies.

They are extended to support the creation of enterprise SOA solutions.

S. Contemporary SOA is an achievable ideal:

Many organizations begin with a single application and then begin leveraging service into other applications Changing to SOA requires cultural changes in an organization

2. Compare SOA with client-server and distributed internet

L2 - Nov/Dec 2016 1.SOA vs. client-server Architecture:

Client-server architecture is architecture in which one piece of software requests or receives information from another. The industry term "client-server architecture" generally refers to a particular generation of early environments during which the client and the server played specific roles and had distinct implementation characteristics. Client-server architecture:

Single-tier client-server architecture Single-tier client-server architecture is an environment in which bulky mainframe back-

ends server served the thin clients. Thin client model:

In a thin client model, all of the application processing and data management is carried out on the server. The client is simply responsible for running the presentation software Types of communication:

Synchronous communication - Allow the client and server to wait for each other to transfer the message. That is, the client will not continue until the server has received the message. Asynchronous communication- Allow the server to continuously receive message from the client without waiting for the server to respond. Disadvantage Places a heavy processing load on both the server and the network.

2. Two-tier client-server architecture

Two-tier client-server architecture consists of multiple fat clients, each with its own connection to a database o a central server. Fat-client model:

In fat-client model, the server is only responsible for data management.

architectures.

.[ CO3

S.K.P. Engineering College, Tiruvannamalai

VII SEM

The software on the client implements the application logic and the interactions with the system user.

Operation of Two-tier client-server architecture:

The client accepts user requests and performs the bulk of application logic that produces database requests and transmits them to the server.

The server accepts the requests, performs the data access logic, and transmits the results to the client.

The client accepts the results and presents them to the end user.

Characteristics of Two-tier client-server architecture:

The primary characteristics of the two tier client server architecture is given below which is compared to SOA

o

Application logic

o

Application architecture

o

Technology

o

Security

o

Administration

Application logic:

Client Server Architecture - The application or business logic either resides on the client or on the database server in the form of stored procedures. SOA - The processing logic is partitioned into autonomous units which facilitate design

qualities, future compos ability and reusability. Client server architecture

Client is responsible for the bulk of processing

80/20 ratio is used as a rule of thumb.

Communication is predictably synchronous

Client establish its own database connection-persistent

Client side executables are fully state ful

Client is independently responsible for its actions; server doesn‘t track set of clients or ensure that cached data stays up to date.

Consume a steady chunk of PC memory

All available resources are offered to the application

SOA:

Processing in SOA is highly distributed.

Communication between services and requestor can be synchronous or

asynchronous SOA provides stateless and autonomous nature or services: Server tracks its client, takes actions to keep their cached states ―current ―. Client can trust its cached data.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Further processing is made easier by reducing the need for runtime caching of state information

3. Explain in detail about Benefits of SOA.[ CO3 L2] SOA can result in the creation of solutions that consist of inherently interoperable services. Utilizing solutions based on interoperable services is part of service-oriented integration (SOI) and results in service-oriented integration architecture.Because of the vendor-neutral communications framework established by Web services-driven SOAs, the potential is there for enterprises to implement highly standardized service descriptions and message structures.

The net result is intrinsic interoperability, which turns a cross-application integration project into less of a custom development effort, and more of a modeling exercise. The bottom line: The cost and effort of cross-application integration is significantly lowered when applications being integrated are SOA-compliant.

Inherent reuse Service-orientation promotes the design of services that are inherently reusable. Designing services to support reuse from the get-go opens the door to increased opportunities for leveraging existing automation logic. The bottom line: Building services to be inherently reusable results in a moderately increased development effort and requires the use of design standards. Subsequently leveraging reuse within services lowers the cost and effort of building service-oriented solutions.

Streamline architectures and solutions The aspect of service-oriented architecture can lead to highly optimized automation environments, where only the technologies required actually become part of the architecture. The bottom line: Realizing this benefit requires adherence to design standards that govern allowable extensions within each application environment. Benefits of streamlined solutions and architectures include the potential for reduced processing overhead and reduced skill-set requirements (because technical resources require only the knowledge of a given application, service, or service extension).

Leveraging the legacy investment The bottom line: The cost and effort of integrating legacy and contemporary solutions is lowered. The need for legacy systems to be replaced is potentially lessened.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

Establishing standardized XML data representation An adoption of SOA leads to the opportunity to fully leverage the XML data representation platform. A standardized data representation format (once fully established) can reduce the underlying complexity of all affected application environments. XML documents and accompanying XML Schemas (packaged within SOAP messages) passed between applications or application components fully standardize format and typing of all data communicated. The result is a predictable and therefore easily extensible and adaptable communications network.

The bottom line: The cost and effort of application development is reduced after a proliferation of standardized XML data representation is achieved.

Web services establish a common communications framework; SOA can centralize inter-application and intra-application communication as part of standard IT infrastructure. This allows organizations to evolve enterprise-wide infrastructure by investing in a single technology set responsible for communication.

The bottom line: The cost of scaling communications infrastructure is reduced, as only one communications technology is required to support the federated part of the enterprise.

IT departments are frequently required to push back and limit or even reject requests to alter or expand upon existing automation solutions.

SOA won't solve these problems entirely, but it is expected to increase empowerment of both business and IT communities. A key feature of service- oriented enterprise environments is the support of "best-of-breed" technology.

SOA establishes a vendor-neutral communications framework, it frees IT departments from being chained to a single proprietary development and/or middleware platform.

The bottom line: The potential scope of business requirement fulfillment increases, as does the qualityof business automation.

Organizational agility

Agility is a quality inherent in just about any aspect of the enterprise. A simple algorithm, a software component, a solution, a platform, a process all of these

parts contain a measure of agility related to how they are constructed, positioned, and leveraged. How building blocks such as these can be realized and maintained within existing financial and cultural constraints ultimately determines the agility of the organization as a whole.

The bottom line: The cost and effort to respond and adapt to business or technology-related change isreduced.

S.K.P. Engineering College, Tiruvannamalai

VII SEM

4. Discuss in detail about the Common principles of service- orientation.[ CO3 L2 - May/June 2015] A service-oriented architecture is an environment standardized according to the principles of service-orientation in which a process that uses services (a service- oriented process) can execute.

Separation of concerns:

―Separation of concerns‖ is an established software engineering theory based on the idea of breaking down a large problem into a series of individual concerns. Allows the logic required to solve the problem to be decomposed into a collection of smaller, related pieces. Each piece of logic addresses a specific concern. Implemented in different ways with different development platforms

Principles of Service orientation:

Services are reusable

Services share a formal contract

Services are loosely coupled

Services abstract underlying logic

Services are compos able

Services are autonomous

Services are stateless

Services are discoverable

(i). Services are reusable Service reusability is a design principle that is used to create services (collection of related operations) that have the potential to be reused across the enterprise resources. The more generic a services operations are, the more reusable the service. Messaging also supports service reusability through the use of SOAP headers. Reusability includes,

Inter-application interoperability

Composition

Creation of cross-cutting or utility services

Benefits

Accommodate future requirements with less development effort.

Reduce the need for creating wrapper services

Reduction of cost by not just avoiding duplication of code

Reducing risks by reusing well-tested code and runtime environments

S.K.P. Engineering College, Tiruvannamalai

VII SEM

(ii).Services share a formal contract:

Service contract provide a formal definition for all of the primary parts of an SOA The service endpoint Each service operation Every input and output message supported by each operation Rules and characteristics of the service and its operations Benefits Provide semantic information of how a service accomplishes a particular task. Services express their purpose and capabilities via a service contract. Shared among services-need careful maintenance and versioned

(iii).Services are loosely coupled:

Loose coupling is a condition wherein a service acquires knowledge of another services while still remaining independent of that services. It is achieved through the use of services contract that allow services to interact within predefined parameters Note: service contracts impose low consumer coupling requirements and are themselves decoupled from theirsurrounding environment.

(iv).Services abstract underlying logic:

Service interface-level abstraction is this principle that allows a service details are hidden from the potential customers. Service provides the following,

Simple task to perform

Gateway to an entire automation solution

Represent limitless amount of logic

Act as a container for the operations that abstract the logic

Benefits Directly enables and preserves the previously described loosely coupled relationship. (v). Services are composable:

o

Services are effective composition participants, regardless of the size and complexity of the composition. It is controlled by a parent process service that compose process participants

o

A service composition is an aggregate of services collectively composed to automate a particular task or business process.

Benefits

Reusability

S.K.P. Engineering College, Tiruvannamalai

(vi). Services are autonomous:

VII SEM

Note: Does not necessarily grant a service exclusive ownership of the logic encapsulates Types of autonomy:

Service-level autonomy: Service boundaries are distinct from each other, but the service may share underlying resources. It governs the legacy system but also shares resources with other legacy clients. Pure autonomy :When the underlying logic is built from the ground up in support of the service which has complete control and ownership of that logic.

(vii). Services are stateless:

State refers to something‘s particular condition. They are two primary conditions can be invoked:

Stateful : A Stateful services a service that is actively engaged in the process of retaining or processing state information. Stateless : A stateless service is a service whose response does not require access or use of information

Stateless services do scale better

Promotes reusability and scalability

(viii). Services are discoverable:

In SOA level, discoverability refers to the architectures ability to provide a discovery mechanism, such as a service registry or directory. On a service level, the principle of discoverability refers to the design of an individual service so that it can be as discoverable as possible. Benefits Avoids the accidental creation of redundant services or services that implement redundant logic.

5. Explain about Service Layers in detail.[ CO3 L2 - May/June 2015] ]

1. Service-orientation and contemporary SOA

The majority of Web services specifications are open and vendor neutral.QoS capableThe quality of service improvements provided by contemporary SOA are, for the

most part, realized via vendor implementations of individual WS-extensions.

Architecturally composable While compos ability, on a service level, is one of our service-orientation principles, for an architecture to be considered composable requires that the technology from which the architecture is built support this notion. For the most part, the specifications that comprise the WS-―landscape fully enable architectural

S.K.P. Engineering College, Tiruvannamalai

VII SEM

compos ability by allowing a given SOA to only implement extensions is actual requires. Vendor diversity This is really more of a benefit of SOA than an actual characteristic. Regardless, it is primarily realized through the use of the open standards provided by the Webservices platform. Intrinsic interoperability.

The standardized communications framework provided by Web services establishes the potential to foster limitless interoperability between services. This is no big secret. To foster intrinsic interoperability among services,though,requires forethought and good design standards. Although supported by a number of WS specifications, this characteristic is not directly enabled by our identified influences. discoverabilityService level discoverability is one of our fundamental principles of service-orientation, implementing discoverability on an SOA level typically requires the use of directory technologies, such as UDDI (one of the first generation Web services specifications).

Promotes federation Federation is a state achieved by extending SOA into the realm of service-oriented integration. A number of key WS- extensions provide features sets that supports the attainment of federation. Most notable among these are the specifications that implement the concepts of orchestration and choreography.Inherent reusabilityReusability is one of the primary principles of service orientation and one that can be applied across service oriented solution environments.

SOA promotes the creation of inherently reusable service logic within individual services and across service design compositions benefit attainable through quality service design extensibility Given that Web services are composable and based on open standards,extensibility is a natural benefit of this platform. Several WS extensions introduce architectural mechanisms that build extensibility into a solution. However, for the most part, this is a characteristic that must be intentionally designed into services individually and into SOA as a whole.

(i)Mapping the origins and supporting sources of concrete SOA Characteristics (ii)Unsupported SOA characteristics intrinsic interoperability extensibility enterprise-wide loose coupling service-oriented business modeling organizational agility layers of abstraction enterprise-wide loose coupling support for service-oriented business modeling

S.K.P. Engineering College, Tiruvannamalai

VII SEM

organizational agility layers of abstraction The service layer is between the application layer and the business process layer

2. SERVICE LAYER ABSTRACTION:

The service layer is between the application layer and the business process layer Problems solved by layering services:

(i) What logic should be represented by services? Enterprise logic can be divided into two primary domains

Business logic Application logic (ii) How should services relate to existing application logic? Existing legacy application logic needs to be exposed via services or whether new logic is being developed in support of services number of constrains, limitations, and environmental requirements (iii) How can services best represent business process logic When modeling service to represent business logic, the service representation of business logic should be alignment with existing business models. (iv) How can services be built and positioned to promote agility? The key to building an agility SOA is in minimizing the dependencies each services has within its own processing logic. Layers of abstraction Each layer can abstract a specific aspect of the solution, addressing to one of the issues that are identified. The three layers of abstraction identified for SOA are:

The application service layer

The business service layer

The orchestration service layer

3. APPLICATION SERVICE LAYER (NOV/DEC 2012) The application service layer consists of application services that represent technology specific logic. Typically incarnations of application services are the Utility models Wrapper modelsIt consists of services that encapsulate some or all parts of a legacy environment to expose legacy functionality to service requestors. Characteristics

Expose functionality within a specific processing context

Draw upon available resources within a given platform