Home
XML
Interview FAQs

FAQs of level

Removing element from XML document via XSL transformation or XSLT is easy if you are familiar with Identity template. You need to write two templates one is Identity template, which copies everything and another for matching with particular element and doing nothing just like shown below, which will then result in removal of a that particular element. See an example of removing XML elements using XSLT for details.
<xsl:template match="/root/product"/>

Process of removing an attribute is similar to removing elements from XML document, as discussed in above XSLT interview question. Along with Identity template, define another template to match with that particular attribute as shown below.

<xsl:template match="@product_synonym"/>

Renaming 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=".">

Identity template in XSL is used to create deep copy of source XML file. It is template matches to every node() and attribute and copy everything to create copy of original xml file. many people define Identity template in its own file like Identity.xsl but some people also preferred to keep in main XSL file as top template. Identity template has several uses in XSL transformation, like if you want to remove any attribute or element you will most likely copy everything using Identity template and create another template for not doing anything for those attribute or elements-
<xsl:template match="@|node()">
   <xsl:copy>
       <xsl:apply-templates select="@|node()"/>
   </xsl:copy>
</xsl:template>

Above template is called Identity template. If you look at definition first template matches any attribute or any node and then copies current node including any attributes and child nodes.

This is an extension or follow up questions of previous XSLT question about Identity template. we use select="@|node() to copy all child element and any attribute.if we do not use that than <xsl:apply-templates/> will default on select="node()" which will copy child nodes except attributes.

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>

XmlReader and XmlWriter are abstract base classes, which define the functionality that all derived classes must support.
There are three concrete implementations of XmlReader:

  1. XmlTextReader
  2. XmlNodeReader
  3. XmlValidatingReader
There are two concrete implementations of XmlWriter:
  1. XmlTextWriter
  2. XmlNodeWriter
XmlTextReader and XmlTextWriter support reading data to/from text-based stream, while XmlNodeReader and XmlNodeWriter are designed for working with in-memory DOM tree structure. The custom readers and writers can also be developed to extend the built-in functionality of XmlReader and XmlWriter.

The System.XML namespace provides XML related processing ability in .Net framework. XmlReader and XMLWriter are the two abstract classes at the core of .Net Framework XML classes: 

  • XmlReader provides a fast, forward-only, read-only cursor for processing an XML document stream.
  • XmlWriter provides an interface for producing XML document streams that conform to the W3Cs XML standards.
Both XmlReader and XmlWriter are abstract base classes, which define the functionality that all derived classes must support.

Yes, you can encode mathematics via using MathML. 
We use a CSS or XSLT stylesheet for formatting and appearance. 
PreviousDisplaying 6 of 7Next
1 2 3 4 5 6 7
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*