XML Reis

Loomine andmebass:

Loomine tabel:

Loomine mockaroo:

XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="reis.xsl"?>

<reisedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="reis.xsd">
	<trip id="1">
		<destination>Barcelona, Spain</destination>
		<rating>4.7</rating>
		<transport>
			<flight>
				<airport>BCN</airport>
				<number>VY123</number>
				<price>220.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Barcelona</name>
				<stars>4</stars>
				<price>450.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>120.00</total>
		</excursions>
		<meals>
			<total>80.00</total>
		</meals>
		<insurance>
			<total>30.00</total>
		</insurance>
		<other>
			<total>25.00</total>
		</other>
		<note>Late spring special</note>
	</trip>

	<trip id="2">
		<destination>Rome, Italy</destination>
		<rating>4.6</rating>
		<transport>
			<flight>
				<airport>FCO</airport>
				<number>AZ345</number>
				<price>180.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Roma</name>
				<stars>3</stars>
				<price>380.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>90.00</total>
		</excursions>
		<meals>
			<total>70.00</total>
		</meals>
		<insurance>
			<total>25.00</total>
		</insurance>
		<other>
			<total>20.00</total>
		</other>
		<note>City tour included</note>
	</trip>

	<trip id="3">
		<destination>Paris, France</destination>
		<rating>4.8</rating>
		<transport>
			<flight>
				<airport>CDG</airport>
				<number>AF789</number>
				<price>250.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Paris</name>
				<stars>5</stars>
				<price>600.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>150.00</total>
		</excursions>
		<meals>
			<total>100.00</total>
		</meals>
		<insurance>
			<total>40.00</total>
		</insurance>
		<other>
			<total>30.00</total>
		</other>
		<note>Romantic package</note>
	</trip>

	<trip id="4">
		<destination>Prague, Czechia</destination>
		<rating>4.2</rating>
		<transport>
			<flight>
				<airport>PRG</airport>
				<number>OK456</number>
				<price>140.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Praha</name>
				<stars>4</stars>
				<price>300.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>60.00</total>
		</excursions>
		<meals>
			<total>50.00</total>
		</meals>
		<insurance>
			<total>20.00</total>
		</insurance>
		<other>
			<total>15.00</total>
		</other>
	</trip>

	<trip id="5">
		<destination>Berlin, Germany</destination>
		<rating>4.1</rating>
		<transport>
			<flight>
				<airport>BER</airport>
				<number>LH222</number>
				<price>160.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Berlin</name>
				<stars>4</stars>
				<price>320.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>70.00</total>
		</excursions>
		<meals>
			<total>60.00</total>
		</meals>
		<insurance>
			<total>20.00</total>
		</insurance>
		<other>
			<total>10.00</total>
		</other>
	</trip>

	<trip id="6">
		<destination>Vienna, Austria</destination>
		<rating>4.3</rating>
		<transport>
			<flight>
				<airport>VIE</airport>
				<number>OS333</number>
				<price>155.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Hotel Vienna</name>
				<stars>4</stars>
				<price>340.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>80.00</total>
		</excursions>
		<meals>
			<total>55.00</total>
		</meals>
		<insurance>
			<total>22.00</total>
		</insurance>
		<other>
			<total>12.00</total>
		</other>
	</trip>

	<trip id="7">
		<destination>Amsterdam, NL</destination>
		<rating>4.5</rating>
		<transport>
			<flight>
				<airport>AMS</airport>
				<number>KL111</number>
				<price>210.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Canal Hotel</name>
				<stars>4</stars>
				<price>410.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>110.00</total>
		</excursions>
		<meals>
			<total>75.00</total>
		</meals>
		<insurance>
			<total>28.00</total>
		</insurance>
		<other>
			<total>18.00</total>
		</other>
		<note>Bike tour</note>
	</trip>

	<trip id="8">
		<destination>Lisbon, Portugal</destination>
		<rating>4.0</rating>
		<transport>
			<flight>
				<airport>LIS</airport>
				<number>TP222</number>
				<price>200.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Lisbon Inn</name>
				<stars>3</stars>
				<price>290.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>70.00</total>
		</excursions>
		<meals>
			<total>50.00</total>
		</meals>
		<insurance>
			<total>20.00</total>
		</insurance>
		<other>
			<total>10.00</total>
		</other>
	</trip>

	<trip id="9">
		<destination>Reykjavik, Iceland</destination>
		<rating>4.9</rating>
		<transport>
			<flight>
				<airport>KEF</airport>
				<number>FI505</number>
				<price>420.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Nordic Hotel</name>
				<stars>4</stars>
				<price>700.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>200.00</total>
		</excursions>
		<meals>
			<total>120.00</total>
		</meals>
		<insurance>
			<total>50.00</total>
		</insurance>
		<other>
			<total>40.00</total>
		</other>
		<note>Northern lights option</note>
	</trip>

	<trip id="10">
		<destination>Oslo, Norway</destination>
		<rating>4.4</rating>
		<transport>
			<flight>
				<airport>OSL</airport>
				<number>SK777</number>
				<price>300.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Fjord Hotel</name>
				<stars>4</stars>
				<price>520.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>130.00</total>
		</excursions>
		<meals>
			<total>90.00</total>
		</meals>
		<insurance>
			<total>35.00</total>
		</insurance>
		<other>
			<total>25.00</total>
		</other>
	</trip>

	<trip id="11">
		<destination>Stockholm, Sweden</destination>
		<rating>4.2</rating>
		<transport>
			<flight>
				<airport>ARN</airport>
				<number>SK123</number>
				<price>280.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Royal Hotel</name>
				<stars>5</stars>
				<price>540.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>120.00</total>
		</excursions>
		<meals>
			<total>95.00</total>
		</meals>
		<insurance>
			<total>30.00</total>
		</insurance>
		<other>
			<total>20.00</total>
		</other>
	</trip>

	<trip id="12">
		<destination>Helsinki, Finland</destination>
		<rating>4.1</rating>
		<transport>
			<flight>
				<airport>HEL</airport>
				<number>AY321</number>
				<price>260.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Sauna Hotel</name>
				<stars>4</stars>
				<price>480.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>100.00</total>
		</excursions>
		<meals>
			<total>85.00</total>
		</meals>
		<insurance>
			<total>28.00</total>
		</insurance>
		<other>
			<total>18.00</total>
		</other>
	</trip>

	<trip id="13">
		<destination>Budapest, Hungary</destination>
		<rating>4.0</rating>
		<transport>
			<flight>
				<airport>BUD</airport>
				<number>W6 221</number>
				<price>170.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Thermal Hotel</name>
				<stars>4</stars>
				<price>310.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>65.00</total>
		</excursions>
		<meals>
			<total>55.00</total>
		</meals>
		<insurance>
			<total>18.00</total>
		</insurance>
		<other>
			<total>12.00</total>
		</other>
	</trip>

	<trip id="14">
		<destination>Krakow, Poland</destination>
		<rating>3.9</rating>
		<transport>
			<flight/>
			<train>
				<price>45.00</price>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Old Town Hotel</name>
				<stars>3</stars>
				<price>200.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>50.00</total>
		</excursions>
		<meals>
			<total>40.00</total>
		</meals>
		<insurance>
			<total>15.00</total>
		</insurance>
		<other>
			<total>8.00</total>
		</other>
		<note>Train only</note>
	</trip>

	<trip id="15">
		<destination>Athens, Greece</destination>
		<rating>4.3</rating>
		<transport>
			<flight>
				<airport>ATH</airport>
				<number>A3 989</number>
				<price>230.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Acropolis Hotel</name>
				<stars>4</stars>
				<price>350.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>90.00</total>
		</excursions>
		<meals>
			<total>65.00</total>
		</meals>
		<insurance>
			<total>25.00</total>
		</insurance>
		<other>
			<total>15.00</total>
		</other>
	</trip>

	<trip id="16">
		<destination>Dubrovnik, Croatia</destination>
		<rating>4.4</rating>
		<transport>
			<flight>
				<airport>DBV</airport>
				<number>OU 170</number>
				<price>210.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Seaside Hotel</name>
				<stars>4</stars>
				<price>420.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>110.00</total>
		</excursions>
		<meals>
			<total>70.00</total>
		</meals>
		<insurance>
			<total>25.00</total>
		</insurance>
		<other>
			<total>20.00</total>
		</other>
	</trip>

	<trip id="17">
		<destination>London, UK</destination>
		<rating>4.6</rating>
		<transport>
			<flight>
				<airport>LHR</airport>
				<number>BA150</number>
				<price>270.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>London Suites</name>
				<stars>5</stars>
				<price>650.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>160.00</total>
		</excursions>
		<meals>
			<total>110.00</total>
		</meals>
		<insurance>
			<total>45.00</total>
		</insurance>
		<other>
			<total>35.00</total>
		</other>
		<note>Theatre ticket</note>
	</trip>

	<trip id="18">
		<destination>Dublin, Ireland</destination>
		<rating>4.0</rating>
		<transport>
			<flight>
				<airport>DUB</airport>
				<number>EI444</number>
				<price>190.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Green Hotel</name>
				<stars>3</stars>
				<price>330.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>85.00</total>
		</excursions>
		<meals>
			<total>60.00</total>
		</meals>
		<insurance>
			<total>22.00</total>
		</insurance>
		<other>
			<total>14.00</total>
		</other>
	</trip>

	<trip id="19">
		<destination>Edinburgh, UK</destination>
		<rating>4.1</rating>
		<transport>
			<flight/>
			<train>
				<price>60.00</price>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Castle Inn</name>
				<stars>4</stars>
				<price>360.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>80.00</total>
		</excursions>
		<meals>
			<total>65.00</total>
		</meals>
		<insurance>
			<total>20.00</total>
		</insurance>
		<other>
			<total>10.00</total>
		</other>
		<note>Train included</note>
	</trip>

	<trip id="20">
		<destination>Gran Canaria, Spain</destination>
		<rating>4.2</rating>
		<transport>
			<flight>
				<airport>LPA</airport>
				<number>IB210</number>
				<price>240.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Beach Hotel</name>
				<stars>4</stars>
				<price>400.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>100.00</total>
		</excursions>
		<meals>
			<total>90.00</total>
		</meals>
		<insurance>
			<total>30.00</total>
		</insurance>
		<other>
			<total>15.00</total>
		</other>
	</trip>

	<trip id="21">
		<destination>Malta, Valletta</destination>
		<rating>4.0</rating>
		<transport>
			<flight>
				<airport>MLA</airport>
				<number>KM333</number>
				<price>210.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Harbor Hotel</name>
				<stars>3</stars>
				<price>320.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>70.00</total>
		</excursions>
		<meals>
			<total>60.00</total>
		</meals>
		<insurance>
			<total>20.00</total>
		</insurance>
		<other>
			<total>12.00</total>
		</other>
	</trip>

	<trip id="22">
		<destination>Zermatt, Switzerland</destination>
		<rating>4.7</rating>
		<transport>
			<flight>
				<airport>ZRH</airport>
				<number>LX999</number>
				<price>340.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Mountain Hotel</name>
				<stars>4</stars>
				<price>680.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>140.00</total>
		</excursions>
		<meals>
			<total>100.00</total>
		</meals>
		<insurance>
			<total>40.00</total>
		</insurance>
		<other>
			<total>30.00</total>
		</other>
		<note>Ski pass optional</note>
	</trip>

	<trip id="23">
		<destination>Munich, Germany</destination>
		<rating>4.1</rating>
		<transport>
			<flight/>
			<train>
				<price>35.00</price>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>City Hotel</name>
				<stars>3</stars>
				<price>300.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>60.00</total>
		</excursions>
		<meals>
			<total>55.00</total>
		</meals>
		<insurance>
			<total>18.00</total>
		</insurance>
		<other>
			<total>10.00</total>
		</other>
		<note>Train only</note>
	</trip>

	<trip id="24">
		<destination>Budva, Montenegro</destination>
		<rating>3.8</rating>
		<transport>
			<flight>
				<airport>TGD</airport>
				<number>YM222</number>
				<price>180.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Adriatic Hotel</name>
				<stars>3</stars>
				<price>270.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>55.00</total>
		</excursions>
		<meals>
			<total>45.00</total>
		</meals>
		<insurance>
			<total>15.00</total>
		</insurance>
		<other>
			<total>10.00</total>
		</other>
	</trip>

	<trip id="25">
		<destination>Tallinn, Estonia</destination>
		<rating>4.3</rating>
		<transport>
			<flight>
				<airport>TLL</airport>
				<number>BT100</number>
				<price>120.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Old City Hotel</name>
				<stars>4</stars>
				<price>280.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>60.00</total>
		</excursions>
		<meals>
			<total>50.00</total>
		</meals>
		<insurance>
			<total>15.00</total>
		</insurance>
		<other>
			<total>8.00</total>
		</other>
	</trip>

	<trip id="26">
		<destination>Riga, Latvia</destination>
		<rating>4.0</rating>
		<transport>
			<flight/>
			<train>
				<price>30.00</price>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Baltic Hotel</name>
				<stars>3</stars>
				<price>240.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>50.00</total>
		</excursions>
		<meals>
			<total>45.00</total>
		</meals>
		<insurance>
			<total>12.00</total>
		</insurance>
		<other>
			<total>8.00</total>
		</other>
		<note>Train only</note>
	</trip>

	<trip id="27">
		<destination>Vilnius, Lithuania</destination>
		<rating>3.9</rating>
		<transport>
			<flight/>
			<train>
				<price>25.00</price>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Gediminas Hotel</name>
				<stars>3</stars>
				<price>220.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>45.00</total>
		</excursions>
		<meals>
			<total>40.00</total>
		</meals>
		<insurance>
			<total>10.00</total>
		</insurance>
		<other>
			<total>6.00</total>
		</other>
		<note>Train only</note>
	</trip>

	<trip id="28">
		<destination>New York, USA</destination>
		<rating>4.8</rating>
		<transport>
			<flight>
				<airport>JFK</airport>
				<number>DL400</number>
				<price>550.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Manhattan Hotel</name>
				<stars>5</stars>
				<price>1200.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>300.00</total>
		</excursions>
		<meals>
			<total>200.00</total>
		</meals>
		<insurance>
			<total>80.00</total>
		</insurance>
		<other>
			<total>60.00</total>
		</other>
		<note>Transatlantic</note>
	</trip>

	<trip id="29">
		<destination>Dubai, UAE</destination>
		<rating>4.6</rating>
		<transport>
			<flight>
				<airport>DXB</airport>
				<number>EK205</number>
				<price>700.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Marina Hotel</name>
				<stars>5</stars>
				<price>900.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>250.00</total>
		</excursions>
		<meals>
			<total>150.00</total>
		</meals>
		<insurance>
			<total>60.00</total>
		</insurance>
		<other>
			<total>40.00</total>
		</other>
		<note>Luxury option</note>
	</trip>

	<trip id="30">
		<destination>Tokyo, Japan</destination>
		<rating>4.9</rating>
		<transport>
			<flight>
				<airport>NRT</airport>
				<number>JL800</number>
				<price>900.00</price>
			</flight>
			<train>
				<price/>
			</train>
		</transport>
		<accommodation>
			<hotel>
				<name>Shinjuku Hotel</name>
				<stars>5</stars>
				<price>1100.00</price>
			</hotel>
		</accommodation>
		<excursions>
			<total>280.00</total>
		</excursions>
		<meals>
			<total>200.00</total>
		</meals>
		<insurance>
			<total>70.00</total>
		</insurance>
		<other>
			<total>50.00</total>
		</other>
		<note>Long haul</note>
	</trip>

</reisedata>

XSLT

<?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" indent="yes"/>

	<xsl:template match="/reisedata">
		<html>
			<head>
				<meta charset="utf-8"/>
				<title>Trips</title>
				<style>
					.third { background-color: yellow; padding: 2px; display: inline-block; }
					.highlight { font-weight: bold; color: red; }
					table { border-collapse: collapse; width: 100%; }
					th, td { border: 1px solid #ccc; padding: 6px; text-align: left; }
					.row-odd { background-color: #f9f9f9; }
					.row-even { background-color: #ffffff; }
				</style>
			</head>
			<body>
				<!-- Список поездок: фильтрация по наличию flight/price -->
				<xsl:for-each select="trip[transport/flight/price!='']">
					<!-- сортировка по rating (убывание) -->
					<xsl:sort select="number(rating)" data-type="number" order="descending"/>
					<div>
						<h1>
							<xsl:value-of select="destination"/>
							<xsl:text> </xsl:text>
							<xsl:text>(рейтинг: </xsl:text>
							<xsl:value-of select="rating"/>
							<xsl:text>)</xsl:text>
						</h1>

						<!-- Рассчёт стоимости: берем flight/price если есть, иначе train/price -->
						<xsl:variable name="transportPrice">
							<xsl:choose>
								<xsl:when test="string-length(normalize-space(transport/flight/price)) > 0">
									<xsl:value-of select="number(transport/flight/price)"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="number(transport/train/price)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="accPrice" select="number(accommodation/hotel/price)"/>
						<xsl:variable name="exc" select="number(excursions/total)"/>
						<xsl:variable name="meals" select="number(meals/total)"/>
						<xsl:variable name="ins" select="number(insurance/total)"/>
						<xsl:variable name="oth" select="number(other/total)"/>
						<xsl:variable name="total" select="$transportPrice + $accPrice + $exc + $meals + $ins + $oth"/>

						<!-- Показ компонентов -->
						<ul>
							<li>
								Transport
								<ul>
									<li>
										<!-- третий уровень: flight -->
										<span class="third">
											<xsl:if test="string-length(normalize-space(transport/flight/price)) > 0">
												Flight: <xsl:value-of select="transport/flight/number"/> -
												<xsl:value-of select="transport/flight/airport"/> -
												<xsl:value-of select="transport/flight/price"/>
											</xsl:if>
											<xsl:if test="not(string-length(normalize-space(transport/flight/price)))">
												Train price: <xsl:value-of select="transport/train/price"/>
											</xsl:if>
										</span>
									</li>
								</ul>
							</li>

							<li>
								Accommodation
								<ul>
									<li>
										<span class="third">
											<xsl:value-of select="accommodation/hotel/name"/>
											<xsl:value-of select="accommodation/hotel/stars"/>★ —
											<xsl:value-of select="accommodation/hotel/price"/>
										</span>
									</li>
								</ul>
							</li>

							<li>
								Excursions: <span class="third">
									<xsl:value-of select="excursions/total"/>
								</span>
							</li>
							<li>
								Meals: <span class="third">
									<xsl:value-of select="meals/total"/>
								</span>
							</li>
							<li>
								Insurance: <span class="third">
									<xsl:value-of select="insurance/total"/>
								</span>
							</li>
							<li>
								Other: <span class="third">
									<xsl:value-of select="other/total"/>
								</span>
							</li>
						</ul>

						<!-- Итоговая сумма с условием выделения -->
						<p>
							Total cost:
							<xsl:choose>
								<xsl:when test="$total > 1000">
									<span class="highlight">
										<xsl:value-of select="format-number($total,'0.00')"/>
									</span>
								</xsl:when>
								<xsl:otherwise>
									<span>
										<xsl:value-of select="format-number($total,'0.00')"/>
									</span>
								</xsl:otherwise>
							</xsl:choose>
						</p>

						<hr/>
					</div>
				</xsl:for-each>

				<!-- Табличный вывод: все trip (чередующиеся цвета) -->
				<h2>All trips (XML dump)</h2>
				<table>
					<tr>
						<th>ID</th>
						<th>Destination</th>
						<th>Rating</th>
						<th>Transport</th>
						<th>Accommodation</th>
						<th>Excursions</th>
						<th>Meals</th>
						<th>Insurance</th>
						<th>Other</th>
						<th>Total</th>
					</tr>
					<xsl:for-each select="trip">
						<xsl:variable name="rowClass">
							<xsl:choose>
								<xsl:when test="position() mod 2 = 1">row-odd</xsl:when>
								<xsl:otherwise>row-even</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="tprice">
							<xsl:choose>
								<xsl:when test="string-length(normalize-space(transport/flight/price)) > 0">
									<xsl:value-of select="number(transport/flight/price)"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="number(transport/train/price)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="sum" select="number($tprice) + number(accommodation/hotel/price) + number(excursions/total) + number(meals/total) + number(insurance/total) + number(other/total)"/>

						<tr>
							<td class="{$rowClass}">
								<xsl:value-of select="@id"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="destination"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="rating"/>
							</td>
							<td class="{$rowClass}">
								<xsl:if test="string-length(normalize-space(transport/flight/price)) > 0">
									<xsl:value-of select="concat('Flight ', transport/flight/number, ' (', transport/flight/airport, ') ', transport/flight/price, '€')"/>
								</xsl:if>
								<xsl:if test="not(string-length(normalize-space(transport/flight/price)))">
									<xsl:value-of select="concat('Train ', transport/train/price, '€')"/>
								</xsl:if>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="concat(accommodation/hotel/name, ' — ', accommodation/hotel/stars, '★ — ', accommodation/hotel/price, '€')"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="excursions/total"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="meals/total"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="insurance/total"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="other/total"/>
							</td>
							<td class="{$rowClass}">
								<xsl:value-of select="format-number($sum,'0.00')"/>
							</td>
						</tr>
					</xsl:for-each>
				</table>

			</body>
		</html>
	</xsl:template>

</xsl:stylesheet>

Tulemus:

Scroll to Top