Гость
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Не выполняется цикл / 3 сообщений из 3, страница 1 из 1
13.03.2009, 00:56
    #35866145
Ex_Soft
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не выполняется цикл
Дрозофила:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
<?xml version="1.0" encoding="windows-1251"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<contract xmlns="http://localhost/contract" xmlns:othersperson="http://localhost/othersperson">
	<contragent>Иванов Иван Иванович</contragent>
	<date> 2009 . 03 . 11 </date>
	<no> 13 </no>
	<othersperson:othersperson>
		<othersperson:contragent othersperson:date="1870.04.22">Ленин Владимир Ильич</othersperson:contragent>
		<othersperson:contragent othersperson:date="1878.12.18">Сталин Иосиф Виссарионович</othersperson:contragent>
		<othersperson:contragent othersperson:date="1894.04.17">Хрущев Никита Сергеевич</othersperson:contragent>
	</othersperson:othersperson>
</contract>
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://localhost/contract" xmlns:othersperson="http://localhost/othersperson">
	<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" encoding="windows-1251" />
	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="//my:contragent"/></title>
			</head>
			<body>
				<p><strong><xsl:value-of select="//my:contragent"/></strong></p>
				<p><xsl:value-of select="//my:date"/></p>
				<p><xsl:value-of select="//my:no"/></p>
				<table>
					<caption>Others Person I</caption>
					<thead>
						<tr>
							<th>Name</th>
							<th>BirthDate</th>
						</tr>
					</thead>
					<tbody>
						<xsl:apply-templates select="my:contract/othersperson:othersperson" />
					</tbody>
				</table>
				<hr />
				<table>
					<caption>Others Person II</caption>
					<thead>
						<tr>
							<th>Name</th>
							<th>BirthDate</th>
						</tr>
					</thead>
					<tbody>
						<xsl:for-each select="my:contract/othersperson:othersperson">
							<tr>
								<td><xsl:value-of select="othersperson:contragent" /></td>
								<td><xsl:value-of select="othersperson:contragent/@othersperson:date" /></td>
							</tr>
						</xsl:for-each>
					</tbody>
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="othersperson:othersperson">
		<tr>
			<td><xsl:value-of select="othersperson:contragent" /></td>
			<td><xsl:value-of select="othersperson:contragent/@othersperson:date" /></td>
		</tr>
	</xsl:template>
</xsl:stylesheet>
В обоих случаях выводит только 1 TR (с Лениным). А почему?
_________________
"Helo, word!" - 17 errors 56 warnings
...
Рейтинг: 0 / 0
13.03.2009, 12:15
    #35867088
maXmo
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не выполняется цикл
сосчитай othersperson:othersperson'ов.
...
Рейтинг: 0 / 0
13.03.2009, 12:36
    #35867167
Ex_Soft
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не выполняется цикл
Уже направили на путь истинный:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://localhost/contract" xmlns:othersperson="http://localhost/othersperson">
	<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" encoding="windows-1251" />
	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="//my:contragent"/></title>
			</head>
			<body>
				<p><strong><xsl:value-of select="//my:contragent"/></strong></p>
				<p><xsl:value-of select="//my:date"/></p>
				<p><xsl:value-of select="//my:no"/></p>
				<table>
					<caption>Others Person I</caption>
					<thead>
						<tr>
							<th>Name</th>
							<th>BirthDate</th>
						</tr>
					</thead>
					<tbody>
						<xsl:apply-templates select="my:contract/othersperson:othersperson" />
					</tbody>
				</table>
				<hr />
				<table>
					<caption>Others Person II</caption>
					<thead>
						<tr>
							<th>Name</th>
							<th>BirthDate</th>
						</tr>
					</thead>
					<tbody>
						<xsl:for-each select="my:contract/othersperson:othersperson/othersperson:contragent">
							<tr>
								<td><xsl:value-of select="." /></td>
								<td><xsl:value-of select="@othersperson:date" /></td>
							</tr>
						</xsl:for-each>
					</tbody>
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="othersperson:othersperson">
		<xsl:apply-templates select="othersperson:contragent" />
	</xsl:template>

	<xsl:template match="othersperson:contragent">
		<tr>
			<td><xsl:value-of select="." /></td>
			<td><xsl:value-of select="@othersperson:date" /></td>
		</tr>
	</xsl:template>
</xsl:stylesheet>
_________________
"Helo, word!" - 17 errors 56 warnings
Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Не выполняется цикл / 3 сообщений из 3, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]