XSLT (XSL Transformations) Question:
Explain how to retrieve value of an attribute for an element using XSLT?
Answer:
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>
<xsl:template match="/employees/employee">
Value of attribute Id is :
<xsl:value-of select="@id"></xsl:value-of>
</xsl:template>
Previous Question | Next Question |
What is XSL template? What output this XSL template will produce given a particular xml file? | How to generate dynamic HTML pages from relational database using XSLT? |