XSLT <xsl:template> Element
- Previous Page XSLT Transformation
- Next Page XSLT <value-of>
XSL ສະແນອມເບວຈະຕັ້ງຢູ່ກັບກົດລະບຽບທີ່ເອີ້ນວ່າ ຕົວແທນ (template).
ແຕ່ລະຕົວແທນມີກົດລະບຽບທີ່ຈະນຳໃຊ້ເວລາທີ່ຫົວໜ້າຂອງຫົວຫຼັງສະແດງຕົວ.
xsl:template ປະສົມປະກອບ
xsl:template ປະສົມປະກອບຂອງການສ້າງຕົວແທນ.
match ຜົນງານຂອງປະສົມປະກອບທີ່ກ່ຽວກັບ XML ແລະຕົວຈຳກັດ. match ປະສົມປະກອບກໍ່ຈະນຳໃຊ້ເພື່ອການສະແນອມຕົວແທນສະບັບສະໜາມຂອງໂຕແບບ. ຄູ່ມູນຂອງ match ແມ່ນ XPath ການສະແດງ (ຕົວຢ່າງ, match="/" ການສະແນອມໂດຍທົ່ວໂຕແບບ).
ດັ່ງນັ້ນພວກເຮົາຈະເບິ່ງເບີ່ງສະບັບສັນຍາສັນຍານ XSL ທີ່ຫຼຸດລົງຂອງກ່ອນໜ້ານີ້:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td>.</td> <td>.</td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
ການອະທິບາຍວິທະຍານ:
ຍ້ອນ XSL ສະແນອມເບວຈະເປັນເອກະສານ XML ດຽວນີ້ ມັນຈະຕ້ອງໄດ້ໂດຍການປະກາດ XML ໃນຕອນຕົ້ນ:
<?xml version="1.0" encoding="ISO-8859-1"?>
The next element,<xsl:stylesheet>defines this document as an XSLT stylesheet document (including version number and XSLT namespace attributes).
<xsl:template> Element defines a template. And match="/" Attributes link this template to the root of the XML source document.
The content inside the <xsl:template> element defines the HTML code written to the output result.
The last two lines define the end of the template and the end of the stylesheet.
The result of the above transformation is similar to this:

View XML File,View XSL File,View Result
The result of this example has a little defect because the data has not been copied from the XML document to the output.
In the next section, you will learn how to use <xsl:value-of> Elements pick values from XML elements.
- Previous Page XSLT Transformation
- Next Page XSLT <value-of>