Professional Documents
Culture Documents
Elements in XSL
Elements in XSL
ELEMENT xsl:apply-templates xsl:attribute xsl:choose xsl:comment xsl:copy xsl:copy-of xsl:element xsl:for-each xsl:if xsl:import xsl:include xsl:otherwise xsl:sort xsl:stylesheet xsl:template xsl:text xsl:transform xsl:value-of xsl:variable xsl:when
FUNCTION
Applies a template rule to the current element or to the current element's child nodes
Adds an attribute
Used in conjunction with <when> and <otherwise>to express multiple conditional tests
Includes the contents of one style sheet into another.An included style sheet has the same precedence as the including style sheet
Defines the root element of a style sheet Rules to apply when a specified node is matched
Writes literal text to the output
Defines the root element of a style sheet Extracts the value of a selected node
Declares a local or global variable
3
contoh1_4.xsl <?xml version = "1.0"?> <xsl:stylesheet xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" version= "1.0"> <xsl:template match="book"> <b> <xsl:value-of select="."/> </b> </xsl:template> <xsl:template match="title"> <i> <xsl:value-of select="."/> </i> </xsl:template> </xsl:stylesheet> contoh1_5.xsl <?xml version = 1.0?> <xsl:stylesheet xmlns:xsl= http://www.w3.org/1999/XSL/Transform version= 1.0> <xsl:template match=book> <b><xsl:apply-templates select=series/></b> <b><xsl:apply-templates select=title/></b> </xsl:template> <xsl:template match=title> <i><xsl:value-of select=./></i> </xsl:template> </xsl:stylesheet> <html> <body> <b>Utama <i>12 tugas Utama</i></b> </body> </html>
6 Sorting
<?xml version =1.0 ?> <?xml-stylesheet type=text/xsl href=contoh4_1.xsl?> <record> <book isbn=a23532324> <title series=Utama ke =1>12 Tugasan Utama</title> <title series =Utama ke=7>Sabit Emas</title> <title series =Utama ke=15>Pertaruhan </title> <title series=Utama ke=102>Amerika</title> </book> </record> contoh4_1.xsl <?xml version = 1.0?> <xsl:stylesheet xmlns:xsl= http://www.w3.org/1999/XSL/Transform version= 1.0> <xsl:template match=/> <xsl:for-each select=//title> <xsl:sort order=ascending data-type=text select=@ke/> <xsl:text>Series ke</xsl:text> <xsl:value-of select=@ke/> <xsl:text>:</xsl:text> <b><xsl:value-of select=./></b><br/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Contoh4_2.xsl <?xml version = 1.0?> <xsl:stylesheet xmlns:xsl= http://www.w3.org/1999/XSL/Transform version= 1.0> <xsl:template match=/> <xsl:for-each select=//title> <xsl:sort order=ascending data-type=number select=@ke/> <xsl:text>Series ke</xsl:text> <xsl:value-of select=@ke/> <xsl:text>:</xsl:text> <b><xsl:value-of select=./></b><br/> </xsl:for-each> </xsl:template> </xsl:stylesheet>