Professional XSLT Interview Questions & Answers:
XSLT shares the same data model of XPATH with some additions. XSLT accepts a XSLT stylesheet as an input and output is another XML, text or another document. The model is based on text nodes. These text nodes are embedded within element nodes. The model is a hierarchical structure like a tree. The tree has a variety of nodes like- text nodes, attribute nodes, element nodes, comment nodes, and processing instruction nodes. For every node type there is a way of determining a string-value for a node of that type.
XPATH is used to scan the XML document for navigation of elements and attributes. It contains a library of standard functions string ad numeric values. For navigation, XPATH makes use of path expressions to select nodes or sets of nodes in a XML document.
XSL stylesheet is just like a XML document used as a program text or a source. It contains sets of rules and instructions used for transformations. XSLT stylesheet along with the XML source documents are the inputs to the XSLT processor. The template rule contains two parts: a pattern used to match the nodes in the source document and a template which can be instantiated to form part of the result tree. A stylesheet is represented by an xsl:stylesheet element in an XML document.
4. Explain its relationships of XSLT with XSL?
XSLT stands for eXtensible Stylesheet Language Transformations. It is a language used to convert XML documents to XHTML or other XML documents. This conversion is done by transforming each XML element into an (X)HTML element.. it uses XPath to find information in a XML document. XSLT is nothing but transforming XSL's. Xpath defines the parts of the source document that must match one or more predefined templates. Once a match is found, XSLT will transform the match into the result document.
5. Do you know what are the roles of XSLT?
The roles of XSLT are:
XSLT is used to transform an XML document into another XML document such as HTML, etc.
XSLT can be used to add or remove elements and attributes to or from the output file.
XSLT can also be used for rearranging and sorting elements.
It can also be used for performing tests and making decisions about hiding and displaying of elements
XSLT stands for XSL Transformations and is a language used to transform XML documents into XHTML documents or to other XML documents.
7. Do you know how to transform an XML file into HTML using XSL transformation (XSLT)?
That's all on my list of XSLT and XML transformation interview questions and answers. XSLT is one of the important skill to have in your resume, if you are using XML in your project. Since XML is mostly used as transportation protocol and middle and back office systems, those roles look for candidates which are good in XML, XSL and XSLT transformation. So if you are applying for any middle and back office Java development role in Investment banks, make sure to prepare XSLT well.
8. How to generate dynamic HTML pages from relational database using XSLT?
This is one of the XSLT interview questions which checks practical knowledge of candidate in XSL. This is one of the most common application of XSLT I have seen where data stored in relational database is converted into XML and by using XSLT transformed into HTML pages. Database stored procedure can be used for first part and having all the logic of rendering HTML in XSLT you don't need to change your query now and then if you need to change structure of HTML pages. If candidate successfully answer this XSLT interview question then there is very good chance that he has a good understanding of how things works with database, xml and XSLT.
Now let's see couple of XSLT Interview question for practice, you need to find answer of these two questions by yourself, and once you find the answer, you can also post them as comment here. The reason, I am not giving answer of these question here because, they are extremely basic and should come as experience, i.e. you would better write code for that. That will enable you to understand other XSLT questions as well.
9. Explain how to retrieve value of an attribute for an element using XSLT?
This XSLT interview question is pretty common in many XML interviews as well. If candidate has worked in XSLT then this is a fairly easy question as it just need to come up with a XSLT template which can copy an attribute from an element like below:
<xsl:template match="/employees/employee">
Value of attribute Id is :
<xsl:value-of select="@id"></xsl:value-of>
</xsl:template>
10. What is XSL template? What output this XSL template will produce given a particular xml file?
This kind of XSL transformation questions are more popular to gauge real understanding of templates. they can write template in front of you and may ask you to explain, most simple example of this is writing Identity template as discussed in XSLT interview question
Alternatively they may give you XSL and XML file and ask you about about of transformation. This are tricky questions in XSL and in order to answer these question you need to be familiar with XSL language, which is the primary reason people ask it. On the other hand this is an excellent opportunity to show you how well you know about XSL working or how template executes, by clearly explaining what a particular template does.
https://InterviewQuestionsAnswers.ORG.