XML Interview Questions and Answers – 3

101. What Happens If There Is No Prefix On An Element Type Name?
If a default XML namespace declaration is in scope, then the element type name is in the default XML namespace. Otherwise, the element type name is not in any XML namespace.

102. What Is An Xml Namespace Prefix?
An XML namespace prefix is a prefix used to specify that a local element type or attribute name is in a particular XML namespace.

103. Can I Use The Same Prefix For More Than One Xml Namespace?
Yes.

104. What Is A Qualified Name?
A qualified name is a name of the following form. It consists of an optional prefix and colon, followed by the local part, which is sometimes known as a local name.
prefix:local-part
–OR–
local-part

105. What Does A Namespace-aware Application Do When It Encounters An Error?
The XML namespaces recommendation does not specify what a namespace-aware application does when it encounters a document that does not conform to the recommendation. Therefore, the behavior is application-dependent.
For example, the application could stop processing, post an error to a log and continue processing, or ignore the error.

106. Can An Application Be Both Namespace-aware And Namespace-unaware?
Yes., However, there is generally no reason to do this. The reason is that most applications understand a particular XML language, such as one used to transfer sales orders between companies. If the element type and attribute names in the language belong to an XML namespace, the application must be namespace-aware; if not, the application must be namespace-unaware.
For a few applications, being both namespace-aware and namespace-unaware makes sense. For example, a parser might choose to redefine validity in terms of universal names and have both namespace-aware and namespace-unaware validation modes. However, such applications are uncommon.

107. Can An Application Process Documents That Use Xml Namespaces And Documents That Don’t Use Xml Namespaces?
Yes., This is a common situation for generic applications, such as editors, browsers, and parsers, that are not wired to understand a particular XML language. Such applications simply treat all element type and attribute names as qualified names. Those names that are not mapped to an XML namespace — that is, unprefixed element type names in the absence of a default XML namespace and unprefixed attribute names — are simply processed as one-part names, such as by using a null XML namespace name (URI).

108. What SAX stands for?
SAX stands for Simple API for XML.

109. What is SAX?
SAX is an interface processing XML documents using events.

110. Can we create an XML document using SAX parser?
No! Using SAX parser, we can only parse or modify a XML document.

111. How Do I Use Xml Namespaces With Sax 2.0?
SAX 2.0 primarily supports XML namespaces through the following methods: * startElement and endElement in the ContentHandler interface return namespace names (URIs) and local names as well as qualified names. * getValue, getType, and getIndex in the Attributes interface can retrieve attribute information by namespace name (URI) and local name as well as by qualified name.

112. How Do Applications Process Documents That Use Xml Namespaces?
Applications process documents that use XML namespaces in almost exactly the same way they process documents that don’t use XML namespaces. For example, if a namespace-unaware application adds a new sales order to a database when it encounters a Sales Order element, the equivalent namespace-aware application does the same. The only difference is that the namespace-aware application:
•  Might need to check for xmlns attributes and parse qualified names. Whether it does this depends on whether such processing is already done by lower-level software, such as a namespace-aware DOM implementation.
•  Uses universal (two-part) names instead of local (one-part) names.

113. What Software Is Needed To Process Xml Namespaces?
From a document author’s perspective, this is generally not a relevant . Most XML documents are written in a specific XML language and processed by an application that understands that language. If the language uses an XML namespace, then the application will already use that namespace — there is no need for any special XML namespace software.

114. How Do I Create Documents That Use Xml Namespaces?
The same as you create documents that don’t use XML namespaces. If you’re currently using Notepad on Windows or emacs on Linux, you can continue using Notepad or emacs. If you’re using an XML editor that is not namespace-aware, you can also continue to use that, as qualified names are legal names in XML documents and xmlns attributes are legal attributes. And if you’re using an XML editor that is namespace-aware, it will probably provide features such as automatically declaring XML namespaces and keeping track of prefixes and the default XML namespace for you.

115. Can I Use Qualified Names In Dtds?
Yes.
For example, the following is legal:

<!ELEMENT google:A (google:B)>
<!ATTLIST google:A
google:C CDATA #IMPLIED>
<!ELEMENT google:B (#PCDATA)>

However, because XML namespace declarations do not apply to DTDs , qualified names in the DTD cannot be converted to universal names.
As a result, qualified names in the DTD have no special meaning.
For example, google:A is just google:A — it is not A in the XML namespace to which the prefix google is mapped.
The reason qualified names are allowed in the DTD is so that validation will continue to work.

116. Do Xml Namespace Declarations Apply To DTDs?
No., In particular, an xmlns attribute declared in the DTD with a default is not an XML namespace declaration for the DTD.. (Note that an earlier version of MSXML (the parser used by Internet Explorer) did use such declarations as XML namespace declarations, but that this was removed in MSXML 4.

117. Does The Scope Of An Xml Namespace Declaration Ever Include The Dtd?
No., XML namespaces can be declared only on elements and their scope consists only of those elements and their descendants. Thus, the scope can never include the DTD.

118. How Can I Declare Xml Namespaces So That All Elements And Attributes Are In Their Scope?
XML namespace declarations that are made on the root element are in scope for all elements and attributes in the document. This means that an easy way to declare XML namespaces is to declare them only on the root element.

119. What Is The Scope Of An Xml Namespace Declaration?
The scope of an XML namespace declaration is that part of an XML document to which the declaration applies. An XML namespace declaration remains in scope for the element on which it is declared and all of its descendants, unless it is overridden or undeclared on one of those descendants.

120. How Do I Undeclare The Default Xml Namespace?
To “undeclare” the default XML namespace, you declare a default XML namespace with an empty (zero-length) name (URI). Within the scope of this declaration, unprefixed element type names do not belong to any XML namespace. For example, in the following, the default XML namespace is the http://www.google.org/ for the A and B elements and there is no default XML namespace for the C and D elements. That is, the names A and B are in the http://www.google.org/ namespace and the names C and D are not in any XML namespace.

<A xmlns=”http://www.google.org/”>
<B>
<C xmlns=”">
<D>abcd</D>
</C>
</B>
</A>

121. Explain About SOAP?
SOAP acts as a medium to provide basic messaging framework. On these basic messaging frameworks abstract layers are built. It transfers messages across the board in different protocols; it also acts as a medium to transmit XML based messages over the network.

122. What is the relation of SOAP with XML?
SOAP uses XML to define a protocol for the exchange of information in distributed computing environments.

123. What is the purpose of SOAP?
A web service needs a combination of XML, HTTP and a protocol which is application-specific. A web service uses XML data for exchanging. The weather service, stock quote service, look up service of postal department are all sending XML messages and receiving an XML reply. This is the pattern that dominates the web services. To perform these web services, SOAP is the reliable protocol.

124. Give Examples Where Soap Is Used?
Remote methods over multiple platforms and technologies are used with HTTP. SOAP is XML based protocol and platform-agnostic. Each application uses different technology. This may cause problems with proxy server and firewalls. SOAP is the solution for this situation.
Industries transport the request for finding best route and best cost price. So the application transfers a request to other similar services which uses SOAP.

125. What Are Transport Methods In Soap?
Application layer and transport layers of a network are used by SOAP. SMTP and HTTP are the valid application layer protocol uses as transport for SOAP. Wider acceptance is gained by HTTP, as it works better with the current internet infrastructure, especially with firewalls.

126. What are the three components in SOAP?
It consists of an envelope, a set of encoding rules, and a convention for representing remote procedure calls.

127. Give An Example About The Functioning Of SOAP?
Consider a real estate database with huge data ranges. If a user wants to search about a particular term, the message with all the required features such as price, availability, place, etc will be returned to the user in an XML formatted document which the user can integrate into third party site for additional performance.

128. Explain About Remote Call Procedure?
Remote Call Procedure is considered as a very important function in SOAP. In RCP a user (node) sends a request to another node (server) where the information is processes and sent to the user. It immediately sends message across the network.

129. Explain About Transport Methods In SOAP?
Internet application layer is used to transfer messages from one end to another end. Various products have been transported successfully from one end to another end using SOAP. Both SMTP and HTTP are two successful transport protocols used in transmitting information, but HTTP has gained good ground than HTTP.

130. Explain About Https In SOAP?
HTTPS is similar to HTTP but it has an additional layer underneath the internet application layer which makes the data encrypted. This protocol is widely used than IOP or DCOM because those protocols are filtered by firewalls. HTTPS protocol advocates WS-I method to provide security for transmission of secured data.

131. Explain About The Role Of XML In SOAP?
XML is chosen as a standard format because it was already in use by many large companies and immensely due to its open source nature. A wide variety of tools are available on shelves which ease the process of transition to SOAP. XML can significantly reduce the speed and efficiency but binary XML is being considered as a format for future.

132. What Are The Advantages Which A User Can Get When He Uses SOAP?
SOAP by passes all firewalls thus making the process easier.
• It has huge collection of protocols
• It is platform and language independent
• Simplicity and extensible nature makes it the most wanted

133. State Some Disadvantages Due To The Usage Of SOAP?
1) SOAP is much slower than middleware technologies
2) Due to the usage of HTTP for transporting messages and not the defined ESB or WS-Addressing interaction of parties over a message is fixed.
3) Information regarding the usability of HTTP for different purposes is not present which makes the application protocol level problematic.

134. What is CDATA in XML?
CDATA stands for character data. Characters like ‘<’ and ‘>’ are not allowed in XML. CDATA starts with <! CDATA [“and end with”]>. CDATA is an unparsed character data that cannot be parsed by the XML parser.

135. What is the difference between CDATA and PCDATA?
CDATA means unparsed character data whereas PCDATA means parsed character data.
CDATA: (Unparsed Character data): CDATA contains the text which is not parsed further in an XML document. Tags inside the CDATA text are not treated as markup and entities will not be expanded.
Let’s take an example for CDATA:

<?xml version="1.0"?>
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee>
<![CDATA[
<firstname>vimal</firstname>
<lastname>jaiswal</lastname>
<email>vimal@javatpoint.com</email>
]]>
</employee>

In the above CDATA example, CDATA is used just after the element employee to make the data/text unparsed, so it will give the value of employee:
<firstname>vimal</firstname><lastname>jaiswal</lastname><email>vimal@javatpoint.com</email>

PCDATA: (Parsed Character Data): XML parsers are used to parse all the text in an XML document. PCDATA stands for Parsed Character data. PCDATA is the text that will be parsed by a parser. Tags inside the PCDATA will be treated as markup and entities will be expanded.
In other words you can say that a parsed character data means the XML parser examine the data and ensure that it doesn’t content entity if it contains that will be replaced.
Let’s take an example:

<?xml version="1.0"?>
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee>
<firstname>vimal</firstname>
<lastname>jaiswal</lastname>
<email>vimal@javatpoint.com</email>
</employee>

In the above example, the employee element contains 3 more elements ‘firstname’, ‘lastname’, and ’email’, so it parses further to get the data/text of firstname, lastname and email to give the value of employee as:

vimal jaiswal vimal@javatpoint.com

136. What is Diffgram in XML?
Diffgram is an XML format that is used to find the current and original versions of the XML document.

137. Define Complex Element?
The element, which has attributes and supposedly other different elements, is known as complex elements. A complex element may contain empty elements, only text or both text and element, etc. 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

138. 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

139. What is the difference between simple element and complex element?
In XML, simple elements are text-based elements. It contains less attributes, child elements, and cannot be left empty.
But, complex elements can hold multiple attributes and elements. It can contain additional sub elements and empty element also.

140. What are the ways to use namespaces?
There are two ways to use namespaces:
1. Declare a default namespace
2. Associate a prefix with a namespace, then use the prefix in the XML to refer to the namespace

141. How are white-spaces handled by xml?
Any white-space ( this includes line breaks, tab characters and normal spaces etc.) are passed by the xml parser unchanged to an application. This implies that it is not the responsibility of a parser on how to interpret a white-space, instead it is the responsibility of the application to know what to do with it. The white-spaces in xml can be broadly categorized into two types:
1. Insignificant white-space : Those whites-paces that are found between structural elements and are passed by the parser as they are to the application without any effect ( suppressed) are the insignificant spaces. A good example of such white-spaces are the spaces given in an html document.
2. Significant white-space : Those spaces that occur between the elements and can contain text and markup mixed together and are passed by the parse exactly the way they are to the application for their handling are known as the significant white-spaces.

142. What is XML Schema?
To define a document made of XML, Schema is used. A schema has certain elements in it such as different Elements & attributes, the Specific child elements, and its order, and element data types.

143. What are the different scenarios under which an xml schema may be used?
The xml schema may be used in case the user wants to have the following requirements:
1. The xml schema can be used when the user requires the information to be included in the document is correct and in a consistent format.
2. It can be used when the user has to create a large set of xml documents with all the documents following a common structure.
3. When the document structure is to be shared with other users if an application is built and it follows a particular file structure.
4. Schema in xml are particularly helpful if the xml documents are going to contain a large amount of data. The schema gives the user the flexibility to define the structure according to his requirements.

144. Explain About Message Passing In RPC?
RPC is very friendly in implementing the client to server interaction model which makes it very prominent. When the server is interacting and searching for information the client side messaging is blocked and server activity goes on. RPC has huge pool of protocols which at times make it difficult to work with. Client server interaction can be best achieved by RPC.

145. Explain The Difference Between RPC And Local Calls?
An important difference between Remote call procedure and local call is that remote call can fail often and this occurs without the knowledge of the user. Local calls are easily handled. Another main difficulty lies with the code writing capability because it is written in a low level language.

146. What Are The Elements Which Should Be Contained In SOAP Message?
Following elements are contained in the SOAP message.
1) An envelope element which identifies and translates the XML document into a SOAP message.
2) A header element is a must as it should contain header message.
3) A body is required which should contain call and response message.
4) Fault element is required which can communicate about the errors occurred during the process

147. Explain About The Syntax Rules In SOAP?
Some of the important syntax rules are as follows
1) SOAP should be coded in XML
2) SOAP envelope should be used for SOAP message
3) A SOAP encoding namespace must be used by SOAP.
4) A DTD reference and a XML processing instruction should not be contained.

148. Explain About The Encoding Style Attribute?
This is used to define the data types in the document. Any SOAP element may use this format and it gets implemented on the child and contents of the SOAP. SOAP element will never have a default encoding.

149. Explain About The Soap Envelope Element?
A SOAP message will have the SOAP element as the root element. SOAP element name space should always have the value of : as that defines the Envelope.

150. Explain About The Actor Element?
A SOAP message has to travel a very long distance between its client and server but during the process a part of the message may be intended to be deployed to another destination which is made possible by the SOAP elements actor attribute which address the header element to a particular location.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *


× six = 42

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter