Web Services, Remoting Interview Questions and Answers (102) - Page 5

The XSLT processor copies the elements of the stylesheet until it finds a command in which format?

The XSLT processor copies the elements of the stylesheet until it finds a command in {item, action} format.
Explain about XQuery ?

Xquery is a query language which is designed to query XML data.
It is also used in making changes to query.
Its subset is Xpath.
This XQuery is formed from the experts of w3c. This facilitates extraction of data from many different databases. This can be rightly said that in future it will be used as SQL.
How to define functions in XQuery ?

XML has many build-in functions. XQuery functions generally made perform with string values, numeric values, date and time comparisons, boolean values etc.
XQuery give us the facility to made our own functions.
Here are some of the ways, how to call XQuery functions:

Ex 1: When you use function in an element.
<name>{uppercase($booktitle)}</name>

Ex 2: When you use function in the predicate of a path expression.
doc("bookmart.xml")/bookstore/book[substring(title,1,5)='Jungle']

Ex 3: When you use function in a let clause
let $name := (substring($booktitle,1,4))

What do you mean by selecting and Filtering elements in XQuery ?

We can select and filter the xml elements with FLWOR and Path expression.

Below is an example for FLWOR expression:

for $a in doc("bookmart.xml")/bookstore/book
where $a/price<150
order by $a/title
return $a/title
Where,
1. for : It is an optional and use to bind a variable to each item.
for $a in (1 to 5)
return <test>{$a}</test>

How you define atomic values ?

Atomic Values can be defined as follows.

Consider the example as given below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<title lang="en">Jungle Book</title>
<author>Rudyard Kipling</author>
<year>1894</year>
<price>99.89</price>
</book>
</bookstore>

How to perform conditional operations in XQuery ?

Here is a way to perform conditional operations in XQuery.

Example:


for $a in doc("bookmart.xml")/bookstore/book
return if ($a/@category="ADVENTURE")
then <child>{data($a/title)}</child>
else <adult>{data($a/title)}</adult>

Output:

<adult>Jungle Book</adult>
<child>The Book of the Thousand Nights and a Night </child>
<adult>XML Programing</adult>
<adult>XPath and XPointer</adult>

Which type of problems can be solved with XQuery ?

We use XQuery to solve some of the queries in an XML data as follows :

1. Use XQuery to retrieve information in a web service.
2. Use XQuery to generate summary report.
3. Using XQuery we can transform data from XML to XHTML.
4. Use XQuery when we want some relevant information from Web documents.
Explain about core validation ?

During the process of XML validation two processes are followed.
They are:

1) Reference validation and
2) Signature validation

Record digest value is used to verify digital signature.
Canonicalization is a process which is used in signature validation.
In this process, the key info is used to verify the signature.
Explain about XML Canonicalization ?

Documents are identical in many different ways either logical of statistical.
It becomes a major problem when you try to sign a digital signature on two identical documents.
To eliminate this problem you have to use Canonicalization which helps people in identifying two similar documents with similar digital signature.
Similar documents use Canonicalization to identify similar patterns and signature.
How to perform operation on node using XQuery function in XML?Explain with an example ?

To explain given problem, first we will see an example in XML.

Example:


Save the given XML file with "bookmart.xml"

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="CHILDREN">
<title lang="en">Jungle Book</title>
<author>Rudyard Kipling</author>
<year>1894</year>
<price>99.89</price>
</book>
<book category="ADVENTURE">
<title lang="en">The Book of the Thousand Nights and a Night </title>
<author>Sir Richard Francis Burton</author>
<year>1885-88</year>
<price>149.99</price>
</book>
<book category="WEB PROGRAMING">
<title lang="en">XPath and XPointer</title>
<author>John E. Simpson</author>
<year>2002</year>
<price>299.99</price>
</book>
<book category="WEB PROGRAMING">
<title lang="en">XML Programing</title>
<author>R.Allen Wype</author>
<author>Sultan Rehman</author>
<author>Brad Leupen</author>
<year>2002</year>
<price>229.95</price>
</book>
</bookstore>


Now, here is a way to perform operations on node with XQuery.

1. XQuery uses doc() function to retrieve data from XML document.
If you want to select all title elements of "bookmart.xml" , then you should write as follows:

doc("bookmart.xml")/bookstore/book/title


When this XQuery run than it will get like that,


<title lang="en">Jungle Book</title>
<title lang="en">The Book of the Thousand Nights and a Night</title>
<title lang="en">XPath and XPointer</title>
<title lang="en">XML Programing</title>


2. Using XQuery we can predicate the limit of an exiracted data from XML documents.
Now, We write a predicate for XQuery in which we got all book elements whose price has less than 150.

doc("books.xml")/bookstore/book[price<150]


Result will be as follows:


<book category="CHILDREN">
<title lang="en">Jungle Book</title>
<author>Rudyard Kipling</author>
<year>1894</year>
<price>99.89</price>
</book>
<book category="ADVENTURE">
<title lang="en">The Book of the Thousand Nights and a Night </title>
<author>Sir Richard Francis Burton</author>
<year>1885-88</year>
<price>149.99</price>
</book>

How to perform comparisons in XQuery ?

In XQuery we can compare the values with general comparisons and value comparisons.

1. General Comparisons : We perform general comparisons by using these symbols.
Ex. =, !=, <, <=, >, >=

2. Value Comparisons : We use below symbols to perform value comparisons.
Ex. ne, lt, le, eq, ge, gt.

Now, here is the way to use comparisons in XQuery.

$bookstore//book/@q > 100


If any q attributes have values which is greater than 100 expression will return true.
What is a UID and how do I get one ?

The Unique Identifier (UID) is a unique identification for the binary (EXE or DLL) within the system.
Its purpose is to prevent executables from interfering with each other. For S60 3rd Edition applications UIDs have to be reapplied.
What are the syntax rules of XQuery?

Here are some basic syntax rules of XQuery.

1. XQuery is an case sensitive.
2. In XQuery elements , attributes and variables that we use should have valid XML names.
3. Should write XQuery with in single and double quotes.
4. We defined XQuery variable with like: $(variable name).
Ex: $book.
5. We can write XQuery comments between colon(:).
Ex: (:Comment in XQuery:)
Is DOM parsing supported by Silverlight ? What is LINQ to XML ?

Dom Parsing of XML documents is not supported by Silverlight.
But it supports DOM parsing using LINQ to XML.
A LINQ to XML API has been introduced with .NET 3.5 with which silverlight works with XML documents using LINQ to XML.
How many parents can an XML child element support ?

Only one parent is supported by an XML child element.
It is also to be noted that, the root element does not support any parent element.
For Example:

<Students>

<Name>Andy</Name>
<Id>3001</Id>
<Class>5</Class>
</Students>

Explain about an empty XML element..

If an XML element do not have a value inside it, then it is calles as an empty XML element.
It may have an attribute which consists of a value but the element itself is empty.

For Example:

<Student></Student>

In the above examle, as there is nothing between the closing and ending tags, it is said to be an empty element.

<Student age="10" name="Andy"></Student>

The above example also shows an empty element because, it has the attributes but there is no value within the element tags.
Discuss the advantages of using XmlReader and XmlWriter ?

Both are used for the same purpose. These objects are used for read and write requirements of large XML documents.
They parses the XML document from top to bottom, i.e., the whole XML document need not to be processed in the memory, and that saves on processing requirements.
They process each XML element one at a time.
What is an Extension of a Web-Service?

NOTE: This is objective type question, Please click question title for correct answer.
What happend when we have a method inside a Web service but having no WebMethod attribute defined?

If a method which is defined inside a Web-service but have not been marked as WebMethod attribute,then we can not access that method outside the application.

Actually,when we are wrting any function inside webservice,then we have to Mark Explicitly that method as WebMethod attribute,then only we can expose that method
or access that method from outside when referring Webservice in our application.

Attaching the WebMethod attribute to a Public method indicates that we want the method exposed as part of the XML Web service.
Which statement(s) is/are correct about Web Services?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories