сдала 1 и 2, начала делать 3, подключить не могу xsd к xml

This commit is contained in:
Елена Бакальская 2024-10-04 09:42:55 +04:00
parent 4680c11e7a
commit 2d2885ba49
5 changed files with 86 additions and 12 deletions

44
miakd/animals.xsd Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Элемент animals, содержащий один или более animal -->
<xs:element name="animals">
<xs:complexType>
<xs:sequence>
<xs:element name="animal" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Элемент animal с атрибутом id и набором подэлементов -->
<xs:element name="animal">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="size">
<xs:complexType>
<xs:sequence>
<xs:element name="width" type="xs:string"/>
<xs:element name="height" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="weight" type="xs:string"/>
<xs:element name="color" type="xs:string"/>
<xs:element name="diet">
<xs:complexType>
<xs:sequence>
<xs:element name="food" type="xs:string"/>
<xs:element name="averageIntake" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="habitat" type="xs:string"/>
<xs:element name="interestingFact" type="xs:string"/>
</xs:sequence>
<!-- Атрибут id, который является уникальным идентификатором -->
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -1,23 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="XMLStyles.xslt"?>
<!DOCTYPE animals SYSTEM "animals.dtd">
<animals xmlns="http://msiter.ru"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://msiter.ru note.xsd">
<?xml-stylesheet type="text/xsl" href="styles.xslt"?>
<!DOCTYPE animals SYSTEM "animals.dtd">
<animals>
<animal id="1">
<name>Слон</name>
<size>
<width>3.2</width>
<!-- В метрах -->
<height>4.0</height>
<!-- В метрах -->
</size>
<weight>5400</weight>
<!-- В килограммах -->
<color>Серый</color>
<diet>
<food>Трава</food>
<averageIntake>около 150</averageIntake>
<!-- В килограммах в день -->
</diet>
<habitat>Саванна</habitat>
<interestingFact>Слоны - самые большие животные на Земле (на суше)</interestingFact>

View File

@ -35,8 +35,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ClosedXML.Parser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d5f7376574c51ec, processorArchitecture=MSIL">
<HintPath>packages\ClosedXML.Parser.1.2.0\lib\netstandard2.0\ClosedXML.Parser.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -87,19 +103,23 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="animals.dtd" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="animals.xsd">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="XMLanimalsTable.xml" />
<Resource Include="animalsTable.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="XMLStyles.xslt">
<Content Include="styles.xslt">
<SubType>Designer</SubType>
</Content>
</ItemGroup>

8
miakd/packages.config Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ClosedXML.Parser" version="1.2.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
</packages>

View File

@ -3,11 +3,10 @@
<xsl:template match="/">
<html>
<head>
<h1>Список интересных животных</h1>
<h1 style="">Список интересных животных</h1>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 3px solid rgb(255, 150, 100);
@ -15,7 +14,7 @@
text-align: center;
}
th {
background-color: #f2f2f2;
background-color: rgba(255, 150, 100, 0.5);
}
</style>
</head>
@ -33,6 +32,7 @@
</tr>
<!-- Цикл по каждому животному -->
<xsl:for-each select="animals/animal">
<xsl:sort select="weight" data-type="number" />
<tr>
<td>
<xsl:value-of select="name"/>
@ -57,9 +57,10 @@
<xsl:value-of select="habitat"/>
</td>
<td>
<xsl:value-of select="interestingFact"/>
<xsl:value-of select="interestingFact"/> :D
</td>
</tr>
</xsl:for-each>
</table>
</body>