Creating the Result Tree |
Literal Result Elements |
Any element in a template rule that is not in the XSL (or other extension) namespace is copied literally to the result tree |
<xsl:text> |
The content of <xsl:text> elements is copied directly to the result tree; whitespace is preserved by default
<xsl:text>Literal result text</xsl:text> |
<xsl:value-of> |
Inserts the value of an expression into the result tree, converting it to a string first if necessary
<xsl:value-of select=”$count + 1″/> |
<xsl:copy> and <xsl:copy-of> |
Copies the current node or, in the case of xsl:copy-of, the selected nodes, into the result tree without first converting them to a string
<xsl:copy-of select=”title”/> |
<xsl:element> |
Instantiates the named element |
… <xsl:param name=”header”>h3</xsl:param> … <xsl:element name=”{$header}”> <xsl:apply-templates/> </xsl:element> |
<xsl:attribute> |
Adds the named attribute to the nearest containing element |
<table> <xsl:if test=”@pgwide=’1′”> <xsl:attribute name=”width”>100%</xsl:attribute> </xsl:if> … </table> |
Source code of xsl_result_tree.xsl: |
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet[ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="iso-8859-1" /> <xsl:variable name="tbl"> <tr> <td><b>Name</b></td> <td><b>Address</b></td> <td><b>Designation</b></td> </tr> </xsl:variable> <xsl:attribute-set name="tblAttrib"> <xsl:attribute name="border"> 2 </xsl:attribute> <xsl:attribute name="cellspacing"> 3 </xsl:attribute> <xsl:attribute name="bordercolor"> "#3344dd" </xsl:attribute> </xsl:attribute-set> <xsl:template match="/"> <ebizml> <head> <title>XSLT xsl:element Example</title> </head> <body> <span style="width 600px;border: 2px outset blue solidl;display:block"> </span><br /> <table xsl:use-attribute-sets="tblAttrib"> <xsl:copy-of select="$tbl" /> <xsl:for-each select="ebiz/employee_details"> <tr> <td><xsl:element name="emp_name"> <xsl:value-of select="fname" /> <xsl:value-of select="lname" /> </xsl:element></td> <td><xsl:value-of select="address" /></td> <td><xsl:value-of select="designation" /></td> </tr> </xsl:for-each> </table> <br /> </body> </ebizml> </xsl:template> </xsl:stylesheet> |