This commit is contained in:
Никита Потапов 2024-10-01 11:23:59 +04:00
commit cf165fdf4e
5 changed files with 206 additions and 0 deletions

9
README.md Normal file
View File

@ -0,0 +1,9 @@
Чтобы запустить проект, нужно открыть консоль и запустить Python сервер
```bash
python -m http.server
```
Чтобы проверить валидность документа, открыть WSL и запустить
```bash
xmllint --schema it_companies.xsd it_companies.xml --noout
```

23
dtd.xml Normal file
View File

@ -0,0 +1,23 @@
<!ELEMENT it_companies (company+)>
<!ELEMENT company (name, location, employees, specialization, founded)>
<!-- Поле name должно содержать строку от 1 до 100 символов -->
<!ELEMENT name (#PCDATA)>
<!ATTLIST name length CDATA #IMPLIED>
<!-- Поле location должно содержать строку от 1 до 150 символов -->
<!ELEMENT location (#PCDATA)>
<!ATTLIST location length CDATA #IMPLIED>
<!-- Поле employees — целое число, больше 0 и до 2,000,000 -->
<!ELEMENT employees (#PCDATA)>
<!ATTLIST employees minInclusive CDATA #IMPLIED
maxInclusive CDATA #IMPLIED>
<!-- Поле specialization должно содержать строку от 1 до 200 символов -->
<!ELEMENT specialization (#PCDATA)>
<!ATTLIST specialization length CDATA #IMPLIED>
<!-- Поле founded — дата в формате YYYY-MM-DD -->
<!ELEMENT founded (#PCDATA)>
<!ATTLIST founded pattern CDATA #IMPLIED>

75
it_companies.xml Normal file
View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="it_companies.xsl"?>
<it_companies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="it_companies.xsd">
<company>
<name>OpenAI</name>
<location>San Francisco, CA, USA</location>
<employees>1000</employees>
<specialization>Artificial Intelligence</specialization>
<founded>2015-12-11</founded>
</company>
<company>
<name>Yandex</name>
<location>Moscow, Russia</location>
<employees>10000</employees>
<specialization>Search Engine, Online Services</specialization>
<founded>1997-09-23</founded>
</company>
<company>
<name>Google</name>
<location>Mountain View, CA, USA</location>
<employees>135000</employees>
<specialization>Search Engine, Advertising, Cloud Computing</specialization>
<founded>1998-09-04</founded>
</company>
<company>
<name>Microsoft</name>
<location>Redmond, WA, USA</location>
<employees>221000</employees>
<specialization>Software, Cloud Services</specialization>
<founded>1975-04-04</founded>
</company>
<company>
<name>Amazon</name>
<location>Seattle, WA, USA</location>
<employees>1540000</employees>
<specialization>E-commerce, Cloud Computing</specialization>
<founded>1994-07-05</founded>
</company>
<company>
<name>Apple</name>
<location>Cupertino, CA, USA</location>
<employees>164000</employees>
<specialization>Consumer Electronics, Software</specialization>
<founded>1976-04-01</founded>
</company>
<company>
<name>IBM</name>
<location>Armonk, NY, USA</location>
<employees>282100</employees>
<specialization>IT Services, Hardware, Software</specialization>
<founded>1911-06-16</founded>
</company>
<company>
<name>Meta (Facebook)</name>
<location>Menlo Park, CA, USA</location>
<employees>66000</employees>
<specialization>Social Media, Virtual Reality</specialization>
<founded>2004-02-04</founded>
</company>
<company>
<name>Twitter (X)</name>
<location>San Francisco, CA, USA</location>
<employees>7500</employees>
<specialization>Social Media</specialization>
<founded>2006-03-21</founded>
</company>
<company>
<name>Alibaba</name>
<location>Hangzhou, China</location>
<employees>251462</employees>
<specialization>E-commerce, Technology</specialization>
<founded>1999-06-28</founded>
</company>
</it_companies>

66
it_companies.xsd Normal file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="it_companies">
<xs:complexType>
<xs:sequence>
<xs:element name="company" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<!-- Ограничение на имя компании: минимум 1 символ, максимум 100 символов -->
<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Ограничение на местоположение: минимум 1 символ, максимум 150 символов -->
<xs:element name="location">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Ограничение на количество сотрудников: минимум 1, максимум 2,000,000 -->
<xs:element name="employees">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="2000000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Ограничение на специализацию: минимум 1 символ, максимум 200 символов -->
<xs:element name="specialization">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Ограничение на дату: только даты формата YYYY-MM-DD, минимум - 1900 год -->
<xs:element name="founded">
<xs:simpleType>
<xs:restriction base="xs:date">
<!-- Дата не может быть раньше 1900-01-01 -->
<xs:minInclusive value="1900-01-01"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

33
it_companies.xsl Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title>IT Companies</title>
</head>
<body>
<h2>List of IT Companies</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Location</th>
<th>Employees</th>
<th>Specialization</th>
<th>Founded</th>
</tr>
<xsl:for-each select="it_companies/company">
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="location" /></td>
<td><xsl:value-of select="employees" /></td>
<td><xsl:value-of select="specialization" /></td>
<td><xsl:value-of select="founded" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>