<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1002669</guid>
        <pubDate>Wed, 01 Feb 2006 11:27:49 +0000</pubDate>
        <title>Группировка 2х уровней данных в XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1002669</link>
        <description><![CDATA[Tishaishii: Объясню.<br>
<br>
Структура вида:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">o(</div><div class="code_line">&nbsp;&nbsp; &nbsp;B=&#62;Ba,</div><div class="code_line">&nbsp;&nbsp; &nbsp;A=&#62;Aa,</div><div class="code_line">&nbsp;&nbsp; &nbsp;C=&#62;Ca</div><div class="code_line">),</div><div class="code_line">o(</div><div class="code_line">&nbsp;&nbsp; &nbsp;B=&#62;Bb,</div><div class="code_line">&nbsp;&nbsp; &nbsp;A=&#62;Aa</div><div class="code_line">)</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
Надо получить на выходе:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">B(2): Bb(1), Ba(1);</div><div class="code_line">A(2): Aa(2);</div><div class="code_line">C(1): Ca(1)</div></ol></div></div></div></div>]]></description>
        <author>Tishaishii</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1002245</guid>
        <pubDate>Tue, 31 Jan 2006 23:06:24 +0000</pubDate>
        <title>Группировка 2х уровней данных в XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1002245</link>
        <description><![CDATA[Ho Im: Я в XSL  не силен, потому для данного конкретного примера не скажу. Но... виды материалов, которые сгруппированы по назначению, ты что, опять по назначению разгруппировывать хочешь? Экая загогулина получается...]]></description>
        <author>Ho Im</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1001722</guid>
        <pubDate>Tue, 31 Jan 2006 13:20:10 +0000</pubDate>
        <title>Группировка 2х уровней данных в XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=131064&amp;view=findpost&amp;p=1001722</link>
        <description><![CDATA[Tishaishii: Файл test.xml:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&#60;?xml version=&quot;1.0&quot; encoding=&quot;windows-1251&quot;?&#62;</div><div class="code_line">&#60;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;test.xsl&quot;?&#62;</div><div class="code_line">&#60;!DOCTYPE base SYSTEM &quot;test.dtd&quot;&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&#60;base&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&house_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&house_matherial_1;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&roof_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&roof_matherial_2;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&house_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&house_matherial_3;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&roof_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&roof_matherial_2;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&house_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&house_matherial_3;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&roof_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&roof_matherial_2;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;object&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&house_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&house_matherial_2;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;name&#62;&roof_matherial;&#60;/name&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;value&#62;&roof_matherial_1;&#60;/value&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/attr&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/object&#62;</div><div class="code_line">&#60;/base&#62;</div></ol></div></div></div></div><br>
Файл test.xsl:<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&#60;?xml version=&quot;1.0&quot; encoding=&quot;windows-1251&quot;?&#62;</div><div class="code_line">&#60;xsl:stylesheet version=&quot;1.0&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&#60;xsl:template match=&quot;/&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;HTML&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;HEAD&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;TITLE&#62;&#60;/TITLE&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/HEAD&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;BODY&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;DIV class=&quot;page&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/DIV&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/BODY&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/HTML&#62;</div><div class="code_line">&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:key name=&quot;name_key&quot; match=&quot;attr&quot; use=&quot;name|value&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;object&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:for-each select=&quot;attr[count(. | key(&#39;name_key&#39;, name)[1])=1]&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:sort select=&quot;name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;li&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;h3&#62;&#60;xsl:value-of select=&quot;name&quot;/&#62;&#60;/h3&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;ul&#62;&#60;!--вот здесь проблемка--&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:for-each select=&quot;key(&#39;name_key&#39;, name)|attr[value]&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:sort select=&quot;value&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;li&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;value&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/li&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:for-each&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/ul&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/li&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:for-each&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&#60;/xsl:stylesheet&#62;</div></ol></div></div></div></div><br>
DTD приводить не буду, не важно.<br>
<br>
name - назначение материала.<br>
value - вид материала.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&house_matherial; - материал дома</div><div class="code_line">&roof_matherial; - материал крыши</div></ol></div></div></div></div><br>
<br>
Надо составить XSL так, чтобы на выходе получать:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">Назначение материала #1: &#60;список всех используемых</div><div class="code_line">в БД видов материалов для данного</div><div class="code_line">назначения и в скобках количество объектов,</div><div class="code_line">испоьзующих данный материал для данного назначения&#62;</div><div class="code_line">Назначение материала #2: &#60;список всех используемых</div><div class="code_line">в БД видов материалов для данного</div><div class="code_line">назначения и в скобках количество объектов,</div><div class="code_line">испоьзующих данный материал для данного назначения&#62;</div></ol></div></div></div></div><br>
<br>
Например:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">Материал дома: кирпич(1), саман(2), шлакоблок(1)</div><div class="code_line">Материал крыши: шифер(1), черепица(2)</div></ol></div></div></div></div><br>
<br>
Т.е. я пока имею группировку только по виду назначения материала, а хочется ещё сгруппировать и виды материалов.]]></description>
        <author>Tishaishii</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      </channel>
      </rss>
	