powered by simpleCommunicator - 2.0.56     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Как правильно составить XSL шаблон?
3 сообщений из 3, страница 1 из 1
Как правильно составить XSL шаблон?
    #39076160
VaneS Ri_lax
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте,
у меня такая структура:
Код: xml
1.
2.
3.
4.
5.
6.
7.
1 инф группа 1
  1.1 инф группа 2
2 инф группа 3
  2.1 инф группа 4
  2.2 инф группа 5
    2.2.1 инф группа 6
3 инф группа 7


В итоге у меня получилась вот такая XML:
Код: xml
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.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
<informationsystem id="31">
  <informationsystem_dir_id>0</informationsystem_dir_id>
  <structure_id>166</structure_id>
  <site_id>6</site_id>
  <name>Тестовая</name>
  <description></description>
  <items_sorting_direction>0</items_sorting_direction>
  <items_sorting_field>0</items_sorting_field>
  <groups_sorting_direction>0</groups_sorting_direction>
  <groups_sorting_field>0</groups_sorting_field>
  <image_large_max_width>300</image_large_max_width>
  <image_large_max_height>300</image_large_max_height>
  <image_small_max_width>70</image_small_max_width>
  <image_small_max_height>70</image_small_max_height>
  <siteuser_group_id>0</siteuser_group_id>
  <use_captcha>1</use_captcha>
  <watermark_file></watermark_file>
  <watermark_default_use_large_image>0</watermark_default_use_large_image>
  <watermark_default_use_small_image>0</watermark_default_use_small_image>
  <watermark_default_position_x>50%</watermark_default_position_x>
  <watermark_default_position_y>100%</watermark_default_position_y>
  <user_id>19</user_id>
  <items_on_page>10</items_on_page>
  <format_date>%d.%m.%Y</format_date>
  <format_datetime>%d.%m.%Y %H:%M:%S</format_datetime>
  <url_type>1</url_type>
  <typograph_default_items>0</typograph_default_items>
  <typograph_default_groups>0</typograph_default_groups>
  <apply_tags_automatically>1</apply_tags_automatically>
  <change_filename>1</change_filename>
  <apply_keywords_automatically>1</apply_keywords_automatically>
  <group_image_large_max_width>300</group_image_large_max_width>
  <group_image_large_max_height>300</group_image_large_max_height>
  <group_image_small_max_width>70</group_image_small_max_width>
  <group_image_small_max_height>70</group_image_small_max_height>
  <preserve_aspect_ratio>1</preserve_aspect_ratio>
  <preserve_aspect_ratio_small>1</preserve_aspect_ratio_small>
  <preserve_aspect_ratio_group>1</preserve_aspect_ratio_group>
  <preserve_aspect_ratio_group_small>1</preserve_aspect_ratio_group_small>
  <url>/for-tests/</url>
  <captcha_id>19372</captcha_id>
  <items_count>0</items_count>
  <items_total_count>0</items_total_count>
  <subgroups_count>3</subgroups_count>
  <subgroups_total_count>7</subgroups_total_count>
  <siteuser_id>0</siteuser_id>
  <group>0</group>
  <page>0</page>
  <part>0</part>
  <limit>99</limit>
  <total>0</total>
  <informationsystem_group id="16">
    <informationsystem_id>31</informationsystem_id>
    <siteuser_id>0</siteuser_id>
    <parent_id>0</parent_id>
    <top_parent_id>0</top_parent_id>
    <name>Тест 1</name>
    <description></description>
    <sorting>0</sorting>
    <path>test-1</path>
    <image_large></image_large>
    <image_small></image_small>
    <indexing>1</indexing>
    <subgroups_count>1</subgroups_count>
    <subgroups_total_count>1</subgroups_total_count>
    <items_count>0</items_count>
    <items_total_count>0</items_total_count>
    <seo_title></seo_title>
    <seo_description></seo_description>
    <seo_keywords></seo_keywords>
    <siteuser_group_id>-1</siteuser_group_id>
    <active>1</active>
    <user_id>19</user_id>
    <sns_type_id>0</sns_type_id>
    <url>/for-tests/test-1/</url>
    <dir>/upload/information_system_31/0/1/6/group_16/</dir>
    <informationsystem_group id="21">
      <informationsystem_id>31</informationsystem_id>
      <siteuser_id>0</siteuser_id>
      <parent_id>16</parent_id>
      <top_parent_id>0</top_parent_id>
      <name>Тест 2</name>
      <description></description>
      <sorting>0</sorting>
      <path>test-2</path>
      <image_large></image_large>
      <image_small></image_small>
      <indexing>1</indexing>
      <subgroups_count>0</subgroups_count>
      <subgroups_total_count>0</subgroups_total_count>
      <items_count>0</items_count>
      <items_total_count>0</items_total_count>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
      <siteuser_group_id>-1</siteuser_group_id>
      <active>1</active>
      <user_id>19</user_id>
      <sns_type_id>0</sns_type_id>
      <url>/for-tests/test-1/test-2/</url>
      <dir>/upload/information_system_31/0/2/1/group_21/</dir>
    </informationsystem_group>
  </informationsystem_group>
  <informationsystem_group id="26">
    <informationsystem_id>31</informationsystem_id>
    <siteuser_id>0</siteuser_id>
    <parent_id>0</parent_id>
    <top_parent_id>0</top_parent_id>
    <name>тест 3</name>
    <description></description>
    <sorting>0</sorting>
    <path>test-3</path>
    <image_large></image_large>
    <image_small></image_small>
    <indexing>1</indexing>
    <subgroups_count>3</subgroups_count>
    <subgroups_total_count>3</subgroups_total_count>
    <items_count>0</items_count>
    <items_total_count>0</items_total_count>
    <seo_title></seo_title>
    <seo_description></seo_description>
    <seo_keywords></seo_keywords>
    <siteuser_group_id>-1</siteuser_group_id>
    <active>1</active>
    <user_id>19</user_id>
    <sns_type_id>0</sns_type_id>
    <url>/for-tests/test-3/</url>
    <dir>/upload/information_system_31/0/2/6/group_26/</dir>
    <informationsystem_group id="31">
      <informationsystem_id>31</informationsystem_id>
      <siteuser_id>0</siteuser_id>
      <parent_id>26</parent_id>
      <top_parent_id>0</top_parent_id>
      <name>тест 4</name>
      <description></description>
      <sorting>0</sorting>
      <path>test-4</path>
      <image_large></image_large>
      <image_small></image_small>
      <indexing>1</indexing>
      <subgroups_count>0</subgroups_count>
      <subgroups_total_count>0</subgroups_total_count>
      <items_count>0</items_count>
      <items_total_count>0</items_total_count>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
      <siteuser_group_id>-1</siteuser_group_id>
      <active>1</active>
      <user_id>19</user_id>
      <sns_type_id>0</sns_type_id>
      <url>/for-tests/test-3/test-4/</url>
      <dir>/upload/information_system_31/0/3/1/group_31/</dir>
    </informationsystem_group>
    <informationsystem_group id="36">
      <informationsystem_id>31</informationsystem_id>
      <siteuser_id>0</siteuser_id>
      <parent_id>26</parent_id>
      <top_parent_id>0</top_parent_id>
      <name>тест 5</name>
      <description></description>
      <sorting>0</sorting>
      <path>test-5</path>
      <image_large></image_large>
      <image_small></image_small>
      <indexing>1</indexing>
      <subgroups_count>1</subgroups_count>
      <subgroups_total_count>1</subgroups_total_count>
      <items_count>0</items_count>
      <items_total_count>0</items_total_count>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
      <siteuser_group_id>-1</siteuser_group_id>
      <active>1</active>
      <user_id>19</user_id>
      <sns_type_id>0</sns_type_id>
      <url>/for-tests/test-3/test-5/</url>
      <dir>/upload/information_system_31/0/3/6/group_36/</dir>
      <informationsystem_group id="41">
        <informationsystem_id>31</informationsystem_id>
        <siteuser_id>0</siteuser_id>
        <parent_id>36</parent_id>
        <top_parent_id>0</top_parent_id>
        <name>тест 6</name>
        <description></description>
        <sorting>0</sorting>
        <path>test-6</path>
        <image_large></image_large>
        <image_small></image_small>
        <indexing>1</indexing>
        <subgroups_count>0</subgroups_count>
        <subgroups_total_count>0</subgroups_total_count>
        <items_count>0</items_count>
        <items_total_count>0</items_total_count>
        <seo_title></seo_title>
        <seo_description></seo_description>
        <seo_keywords></seo_keywords>
        <siteuser_group_id>-1</siteuser_group_id>
        <active>1</active>
        <user_id>19</user_id>
        <sns_type_id>0</sns_type_id>
        <url>/for-tests/test-3/test-5/test-6/</url>
        <dir>/upload/information_system_31/0/4/1/group_41/</dir>
      </informationsystem_group>
    </informationsystem_group>
  </informationsystem_group>
  <informationsystem_group id="46">
    <informationsystem_id>31</informationsystem_id>
    <siteuser_id>0</siteuser_id>
    <parent_id>0</parent_id>
    <top_parent_id>0</top_parent_id>
    <name>тест 7</name>
    <description></description>
    <sorting>0</sorting>
    <path>test-7</path>
    <image_large></image_large>
    <image_small></image_small>
    <indexing>1</indexing>
    <subgroups_count>0</subgroups_count>
    <subgroups_total_count>0</subgroups_total_count>
    <items_count>0</items_count>
    <items_total_count>0</items_total_count>
    <seo_title></seo_title>
    <seo_description></seo_description>
    <seo_keywords></seo_keywords>
    <siteuser_group_id>-1</siteuser_group_id>
    <active>1</active>
    <user_id>19</user_id>
    <sns_type_id>0</sns_type_id>
    <url>/for-tests/test-7/</url>
    <dir>/upload/information_system_31/0/4/6/group_46/</dir>
  </informationsystem_group>
</informationsystem>


Вопрос, как мне правильно составить XSL шаблон чтобы я мог пробежаться по всем вложенным группам?
Сколько будет вложений заранее неизвестно.
В каждой родительской группе есть поле subgroups_count, в котором хранится число дочерних подгрупп.
Я не силен в XSL, подскажите пожалуйста, как это можно реализовать.
Заранее большое спасибо!
...
Рейтинг: 0 / 0
Как правильно составить XSL шаблон?
    #39076203
VaneS Ri_lax
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Если сократить XML то она выглядеть будет вот так:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
<informationsystem id="31">
	<informationsystem_group id="16">
		<name>Тест 1</name>
		<informationsystem_group id="21">
			<name>Тест 2</name>
		</informationsystem_group>
	</informationsystem_group>
	<informationsystem_group id="26">
		<name>тест 3</name>
		<informationsystem_group id="31">
			<name>тест 4</name>
		</informationsystem_group>
		<informationsystem_group id="36">
			<name>тест 5</name>
			<informationsystem_group id="41">
				<name>тест 6</name>
			</informationsystem_group>
		</informationsystem_group>
	</informationsystem_group>
	<informationsystem_group id="46">
		<name>тест 7</name>
	</informationsystem_group>
</informationsystem>


Но вот как пройтись по всем вложениям пока не знаю
...
Рейтинг: 0 / 0
Как правильно составить XSL шаблон?
    #39076444
Фотография Antonariy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
VaneS Ri_laxНо вот как пройтись по всем вложениям пока не знаю
Код: xml
1.
2.
3.
<xsl:template match="informationsystem_group">
    <xsl:apply-templates select="informationsystem_group"/>
</xsl:template>
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Как правильно составить XSL шаблон?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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