What is xsl:attribute element in XML

In this article i am going to explain xsl:attribute element in XML.
  • 2182
The <xsl:attribute> element is used to creates an attribute node and attaches in the output documents.The attribute tag is used for any value that can be accessed from the stylesheet.The <xsl:attribute> element is support to IE 5.0 and FF 1.0.

Syntax of xsl:attribute element

<xsl:attribute name="SOME NAME" namespace="URI" namespace="URI-REFRENCES">



It have contain two attributes

  • name

           The name attribute is a qualified name that is used to create the name of attribute.The name is one of a very few attributes in XSLT that can be set to an expression that is    computed at run-time.

  • namespace

            It is an optional attribute,define the namespace URI for this attribute in the output document.It is also computed at run-time.

Example of copies my element

XML File(myfirst.xml)

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="abc.xsl" ?>


  <myElement>My First Example</myElement>

  <myElement>My Second Example</myElement>


XSLT File(abc.xsl)

<?xml version="1.0"?> 

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.google.com/XSL/Transform" >

  <xsl:template match="myElement">


      <xsl:attribute name="copied">true</xsl:attribute>

      <xsl:apply-templates />





My First Example My Second Example

Further Readings

You may also want to read these related articles :

Ask Your Question

Ask Your Question Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.