Explain how to rename a particular element and attribute from XML using XSL?
Submitted by: MuhammadRenaming attribute is also similar to removing or deleting attribute as discussed in XSLT question 1, but instead of not doing anything when an attribute matches, you need to create an attribute and copy value of current attribute into new attribute. Identity template will be same and you need to add another template for renaming attribute using XSL:
<xsl:template match="@id">
<xsl:attribute name="emp_id">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
if you are using XSLT 2.0 than instead of separate <xsL:value-of> element you can use select attribute directly with <xsL:attribute> as shown below
<xsl:attribute name="emp_id" select=".">
Submitted by: Muhammad
<xsl:template match="@id">
<xsl:attribute name="emp_id">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
if you are using XSLT 2.0 than instead of separate <xsL:value-of> element you can use select attribute directly with <xsL:attribute> as shown below
<xsl:attribute name="emp_id" select=".">
Submitted by: Muhammad
Read Online XSLT Job Interview Questions And Answers
Top XSLT Questions
☺ | What is the XSLT? |
☺ | Can you use the XSLT to convert html into VXML? |
☺ | How we compare XSLT and XPath? |
☺ | How to use filtering function in XSLT? |
☺ | What does XSLT processing models involve? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |