MiAKD/Lab 3/library.xslt
nikbel2004@outlook.com 86094e3d5a AllLabs
2024-09-15 23:54:00 +04:00

48 lines
1.7 KiB
HTML

<?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>
<head>
<title>Library</title>
<style>
table {
width: 70%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 10px;
text-align: left;
}
th {
background-color: #9acd32;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Library Books</h2>
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Genre</th>
<th>Year</th>
</tr>
<!-- Цикл по элементам book -->
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="genre"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>