Вы находитесь на странице: 1из 28

1.What is XML?

Extensible Markup Language (XML) is the universal


language for data on the Web
XML is a technology which allows us to create our
own markup language.
XML documents are universally accepted as a
standard way of representing information in platform and
language independent manner.
XML
is
universal
standard
for
information
interchange.
XML documents can be created in any language and
can be used in any language.
2.What is the difference between XML and HTML?
XML is no way clashes with HTML, since they are for two
different purposes.
HTML
XML
HTML is for displaying purpose.

whereas
XML
representation.

is

for

HTML is used to mark up text so it XML is used to mark up data


can be displayed to users.
can be processed by computer
HTML describes both structure (e.g.
<p>,
<h2>,
<em>)
and XML describes
appearance (e.g. <br>, <font>, meaning
<i>)

only

conten

HTML uses a fixed, unchangeable


In XML, you make up your own
set of tags
3.What are the benefits of XML?
There are many benefits of using XML on the Web :

Simplicity- Information coded in XML is easy to read


and understand, plus it can be processed easily by
computers.
Openness- XML is a W3C standard, endorsed by
software industry market leaders.
Extensibility - There is no fixed set of tags. New
tags can be created as they are needed.
Self-description- In traditional databases, data
records require schemas set up by the database
administrator. XML documents can be stored without such
definitions, because they contain meta data in the form of
tags and attributes.
Contains
machine-readable
context
information- Tags, attributes and element structure
provide context information that can be used to interpret
the meaning of content, opening up new possibilities for
highly efficient search engines, intelligent data mining,
agents, etc.
Separates content from presentation- XML tags
describe meaning not presentation. The motto of HTML is:
"I know how it looks", whereas the motto of XML is: "I
know what it means, and you tell me how it should look."
The look and feel of an XML document can be controlled
by XSL style sheets, allowing the look of a document to
be changed without touching the content of the
document. Multiple views or presentations of the same
content are easily rendered.
Supports multilingual documents and UnicodeThis is important for the internationalization of
applications.
Facilitates the comparison and aggregation of
data- The tree structure of XML documents allows

documents to be compared and aggregated efficiently


element by element.
Can embed multiple data types - XML documents
can contain any possible data type - from multimedia
data (image, sound, video) to active components (Java
applets, ActiveX).
Can embed existing data - Mapping existing data
structures like file systems or relational databases to XML
is simple. XML supports multiple data formats and can
cover all existing data structures and.
Provides a 'one-server view' for distributed
data - XML documents can consist of nested elements
that are distributed over multiple remote servers. XML is
currently the most sophisticated format for distributed
data - the World Wide Web can be seen as one huge XML
database.
4.What is a well-formed XML document?
If a document is syntactically correct it can be called as
well-formed XML documents. A well-formed document
conforms to XML's basic rules of syntax:
Every open tag must be closed.
The open tag must exactly match the closing tag:
XML is case-sensitive.
All elements must be embedded within a single root
element.
Child tags must be closed before parent tags.
A well-formed document has correct XML tag syntax,
but the elements might be invalid for the specified
document type.
5.What is a valid XML document?
If a document is structurally correct then it can be called
as valid XML documents. A valid document conforms to
the predefined rules of a specific type of document:

These rules can be written by the author of the XML


document or by someone else.

The rules determine the type of data that each part


of a document can contain.
Note:Valid XML document is implicitly well-formed, but
well-formed may not be valid
6.What is the structure of XML document?
Figure 1: XML Structure
7.What is a Processing Instruction in XML?
A Processing Instruction is the information which we
would like to give to application. Through a
ProcessingInstruction an application would get idea about
how to process the document. A ProcessingInstruction
can appear anywhere and any no. of times in a
document.

8.How does the XML structure is defined?


XML document will have a structure which has to be
defined before we can create the documents and work
with them. The structural rules can be defined using
many available technologies, but the following are
popular way of doing
Document Type Definition (DTD)
Schema
9.What is DTD?
A Document Type Definition (DTD) defines the legal
building blocks of an XML document. It defines rules for a
specific type of document, including:
Names of elements, and how and where they can be
used
The order of elements

Proper nesting and containment of elements


Element attributes
To apply a DTD to an XML document, you can:
Include the DTD's element definitions within the XML
document itself.
Provide the DTD as a separate file, whose name you
reference in the XML document.
10.What is XML Schema?
An XML Schema describes the structure of an XML
instance document by defining what each element must
or may contain. XML Schema is expressed in the form of a
separate XML file.
XML Schema provides much more control on element
and attribute datatypes.
Some datatypes are predefined and new ones can be
created.
Allows for faster message validation and processing
Has a unique ID called a namespace

Figure 2: XML Schema

11.What are differences between DTDs and


Schema?
Schema

DTD

Schema document is an XML


document i.e., the structure of an
DTDs follow SGML syntax.
XML document is specified by
another XML document.

Schema
supports
variety
of
dataTypes similar to programming In DTD everything is treated as
language.

In Schema, It is possible to inherit


This is not possible in DTD w
and create relationship among
invalidating existing document
elements.

In Schema, It is possible to group


elements and attributes so that Grouping of elements and attr
they can be treated as single logical is not possible in DTD.
unit.
In Schemas, it is possible to specify
It is not possible to specify an
an upper limit for the number of
limit of an element in DTDs
occurrences of an element
12.What are the different data types in XSD? How
do you define it?
There are different datatypes: int, string, date etc. You
can have custom datatype as in the Java classes. You
have
to
refer
them
using
the
<xsd:attribute name="shoetype" type="xsd:string"/>
13.What is a Complex Element?
A complex element is an XML element that contains other
elements
and/or
attributes.
There are four kinds of complex elements:

empty elements
elements that contain only other elements
elements that contain only text
elements that contain both other elements and text
14.What is a Simple Element?
A simple element is an XML element that can contain only
text.
A simple element cannot have attributes
A simple element cannot contain other elements
A simple element cannot be empty
However, the text can be of many different types,
and may have various restrictions applied to it
15.What are namespaces? Why are they
important?
A simple element is an XML element that can contain only
text.
Namespaces are a simple and straightforward way to
distinguish names used in XML documents, no matter
where they come from.
XML namespaces are used for providing uniquely
named elements and attributes in an XML instance
They allow developers to qualify uniquely the
element names and relationships and make these names
recognizable, to avoid name collisions on elements that
have the same name but are defined in different
vocabularies.
They allow tags from multiple namespaces to be
mixed, which is essential if data is coming from multiple
sources.
Example: a bookstore may define the <TITLE> tag to
mean the title of a book, contained only within the
<BOOK> element. A directory of people, however, might
define <TITLE> to indicate a person's position, for

instance: <TITLE>President</TITLE>. Namespaces help


define this distinction clearly.
Note: a) Every namespace has a unique name which is a
string. To maintain the uniqueness among namespaces a
IRL is most preferred approach, since URLs are unique.
b) Except for no-namespace Schemas, every XML
Schema
uses
at
least
two
namespaces:
1.
The
target
namespace.
2.
The
XMLSchema
namespace
(http://w3.org/2001/XMLSchema)
16.What are the ways to use namespaces?
There are two ways to use namespaces:

Declare a default namespace

Associate a prefix with a namespace, then use the


prefix in the XML to refer to the namespace
17.What is the relevance of ElementFormDefault
attribute in the Schema?
ElementFormDefault indicates whether or not locally
declared elements must be qualified by the target
namespace
in
an
instance
document.
ElementFormDefault attribute in the Schema has the
following relevance:

Qualified: Each and every element of the Schema


must be qualified with the namespace in the instance
document.

Unqualified: means only globally declared elements


must be qualified with there namespace and not the local
elements.
The form for elements declared in the target namespace
of this schema. The value must be "qualified" or
"unqualified". Default is "unqualified". "unqualified"

indicates that elements from the target namespace are


not required to be qualified with the namespace prefix.
"qualified" indicates that elements from the target
namespace must be qualified with the namespace prefix
18.What is a inline schema?
Inline schemas are XML schema definitions included
inside XML instance documents. Like external schema
documents, inline schemas can be used to validate that
the instance matches the schema constraints.
19.Difference between Include and Import in
context to XML schema?
The fundamental difference between include and import
is that you must use import to refer to declarations or
definitions that are in a different target namespace and
you must use include to refer to declarations or
definitions that are (or will be) in the same target
namespace.
20.What is targetNamespace's function?
<schema xmlns="http://www.w3.org/2001/SchemaXML
targetNamespace="http://www.example.com/name"
xmlns:target="http://www.example.com/name">
The targetNamespace declares a namespace for other
xml and xsd documents to refer to this schema. The
target prefix in this case refers to the same namespace
and you would use it within this schema definition to
reference other elements, attributes, types, etc. also
defined in this same schema definition.
21.Difference between URI and URL?
A URI is an identifier for some resource, but a URL gives
you specific information as to obtain that resource. A URI

is a URL and as one commenter pointed out, it is now


considered incorrect to use URL when describing
applications. Generally, if the URL describes both the
location and name of a resource, the term to use is URI.
Since this is generally the case most of us encounter
every day, URI is the correct term.
22.What is XML parser?
An XML parser is a piece of software which can do
following:

Check for well-formedness

Validate the document

Allows us to read, create or modify existing XML


documents
Note: Parser is piece of software provided by vendors. An
XML parser is built in Java runtime from JDK 1.4 onwards
23.What is DOM?
The Document Object Model (DOM) is a platform and
language-independent standard object model for
representing XML and related formats. DOM is standard
API which is not specific to any programming language.
DOM represents an XML document as a tree model. The
tree model makes the XML document hierarchal by
nature. Each and every construct of the XML document is
represented as a node in the tree.
24.What is the difference between call-template
and apply-template?
Call template is almost like calling a function in a
traditional
programming
language.
Apply Template is a little different one but it is the real
power of XSLT: It takes any number of XML nodes
(whatever you define in the select attribute), iterates

them ( apply-templates works like a loop!) and finds


matching templates for them.
25.What is SAX?
SAX-Simple API for XML processing. SAX provides a
mechanism for reading data from an XML document. It is
a popular alternative to the Document Object Model
(DOM).SAX provides an event based processing approach
unlike DOM which is tree based.

26.What are the interfaces of SAX?


The interfaces of SAX are:
DocumentHandler- is used for getting event
notification relating to a document.
DTDHandler- is implemented to get the notifications
related to declarations in DTD like entities and notations
EntityResolver- is used for reading external
entities.
ErrorHandler- is used for handling error related
notifications.
27.What is the difference between SAX parser and
DOM parser?
SAX
DOM
A SAX parser takes the occurrences
of
components
of
an
input
document as events (i.e., event
based processing), and tells the
client what it reads as it reads
through the input document.

A DOM parser creates a


structure in memory from an
document and then waits
requests from client.

No navigation possible
bottom only once)

Whereas, we can navigate the


tree in any direction, any n
times.

(top

to

We cannot modify the document We can modify


content in SAX
content in DOM

the

docu

A DOM parser always serve


A SAX parser serves the client
client application with the
application always only with pieces
document no matter how mu
of the document at any given time.
actually needed by the client.

A SAX parser, however, is much


A DOM parser is space ineffi
more space efficient in case of a big
when the document is huge.
input document
Use SAX parser when

Input document is too big for


available memory.

When only a part of the


document is to be read and we
create the data structures of our
own.

If you use SAX, you are using


much less memory and performing
much
less
dynamic
memory
allocation.

Use DOM when


Your application has to a
various parts of the documen
using your own structure is ju
complicated as the DOM tree.
Your application has to c
the tree very frequently and
has to be stored for a sign
amount of time.

28.What is a CDATA section in XML?


CDATA Sections are used to escape blocks of text
containing characters which would otherwise be
recognized as markup. All tags and entity references are
ignored by an XML processor that treats them just like
any character data. CDATA blocks have been provided as
a convenience measure when you want to include large
blocks of special characters as character data, but you do
not want to have to use entity references all the time.
29.What is XSL?

eXtensible Stylesheet Language(XSL) deals with most


displaying the contents of XML documents.XSL consists of
three parts:

XSLT - a language for transforming XML documents

XPath - a language for navigating in XML documents

XSL-FO - a language for formatting XML documents


30.How is XSL different from Cascading Style
Sheets? Why is a new Stylesheet language
needed?
XSL is compatible with CSS and is designed to handle the
new capabilities of XML that CSS can't handle. XSL is
derived from Document Style Semantics and Specification
Language (DSSSL), a complex Stylesheet language with
roots in the SGML community. The syntax of XSL is quite
different from CSS, which could be used to display simple
XML data but isn't general enough to handle all the
possibilities generated by XML. XSL adds the capability to
handle these possibilities. For instance, CSS cannot add
new items or generated text (for instance, to assign a
purchase order number) or add a footer (such as an order
confirmation). XSL allows for these capabilities.
31.What is XSLT?
eXtensible Stylesheet Language Transformation (XSLT)
deals with transformation of one XML document into
XHTML documents or to other XML documents. XSLT uses
XPath for traversing an XML document and arriving at a
particular node.

Figure 3: XSLT
32.What is the role of XSL transformer?
An XSL transformer will transform in the following way:

The source tree is obtained by parsing in a normal


XML style

The transformation is now applied to the source with


the help of information available in Stylesheet.
33.What is the structure of XSLT?

Figure 4: XSLT Structure


34.What is XSL template?
Template specifies transformation rules. A Stylesheet
document can be made up of at least one template,
which acts as an entry point. Every template uniquely
identifies a particular node in the source tree.
35.What is XPath?
XPath is an standard expression language, used for to
identify or locate portions of an XML. XPath is used to
navigate through elements and attributes in an XML
document.

36.What is XQuery?
XQuery is a query and functional programming language
that is designed to query and transform collections of
structured and unstructured data, usually in the form of
XML, text and with vendor-specific extensions for other
data formats (JSON, binary, etc.).

37.What is XSL-FO?
XSL-FO deals with formatting XML data. This can be
used for generating output in a particular format like XML
to PDF, XML to DOC, etc.
38.How XSL-FO Works (or) How would you produce
PDF output using XSL's?

Figure 5: XSL-FO

1.What is Web Service?


Web service is a piece of code which is available on web
(internet). That code of piece can be developed in any
language (java, .net etc). A client invokes the web service
by sending xml message and it wait for xml response
(synchronously or asynchronously).
2.What is WSDL?

The Web Services Description Language (WSDL) is an


XML-based grammar that defines the operations that a
web service offers and the format of the request and
response messages that the client sends to and receives
from the operations. The request and response messages
define the names and types of the data that the client
exchanges with the operation. You can build a web
service client on any platform and in any language that
supports web services.
3.What is WSDL and DISCO file?
WSDL: Files with the WSDL extension contain web
service interfaces expressed in the Web Service
Description Language (WSDL). WSDL is a standard XML
document type specified by the World Wide Web
Consortium.WSDL files are used to communicate
interface information between web service producers and
consumers. A WSDL description allows a client to utilize a
web service capabilities without knowledge of the
implementation
details
of
the
web
service.
Disco: It is a Microsoft technology for publishing and
discovering Web Services. DISCO can define a document
format along with an interrogation algorithm, making it
possible to discover the Web Services exposed on a given
server. DISCO makes it possible to discover the
capabilities of each Web Service (via documentation) and
how to interact with it. To publish a deployed Web Service
using DISCO, you simply need to create a .disco file and
place it in the vroot along with the other service-related
configuration.
4.What are ends, contract, address, and bindings?

These three terminologies on which SOA service stands.


Every service must expose one or more ends by which
the service can be available to the client. End consists of
three important things where, what and how:
Contract (What) : Contract is an agreement
between two or more parties. It defines the protocol how
client should communicate with your service. Technically,
it describes parameters and return values for a method

Address (Where) : An Address indicates where we


can find this service. Address is a URL, which points to the
location of the service.

Binding (How) : Bindings determine how this end


can be accessed. It determines how communications is
done. For instance, you expose your service, which can
be accessed using SOAP over HTTP or BINARY over TCP.
So for each of these communications medium two
bindings will be created.
Below figure, show the three main components of end.
You can see the stock ticker is the service class, which
has an end hosted on www.soa.com with HTTP and TCP
binding support and using Stock Ticker interface type.

Figure: - Endpoint Architecture

Note: You can also remember the end point by ABC


where A stands for Address, B for bindings and C for
Contract.
5.What is the Difference between abstract and
concrete WSDL?
An abstract WSDL document describes what the web
service does, but not how it does it or how to contact it.
The abstract WSDL document contains the types,
the message, and the portType elements. It describes the
service's interface and the messages exchanged by the
service. Within the types element, XML Schema is used to
define the structure of the data that makes up the
messages. A number of message elements are used to
define the structure of the messages used by the service.
The portType element contains one or more operation
elements that define the messages sent by the
operations
exposed
by
the
service.
The concrete WSDL document contains the binding and
the service elements. It describes how an endpoint that
implements the service connects to the outside world.
The binding elements describe how the data units
described by the message elements are mapped into a
concrete, on-the-wire data format, such as SOAP.
The service elements contain one or more port elements
which define the endpoints implementing the service.

Figure: - WSDL
6.What are the WSDL Document Elements?
A WSDL document is made up of the following elements:
definitions: The root element of a WSDL document.
The attributes of this element specify the name of the
WSDL document, the document's target namespace, and
the shorthand definitions for the namespaces referenced
in the WSDL document
types: The XML Schema definitions for the data units
that form the building blocks of the messages used by a
service.
message: The description of the messages
exchanged during invocation of a services operations.
These elements define the arguments of the operations
making up your service.
operation: An abstract description of the action
supported by the service.
portType: An abstract set of operations supported
by one or more endpoints.

binding: Describes how the operation is invoked by


specifying
concrete
protocol
and
data
format
specifications for the operations and messages.
service: Specifies the port address(es) of the
binding. The service is a collection of network endpoints
or ports.
port: Specifies a single endpoint as an address for
the binding, thus defining a single communication
endpoint.
7.What are the transmission operations/primitives
in wsdl?
WSDL has four transmission primitives that an endpoint
can support:
One-way The endpoint receives a message.
Request-response The
endpoint
receives
a
message, and sends a correlated message.
Solicit-response The endpoint sends a message,
and receives a correlated message.
Notification The endpoint sends a message.
8.Why there is need to concrete and abstract wsdl?
Concrete wsdl is the client side rather run time wsdl
which has the information like binding,endpoint where as
abstract wsdl is the design wsdl. client wsdl is sufficient
to proceed with the build since it removes the
dependency that the service should be deployed and
ready before starting the build. Also same abstract can be
used for multiply binding with different concrete wsdl this
removes the code redundancy. Also in SOA perspective,
abstract wsdl should be used rather than the concrete
since when the process loads there will dependency
across the calling services if the callee service didn't load
before the caller service then the service state will be
unknown in SOA. To avoid this if we use abstract wsdl all

the process loads normally and the concrete binding will


be used only when it starts receiving the request.
9.What is the difference between Async and Sync
activity on wsdl level?
Async wsdl - It has only input messages for the
operation and it has 2 operations one for sending the
request and other for call back.Sync wsdl - It has 2
messages input and output messages for the wsdl
operation.
10.What is the significance of target Namespace in
a wsdl?
It is the one which uniquely identifies the WSDL and when
the WSDL is used it should be identified using its Target
Namespace.
11.Why do we need to have messages in WSDL,
aren't operations and types enough to describe the
parameters for a web service?
Messages consist of one or more logical parts. Each part
is associated with a type from some type system using a
message-typing attribute. The set of message-typing
attributes is extensible. The element describes the data
being exchanged between the Web service providers and
consumers. Each Web Service has two messages: input
and output. The input describes the parameters for the
Web Service and the output describes the return data
from the Web Service. Each message contains zero or
more parameters, one for each parameter of the Web
Service's function. Each parameter associates with a
concrete type defined in the container element. So
describing the parameters cannot performed by
operations and types this is the main need of Messages.

12.What is the difference between RPC and


Document Type?
A web service is usually described by a WSDL (Web
Services Description Language) document. In this
document, the supported web service operations and
messages are described abstractly and then bound to a
concrete network protocol and message format. A typical
WSDL document consists of the following elements:
"types," "message," and "portType" for the abstract
definitions; "binding" and "service" for the concrete
specification. All of these elements are wrapped inside a
"definitions"
element.
In the context of RPC and document style, it is the
binding element that we need to take a closer look at. A
WSDL binding describes how the service is bound to a
messaging protocol, either HTTP GET/POST, MIME, or
SOAP. In practice, SOAP is the most universally used
protocol; it is SOAP that the RPC/document distinction
refers to. Usually HTTP(S) is used as transport protocol for
the
SOAP
message
"SOAP
over
HTTP(S)."
The <wsdl:binding> element of the WSDL contains a pair
of parameters that influence the form of the resulting
SOAP messages: binding style (RPC or document) and use
(encoded or literal). See how style and use are defined in
the WSDL fragment below:
01. <wsdl:binding name="Config1Binding" type="prt0:C
reditLimitLocalWebServiceVi_Document">
02. <soap:binding transport="http://schemas.xmlsoap.o
rg/soap/http" style="document" />
03. <wsdl:operation name="creditLimitCheck">
04. <soap:operation soapAction="" />
05. <wsdl:input >

06.
<soap:body use="literal" use="parameters"/>
07. </wsdl:input >
08. <wsdl:output >
09.
<soap:body use="literal" />
10. </wsdl:output >
11. </wsdl:operation >
12.</wsdl:binding >
The
"Style"
Attribute
WSDL 1.1 specifies the style of the binding as either RPC
or document. This choice corresponds to how the SOAP
payload - i.e., how the contents of the <soap:Body>
element - can be structured. Here are some details of
how each style affects the contents of <soap:Body>:

Document: the content of <soap:Body> is specified


by XML Schema defined in the <wsdl:type> section. It
does not need to follow specific SOAP conventions. In
short, the SOAP message is sent as one "document" in
the <soap:Body> element without additional formatting
rules having to be considered. Document style is the
default choice.

RPC: The structure of an RPC style <soap:Body>


element needs to comply with the rules specified in detail
in Section 7 of the SOAP 1.1 specification. According to
these rules, <soap:Body> may contain only one element
that is named after the operation, and all parameters
must be represented as sub-elements of this wrapper
element.
As a consequence of the freedom of choice that the
document style offers, the SOAP messages conforming to
a document style WSDL may look exactly the same as the
RPC equivalent. The decisive question now is: What are
the consequences of choosing one option or another?
Why choose RPC over document, or document over RPC?

In many cases, the SOAP messages generated from either


RPC or document style WSDLs look exactly the same - so
why offer the choice at all? The reason may be found in
the
history
of
the
SOAP
standard.
SOAP has its roots in synchronous remote procedure calls
over HTTP and the appearance of the document
accordingly followed these conventions. Later, it was
seen as a simplification to use arbitrary XML in the SOAP
body without adhering to conventions. This preference is
reflected in the document style WSDL documents. So far,
both options are represented in the WSDL specification
and the choice of one or the other is mainly a question of
personal taste since most SOAP clients today accept both
versions.
The
"Use"
Attribute
The use attribute specifies the encoding rules of the SOAP
message. This is also done within the <wsdl:binding>
element, as seen in the example above. The value can be
encoded or literal. It refers to the serialization rules
followed by the SOAP client and the SOAP server to
interpret the contents of the <Body> element in the
SOAP payload.

use="literal" means that the type definitions literally


follow an XML schema definition.

use="encoded" refers to the representation of


application data in XML, usually according to the SOAP
encoding rules of the SOAP 1.1 specification. The rules to
encode and interpret a SOAP body are in a URL specified
by the encodingStyle attribute. Encoded is the
appropriate choice where non-treelike structures are
concerned, because all others can be perfectly described
in XML Schema.
The combination of the style and use attributes leads to
four possible style/use pairs:

RPC/encoded
RPC/literal
document/encoded
document/literal
Some of these combinations are rarely used in practice,
such as document/encoded. In general, the literal use is
gaining importance, and as far as RPC/encoded is
concerned, the Web Services Interoperability Organization
(WS-I) in its Basic Profile Version 1.0a of August 2003
ruled out the use of SOAP encoding with web services.
Document/literal and RPC/literal will be the only allowed
style/use combinations in the future.

Вам также может понравиться