Compare commits
2 Commits
main
...
Laboratory
Author | SHA1 | Date | |
---|---|---|---|
|
7849dd4531 | ||
|
a0a3fd0be4 |
15
Lab 2/library.dtd
Normal file
15
Lab 2/library.dtd
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE library [
|
||||
|
||||
<!ELEMENT library (book+)>
|
||||
<!ELEMENT book (title, author, genre, year)>
|
||||
<!ELEMENT title (#PCDATA)>
|
||||
<!ELEMENT author (#PCDATA)>
|
||||
<!ELEMENT genre (#PCDATA)>
|
||||
<!ELEMENT year (#PCDATA)>
|
||||
|
||||
<!ATTLIST book ISBN CDATA #REQUIRED>
|
||||
<!ATTLIST book available CDATA #REQUIRED>
|
||||
<!ATTLIST book publisher CDATA #IMPLIED>
|
||||
<!ATTLIST book language CDATA #IMPLIED>
|
||||
|
||||
]>
|
25
Lab 2/library.xml
Normal file
25
Lab 2/library.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type="text/xsl" href="library.xslt"?>
|
||||
<?xml-model href="library.dtd" type="applecation/xml-dtd"?>
|
||||
|
||||
<library>
|
||||
<book ISBN="978-3-16-148410-0" available="yes" publisher="Penguin" language="English">
|
||||
<title>War and Peace</title>
|
||||
<author>Leo Tolstoy</author>
|
||||
<genre>Historical</genre>
|
||||
<year>1869</year>
|
||||
</book>
|
||||
<book ISBN="978-5-17-085410-0" available="no" language="Russian">
|
||||
<title>The Captain's Daughter</title>
|
||||
<author>Alexander Pushkin</author>
|
||||
<genre>Novel</genre>
|
||||
<year>1836</year>
|
||||
</book>
|
||||
<book ISBN="978-5-11-022410-0" available="yes" language="French">
|
||||
<title>The Three Musketeers</title>
|
||||
<author>Alexandre Dumas</author>
|
||||
<genre>Historical novel</genre>
|
||||
<year>1844</year>
|
||||
</book>
|
||||
<!-- Остальные книги... -->
|
||||
</library>
|
48
Lab 2/library.xslt
Normal file
48
Lab 2/library.xslt
Normal file
@ -0,0 +1,48 @@
|
||||
<?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>
|
Loading…
Reference in New Issue
Block a user