Sáng nay học XML, phần XSLT:
Làm xong phần BT nên share cho anh em nào cần:
Cơ bản là thế này thoy:
DTD:
Mã:
<!ELEMENT BD (SV)*>
<!ELEMENT SV (STT, HOTEN, NSINH, DIEMTP,DTB, GHICHU)>
<!ELEMENT STT (#PCDATA)>
<!ELEMENT HOTEN (#PCDATA)>
<!ELEMENT NSINH (#PCDATA)>
<!ELEMENT DIEMTP (DQT, THI, L2, TK, TK2)>
<!ELEMENT DTB (#PCDATA)>
<!ELEMENT GHICHU (#PCDATA)>
<!ELEMENT DQT (#PCDATA)>
<!ELEMENT THI (#PCDATA)>
<!ELEMENT L2 (#PCDATA)>
<!ELEMENT TK (#PCDATA)>
<!ELEMENT TK2 (#PCDATA)>
<!ATTLIST BD Lop CDATA #REQUIRED
SoTC CDATA #REQUIRED
HocKy CDATA #IMPLIED
Lan CDATA #IMPLIED
NamHoc CDATA #FIXED "2009 -2010">
<!ATTLIST SV MaSV ID #REQUIRED
GioiTinh (Nam|Nu) "Nam">
<!ENTITY GC "Da Dong HP">
Tài liệu XML:
Mã:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="XSLT.xsl"?>
<!DOCTYPE BD SYSTEM "BangDiem_DTD.dtd">
<BD HocKy="I" Lan="2" NamHoc="2009 -2010" Lop="HT01A" SoTC="3">
<SV GioiTinh="Nam" MaSV="CCHT010001">
<STT>1</STT>
<HOTEN>Ly Vinh</HOTEN>
<NSINH>10/02/1991</NSINH>
<DIEMTP>
<DQT>9</DQT>
<THI>9</THI>
<L2>9</L2>
<TK>9</TK>
<TK2>9</TK2>
</DIEMTP>
<DTB>4.0</DTB>
<GHICHU>&GC;</GHICHU>
</SV>
</BD>
XSLT:
Mã:
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:template match="/">
<html>
<head>
<title>Bang diem</title>
</head>
<body>
<H1>BANG TONG KET DIEM</H1>
<H2>LOP: <xsl:value-of select="BD/@Lop"/></H2>
<table width="512" border="1">
<tr>
<td width="78"><div align="center">TT</div></td>
<td width="97"><div align="center">MSV</div></td>
<td width="78"><div align="center">HOTEN</div></td>
<td width="97"><div align="center">NGAYSINH</div></td>
<td width="107"><div align="center">
<table width="200" border="1">
<tr>
<td colspan="5"><div align="center">DIEMTP</div></td>
</tr>
<tr>
<td><div align="center">DQT</div></td>
<td><div align="center">THI</div></td>
<td><div align="center">L2</div></td>
<td><div align="center">TK</div></td>
<td><div align="center">TK2</div></td>
</tr>
</table>
</div></td>
<td width="29"><div align="center">DTB</div></td>
<td width="76"><div align="center">GHICHU</div></td>
</tr>
<tr>
<td width="78"><div align="center"><xsl:value-of select="BD/SV/STT"/></div></td>
<td width="97"><div align="center"><xsl:value-of select="BD/SV/@MaSV"/></div></td>
<td width="78"><div align="center"><xsl:value-of select="BD/SV/HOTEN"/></div></td>
<td width="97"><div align="center"><xsl:value-of select="BD/SV/NSINH"/></div></td>
<td width="107"><div align="center">
<table width="200" border="1">
<tr>
<td><div align="center"><xsl:value-of select="BD/SV/DIEMTP/DQT"/></div></td>
<td><div align="center"><xsl:value-of select="BD/SV/DIEMTP/THI"/></div></td>
<td><div align="center"><xsl:value-of select="BD/SV/DIEMTP/L2"/></div></td>
<td><div align="center"><xsl:value-of select="BD/SV/DIEMTP/TK"/></div></td>
<td><div align="center"><xsl:value-of select="BD/SV/DIEMTP/TK2"/></div></td>
</tr>
</table>
</div></td>
<td width="29"><div align="center"><xsl:value-of select="BD/SV/DTB"/></div></td>
<td width="76"><div align="center"><xsl:value-of select="BD/SV/GHICHU"/></div></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Hoặc:
Download: BT_XML_2mit.org