Answer the question
In order to leave comments, you need to log in
xml. How to make a selection using XPath?
https://pastebin.com/5XgdSPNA
How to fetch data from this file using XPath?
By type: "Kurskaya complex: total classes n", "Classes at 10:00 n" The
data should be displayed in the browser.
I will be grateful!
Answer the question
In order to leave comments, you need to log in
One moment.
<office code="ВТ">
<lesson no="2" complex="BT">
<?xml-stylesheet type='text/xsl' href='/time.xsl'?>
<timeTable>
<offices>
<office code="КУ">
<name>Курская</name>
<address>Костомаровский пер., дом 3, стр 4, Москва, 105120</address>
</office>
<office code="BT">
<name>ВДНХ Техноград</name>
<address>пр-т Мира, 119 строение 63, Москва, 129223</address>
</office>
</offices>
<lessons>
<lesson no="1" complex="КУ">
<thema>Обзор XML технологий</thema>
<date>2021-01-19</date>
<time>10:00</time>
</lesson>
<lesson no="2" complex="BT">
<thema>Введение в XML</thema>
<date>2021-01-23</date>
<time>17:20</time>
</lesson>
<lesson no="3" complex="BT">
<thema>Правила XML</thema>
<date>2021-01-26</date>
<time>15:30</time>
</lesson>
<lesson no="4" complex="КУ">
<thema>Пространства имён XML</thema>
<date>2021-01-29</date>
<time>10:00</time>
</lesson>
<lesson no="5" complex="BT">
<thema>DTD: Описание структуры документа</thema>
<date>2021-02-03</date>
<time>17:20</time>
</lesson>
<lesson no="6" complex="BT">
<thema>DTD: определение сущностей</thema>
<date>2021-02-08</date>
<time>15:30</time>
</lesson>
<lesson no="7" complex="КУ">
<thema>Введение в XML Схемы</thema>
<date>2021-02-12</date>
<time>10:00</time>
</lesson>
<lesson no="8" complex="BT">
<thema>XML Схема: типы данных</thema>
<date>2021-02-17</date>
<time>17:20</time>
</lesson>
<lesson no="9" complex="BT">
<thema>Атрибуты типов</thema>
<date>2021-02-21</date>
<time>15:30</time>
</lesson>
<lesson no="10" complex="КУ">
<thema>XML Схема: Расширение сложных типов</thema>
<date>2021-02-25</date>
<time>10:00</time>
</lesson>
</lessons>
</timeTable>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="timeTable"/>
</xsl:template>
<xsl:template match="timeTable">
<html>
<head>
<title>page</title>
</head>
<body>
<xsl:apply-templates select="offices"/>
</body>
</html>
</xsl:template>
<xsl:template match="offices">
<div>
<xsl:apply-templates select="office"/>
</div>
</xsl:template>
<xsl:template match="office">
<xsl:variable name="office_code" select="@code"/>
<div>
<xsl:text>Комплекс </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>: всего занятий </xsl:text>
<xsl:value-of select="count(/timeTable/lessons/lesson[@complex = $office_code])"/>
<xsl:text>, занятий в 10:00 </xsl:text>
<xsl:value-of select="count(/timeTable/lessons/lesson[@complex = $office_code and time = '10:00'])"/>
</div>
</xsl:template>
</xsl:stylesheet>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>page</title>
</head>
<body>
<div>
<div>Комплекс Курская: всего занятий 4, занятий в 10:00 4</div>
<div>Комплекс ВДНХ Техноград: всего занятий 6, занятий в 10:00 0</div>
</div>
</body>
</html>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question