What is xsl:attribute element in XML
Posted in
XML | XSLT July 05, 2019
In this article i am going to explain xsl:attribute element in XML.
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">
<!--TEMPLATE---->
</xsl:attribute>
|
It have contain two attributes
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.
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" ?>
<root>
<myElement>My First Example</myElement>
<myElement>My Second Example</myElement>
</root>
|
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:copy>
<xsl:attribute name="copied">true</xsl:attribute>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
Output
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