XSl Element
The xsl:element generates the elements in at time of processing.
XML source
A D V E R T I S E M E N T
<?xml version="1.0"?>
<xslTutorial >
<text size="H1">Header1</text>
<text size="H3">Header3</text>
<text size="b">Bold text</text>
<text size="sub">Subscript</text>
<text size="sup">Superscript</text>
</xslTutorial>
HTML output 1
<HTML>
<HEAD> </HEAD>
<BODY>
<H1>Header1</H1>
<H3>Header3</H3>
<b>Bold text</b>
<sub>Subscript</sub>
<sup>Superscript</sup>
</BODY>
</HTML>
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="/">
<xsl:for-each select="//text">
<xsl:element name="{@size}"><xsl:value-of select="."/></xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The XSL Attribute
The xsl:attribute do generates the elements in the time of processing. It creates the
attribute in the element in which it is been enclosed.
XML source
<?xml version="1.0"?>
<xslTutorial >
<color>blue</color>
<color>navy</color>
<color>green</color>
<color>lime</color>
<color>red</color>
HTML output 1
<HTML>
<HEAD> </HEAD>
<BODY>
<TABLE>
<TR>
<TD style="
color:blue">blue</TD></TR></TABLE>
<TABLE>
<TR>
<TD style="
color:navy">navy</TD></TR></TABLE>
<TABLE>
<TR>
<TD style="
color:green">green</TD></TR></TABLE>
<TABLE>
<TR>
<TD style="
color:lime">lime</TD></TR></TABLE>
<TABLE>
<TR>
<TD style="
color:red">red</TD></TR>
</TABLE>
</BODY>
</HTML>
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="color">
<TABLE>
<TR><TD>
<xsl:attribute name="style">
color:<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</TD></TR>
</TABLE>
</xsl:template>
</xsl:stylesheet>
The Copy and Copy-of Constructs
The Copy and copy-of constructs are used for the nodes copying. The Copy element copies
down only the current node without the children and the attributes, while the copy-of
do copies everything.
XML source
<?xml version="1.0"?>
<xslTutorial >
<p id="a12">
Compare <B>these constructs</B>
</p>
</xslTutorial>
HTML output 1
<HTML>
<HEAD> </HEAD>
<BODY>
<DIV>
<B>copy-of : </B>
<p id="a12"> Compare
<B>these constructs</B>. </p></DIV>
<DIV>
<B>copy : </B>
<p/></DIV>
<DIV>
<B>value-of : </B> Compare these constructs.
</DIV>
</BODY>
</HTML>
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="p">
<DIV><B><xsl:text> copy-of : </xsl:text> </B> ;
<xsl:copy-of select="."/>
</DIV>
<DIV><B><xsl:text> copy : </xsl:text> </B>
<xsl:copy/ >
</DIV>
<DIV><B><xsl:text> value-of : </xsl:text> </B>
<xsl:value-of select="."/>
</DIV>
</xsl:template>
</xsl:stylesheet>
Be the first one to comment on this page.
Share And Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords XSL Elements, xsl element, xslt element, the stylesheet does not contain a document element,
xsd element, stylesheet does not contain a document element, cdata section elements,
xpath element, xsd elements, cdata element, xslt elements, xsl element name, xsd optional element,
xsl for each, stylesheet element, xsl value of, asp net xsl, xsl select element, xml elements,
element in xslt