Laboratory_3

This commit is contained in:
nikbel2004@outlook.com 2024-09-15 23:47:08 +04:00
parent 7849dd4531
commit 851d8c0c6d
4 changed files with 71 additions and 5 deletions

View File

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="library.xslt"?> <?xml-stylesheet type="text/xsl" href="library.xslt"?>
<?xml-model href="library.dtd" type="applecation/xml-dtd"?> <?xml-model href="library.dtd" type="applecation/xml-dtd"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="library.xsd">
<library> <book ISBN="978-3-16-148410-0" author="Leo Tolstoy" publisher="Penguin" language="English" available="yes">
<book ISBN="978-3-16-148410-0" available="yes" publisher="Penguin" language="English">
<title>War and Peace</title> <title>War and Peace</title>
<author>Leo Tolstoy</author> <author>Leo Tolstoy</author>
<genre>Historical</genre> <genre>Historical</genre>
<year>1869</year> <year>1869</year>
</book> </book>
<book ISBN="978-5-17-085410-0" available="no" language="Russian"> <book ISBN="978-5-17-085410-0" author="Alexander Pushkin" publisher="AST" language="Russian">
<title>The Captain's Daughter</title> <title>The Captain's Daughter</title>
<author>Alexander Pushkin</author> <author>Alexander Pushkin</author>
<genre>Novel</genre> <genre>Novel</genre>
@ -21,5 +20,4 @@
<genre>Historical novel</genre> <genre>Historical novel</genre>
<year>1844</year> <year>1844</year>
</book> </book>
<!-- Остальные книги... -->
</library> </library>

68
Lab 3/library.xsd Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Определение элемента "library", который содержит один или более элементов "book" -->
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="author">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="genre">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Fiction"/>
<xs:enumeration value="Non-Fiction"/>
<xs:enumeration value="Fantasy"/>
<xs:enumeration value="Mystery"/>
<xs:enumeration value="History"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Описание для year -->
<xs:element name="year" type="xs:gYear"/>
<xs:element name="era">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="BC"/> <!-- До нашей эры -->
<xs:enumeration value="AD"/> <!-- Наша эра -->
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="ISBN">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(\d{10}|\d{13})"/> <!-- Шаблон для ISBN-10 или ISBN-13 -->
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="available" type="xs:boolean" use="required" />
<xs:attribute name="publisher" type="xs:string" use="optional" />
<xs:attribute name="language" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>