By GokiSoft.com|
19:39 27/03/2024|
XML
[Share Code] Tìm hiểu về XSL & XPATH - C2307L
#readme.txt
XML:
- Viết tài liệu XML
- Hiểu về namespace
- DTD (Mô tả cấu trúc XML & kiểu dữ liệu (PCDATA))
-> XML Scheme -> Mở rộng của DTD
- Parser
XSLT
XSL
XPath
XSL-FO
Chuyển XML -> Sang tài liệu HTML
#students.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Student Pages</h2>
<table border="1" cellpadding="3" cellspacing="3">
<thead>
<tr>
<th>Full Name</th>
<th>Address</th>
<th>Email</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="StudentList/Student">
<tr>
<td><xsl:value-of select="Fullname"/></td>
<td><xsl:value-of select="Address"/></td>
<td><xsl:value-of select="Email"/></td>
<td><xsl:value-of select="Gender"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
#students.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='students.xsl'?>
<StudentList>
<Student>
<Fullname>TRAN VAN A</Fullname>
<Address>Ha Noi</Address>
<Email>tranvana@gmail.com</Email>
<Gender>Male</Gender>
</Student>
<Student>
<Fullname><![CDATA[TRAN VAN B <> sdjh &^*76sd]]></Fullname>
<Address>Ha Noi</Address>
<Email>tranvanb@gmail.com</Email>
<Gender>Male</Gender>
</Student>
<Student>
<Fullname>TRAN VAN C</Fullname>
<Address>Ha Noi</Address>
<Email>tranvanc@gmail.com</Email>
<Gender>Male</Gender>
</Student>
</StudentList>
#students.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Student Pages</title>
</head>
<body>
<table border="1" cellpadding="3" cellspacing="3">
<thead>
<tr>
<th>Full Name</th>
<th>Address</th>
<th>Email</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<tr>
<td>TRAN VAN A</td>
<td>Ha Noi</td>
<td>tranvana@gmail.com</td>
<td>Male</td>
</tr>
<tr>
<td>TRAN VAN A</td>
<td>Ha Noi</td>
<td>tranvana@gmail.com</td>
<td>Male</td>
</tr>
<tr>
<td>TRAN VAN A</td>
<td>Ha Noi</td>
<td>tranvana@gmail.com</td>
<td>Male</td>
</tr>
</tbody>
</table>
</body>
</html>
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)