<?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=352199&amp;view=findpost&amp;p=3098588</guid>
        <pubDate>Mon, 19 Mar 2012 07:51:27 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3098588</link>
        <description><![CDATA[tomboy1: В строке 15:<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">&nbsp;&#60;xsl:template match=&quot;field[@isSimple=&#39;yes&#39;]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script> <br>
убрал [@isSimple=&#39;yes&#39;], чтобы были выведены пустые элементы. Т.е. для <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">&nbsp;&nbsp;&#60;type wireName=&quot;box&quot; name=&quot;Box&quot; &#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;field name=&quot;rightCornerPoint&quot; type=&quot;Point&quot; isOptional=&quot;no&quot; wireName=&quot;point&quot; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;field name=&quot;leftCornerPoint&quot; &nbsp;type=&quot;Point&quot; isOptional=&quot;no&quot; wireName=&quot;point&quot; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp;&#60;/type&#62;</div></ol></div></div></div></div> был такой вывод: <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">- box: []</div></ol></div></div></div></div> <br>
Все остальное, вроде, правильно. Еще раз большое спасибо&#33;&#33;&#33;]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3097214</guid>
        <pubDate>Fri, 16 Mar 2012 09:24:55 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3097214</link>
        <description><![CDATA[ss: <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;UTF-8&quot;?&#62;</div><div class="code_line">&#60;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&#62;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:output method=&quot;text&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:template match=&quot;/&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:apply-templates select=&quot;intermediate/type&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:template match=&quot;type&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:apply-templates select=&quot;field[1]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;@wireName&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;&nbsp;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:template match=&quot;field[@isSimple=&#39;yes&#39;]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:param name=&quot;accumulated&quot; select=&quot;node()&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:param name=&quot;hidden&quot; select=&quot;false()&quot;/&#62; &nbsp;&#60;!-- в первый раз никто не скрыт, то есть опциональный field будет выведен --&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:variable name=&quot;is-last&quot; select=&quot;not(following-sibling::field)&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:variable name=&quot;is-simple&quot; select=&quot;@isSimple=&#39;yes&#39;&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:variable name=&quot;new-accumulated&quot; select=&quot;$accumulated | current()[not($hidden) and $is-simple]&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:if test=&quot;not($is-last)&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;following-sibling::field[1]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#60;xsl:with-param name=&quot;accumulated&quot; select=&quot;$new-accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;/xsl:if&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:apply-templates select=&quot;current()[$is-last]&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;accumulated&quot; select=&quot;$new-accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;current()[@isOptional=&#39;yes&#39;][not($hidden)][$is-simple]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;hidden&quot; select=&quot;true()&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;accumulated&quot; select=&quot;$accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:template match=&quot;*&quot; mode=&quot;recursive-combine&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;&#60;xsl:template match=&quot;field&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;xsl:param name=&quot;accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;xsl:value-of select=&quot;concat(&#39;- &#39;, $wire-name, &#39;: [&#39;)&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;xsl:for-each select=&quot;$accumulated&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#60;xsl:value-of select=&quot;concat( substring(&#39;, &#39;, 1 div (not(position()=1)) ), @name )&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;/xsl:for-each&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &#60;xsl:value-of select=&quot;concat(&#39;]&#39;, &#39;&amp;#xa;&#39;)&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;/xsl:template&#62;</div><div class="code_line">&#60;/xsl:stylesheet&#62;</div></ol></div></div></div></div><br>
1. нафиг чойз в выводе, если до вывода доходят только простые поля?<br>
2. переделал на ноде-сеты (смотри внимательно на парметр accumulated), потому нужно допилить под твой парсер - каждый по-своему с сетами работает.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3096195</guid>
        <pubDate>Wed, 14 Mar 2012 21:14:05 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3096195</link>
        <description><![CDATA[ss: Помогу послезавтра.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3096098</guid>
        <pubDate>Wed, 14 Mar 2012 16:55:18 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3096098</link>
        <description><![CDATA[tomboy1: Ан нет, и сейчас немного неправильно.<br>
Смысл вот в чем. Если последний атрибут сделать опциональным, то будет лишняя запятая в конце. Т.е. вот для такой xml:<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;type wireName=&quot;point&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;field wireName=&quot;lat&quot; isOptional=&quot;yes&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;field wireName=&quot;lit&quot; isOptional=&quot;no&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;field wireName=&quot;lon&quot; isOptional=&quot;yes&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;field wireName=&quot;lur&quot; isOptional=&quot;yes&quot; isSimple=&quot;yes&quot; name=&quot;lur&quot;/&#62;</div><div class="code_line">&#60;/type&#62;</div></ol></div></div></div></div>Вывод будет таким:<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">&nbsp;- point: [lat, lit, lon, lur]</div><div class="code_line">&nbsp;- point: [lat, lit, lon, ]</div><div class="code_line">&nbsp;- point: [lat, lit, lur]</div><div class="code_line">&nbsp;- point: [lat, lit, ]</div><div class="code_line">&nbsp;- point: [lit, lon, lur]</div><div class="code_line">&nbsp;- point: [lit, lon, ]</div><div class="code_line">&nbsp;- point: [lit, lur]</div><div class="code_line">&nbsp;- point: [lit, ]</div></ol></div></div></div></div><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">&#60;xsl:variable name=&quot;is-last&quot; select=&quot;not(following-sibling::field)&quot;/&#62;</div></ol></div></div></div></div> добавил <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;xsl:variable name=&quot;is-last-optional&quot; select=&quot;(not($is-last) and following-sibling::field[$is-last][@isOptional=&#39;yes&#39;][not($hidden)])&quot;/&#62;</div></ol></div></div></div></div> и использовал ее здесь:<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;xsl:variable name=&quot;comma&quot; select=&quot;substring(&#39;, &#39;, 1 div (not($hidden) and not($is-last) and $is-simple and is-last-optional))&quot;/&#62;</div></ol></div></div></div></div><br>
Не работает. Он вообще не ставит запятые.<br>
По логике, если мы имеем предпоследний элемент, а последний у нас опциональный и скрытый, то мы не должны ставить запятую. Вроде так и написал, но не работает.<br>
<strong class='tag-b'>ss</strong>, добрый человек, помоги  :-?]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087829</guid>
        <pubDate>Thu, 01 Mar 2012 10:20:51 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087829</link>
        <description><![CDATA[tomboy1: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087822'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ss &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T10:14:13+00:00">01.03.12, 10:14</time></span><div class='quote '>та ещё каша</div></div><br>
Да уж.<br>
<br>
<strong class='tag-b'>ss</strong>, большое спасибо&#33; Теперь, вроде, все правильно.]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087822</guid>
        <pubDate>Thu, 01 Mar 2012 10:14:13 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087822</link>
        <description><![CDATA[ss: <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;xsl:apply-templates select=&quot;current()[@isOptional=&#39;yes&#39;][not($hidden)]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div><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;xsl:apply-templates select=&quot;current()[@isOptional=&#39;yes&#39;][not($hidden)][$is-simple]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-01T10:15:09+00:00">01.03.12, 10:15</time></span></span><br>
та ещё каша]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087797</guid>
        <pubDate>Thu, 01 Mar 2012 09:59:56 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087797</link>
        <description><![CDATA[tomboy1: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087790'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ss &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T09:44:59+00:00">01.03.12, 09:44</time></span><div class='quote '>Неправильно.</div></div><br>
Да, и правда неправильно.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087785'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>ss &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T09:40:05+00:00">01.03.12, 09:40</time></span><div class='quote '>Не проверял.</div></div><br>
В этом случае выводятся несколько элементов, у которых атрибуты isOptional=&quot;yes&quot; и &quot;isSimple=no&quot;.<br>
Т.е. для 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">&nbsp;&nbsp; &#60;type wireName=&quot;content-path&quot; name=&quot;ContentPath&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;startPoint&quot; &nbsp; &nbsp; &nbsp; &nbsp;type=&quot;Point&quot; &nbsp; &nbsp; &nbsp;isOptional=&quot;yes&quot; wireName=&quot;start-point&quot; &nbsp; &nbsp; &nbsp; &nbsp; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;endPoint&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;type=&quot;Point&quot; &nbsp; &nbsp; &nbsp;isOptional=&quot;yes&quot; wireName=&quot;end-point&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;pathFileID&quot; &nbsp; &nbsp; &nbsp; &nbsp;type=&quot;String&quot; &nbsp; &nbsp; isOptional=&quot;no&quot; &nbsp;wireName=&quot;id&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;routeSplinePacked&quot; type=&quot;BinaryData&quot; isOptional=&quot;no&quot; &nbsp;wireName=&quot;route-spline-packed&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;/type&#62;</div></ol></div></div></div></div><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">- content-path: [pathFileID, routeSplinePacked]</div><div class="code_line">- content-path: [pathFileID, routeSplinePacked]</div><div class="code_line">- content-path: [pathFileID, routeSplinePacked]</div><div class="code_line">- content-path: [pathFileID, routeSplinePacked]</div></ol></div></div></div></div>,<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">- content-path: [pathFileID, routeSplinePacked]</div></ol></div></div></div></div>]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087790</guid>
        <pubDate>Thu, 01 Mar 2012 09:44:59 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087790</link>
        <description><![CDATA[ss: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087786'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>tomboy1 &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T09:41:47+00:00">01.03.12, 09:41</time></span><div class='quote '>Вроде работает</div></div>Неправильно.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087786</guid>
        <pubDate>Thu, 01 Mar 2012 09:41:47 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087786</link>
        <description><![CDATA[tomboy1: Сделал так (последний шаблон):<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">&nbsp;&nbsp; &nbsp;&#60;!-- output template --&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;field&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;accumulated-string&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:choose&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:when test=&quot;@isSimple = &#39;yes&#39;&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;!-- output string --&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;concat(&#39;- &#39;, $wire-name, &#39;: [&#39;, $accumulated-string, &#39;]&#39;, &#39;&amp;#xa;&#39;)&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:when&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:otherwise&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;concat(&#39;- &#39;, $wire-name, &#39;: [&#39;, &#39;]&#39;, &#39;&amp;#xa;&#39;)&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:otherwise&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:choose&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div></ol></div></div></div></div><br>
Вроде работает  :yes:]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087785</guid>
        <pubDate>Thu, 01 Mar 2012 09:40:05 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087785</link>
        <description><![CDATA[ss: <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;xsl:variable name=&quot;comma&quot; select=&quot;substring(&#39;, &#39;, 1 div (not($hidden) and not($is-last)) )&quot;/&#62;</div><div class="code_line">&#60;xsl:variable name=&quot;new-accumulated&quot; select=&quot;concat($accumulated-string, @name[not($hidden)], $comma)&quot;/&#62;</div></ol></div></div></div></div><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;xsl:variable name=&quot;is-simple&quot; select=&quot;@isSimple=&#39;yes&#39;&quot;/&#62;</div><div class="code_line">&#60;xsl:variable name=&quot;comma&quot; select=&quot;substring(&#39;, &#39;, 1 div (not($hidden) and not($is-last) and $is-simple) )&quot;/&#62;</div><div class="code_line">&#60;xsl:variable name=&quot;new-accumulated&quot; select=&quot;concat($accumulated-string, @name[not($hidden) and $is-simple], $comma)&quot;/&#62;</div></ol></div></div></div></div><br>
Не проверял.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087780</guid>
        <pubDate>Thu, 01 Mar 2012 09:31:22 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087780</link>
        <description><![CDATA[tomboy1: Ан нет, не совсем так.<br>
Если элемент isSimple = &#39;yes&#39;, то он выводится. Если isSimple = &#39;no&#39;, то он не выводится, но вместо него выводятся пустые скобки.<br>
Т.е. для 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;UTF-8&quot;?&#62;</div><div class="code_line">&#60;intermediate name=&quot;simple&quot; package=&quot;protocol&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;type wireName=&quot;point&quot; name=&quot;Point&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lat&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lat&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lon&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lon&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lur&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lur&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lit&quot; type=&quot;double&quot; isOptional=&quot;no&quot; &nbsp;isArray=&quot;no&quot; wireName=&quot;lit&quot; isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;/type&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;type wireName=&quot;box&quot; name=&quot;Box&quot; &#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;rightCornerPoint&quot; type=&quot;Point&quot; isOptional=&quot;no&quot; wireName=&quot;point&quot; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;leftCornerPoint&quot; &nbsp;type=&quot;Point&quot; isOptional=&quot;no&quot; wireName=&quot;point&quot; isSimple=&quot;no&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;/type&#62;</div><div class="code_line">&#60;/intermediate&#62;</div></ol></div></div></div></div><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">- point: [lat, lon, lur, lit]</div><div class="code_line">- point: [lat, lon, lit]</div><div class="code_line">- point: [lat, lur, lit]</div><div class="code_line">- point: [lat, lit]</div><div class="code_line">- point: [lon, lur, lit]</div><div class="code_line">- point: [lon, lit]</div><div class="code_line">- point: [lur, lit]</div><div class="code_line">- point: [lit]</div><div class="code_line">- box: []</div></ol></div></div></div></div><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">- point: [lat, lon, lur, lit]</div><div class="code_line">- point: [lat, lon, lit]</div><div class="code_line">- point: [lat, lur, lit]</div><div class="code_line">- point: [lat, lit]</div><div class="code_line">- point: [lon, lur, lit]</div><div class="code_line">- point: [lon, lit]</div><div class="code_line">- point: [lur, lit]</div><div class="code_line">- point: [lit]</div></ol></div></div></div></div><br>
Если добавить условие [@isOptional=&#39;yes&#39;]в строчку <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;xsl:template match=&quot;field&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div><br>
то эти поля просто будут пропускаться. Нужно, чтобы эти поля не пропускались, но выводились пустые скобки.]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087691</guid>
        <pubDate>Thu, 01 Mar 2012 08:01:45 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087691</link>
        <description><![CDATA[ss: Ну да. Невнимательно прочитал.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087688</guid>
        <pubDate>Thu, 01 Mar 2012 07:54:38 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087688</link>
        <description><![CDATA[tomboy1: Тогда скорее на <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;xsl:template match=&quot;field[@isSimple=&#39;yes&#39;]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div>,<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">&#60;xsl:template match=&quot;field[@isOptional=&#39;yes&#39;]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div><br>
Идею понял. Спасибо еще раз&#33;]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087685</guid>
        <pubDate>Thu, 01 Mar 2012 07:50:33 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087685</link>
        <description><![CDATA[ss: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087670'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>tomboy1 &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T07:29:53+00:00">01.03.12, 07:29</time></span><div class='quote '> как теперь выводить только те элементы, у которых isSimple = &quot;yes&quot;</div></div><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">&nbsp;&#60;xsl:template match=&quot;field&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div>заменить на<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">&nbsp;&#60;xsl:template match=&quot;field[@isOptional=&#39;yes&#39;]&quot; mode=&quot;recursive-combine&quot;&#62;</div></ol></div></div></div></div><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087670'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>tomboy1 &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T07:29:53+00:00">01.03.12, 07:29</time></span><div class='quote '>Всего третий день изучаю xsl. Как же это сложно. Мне кажется, что я никогда это не пойму</div></div>Это называется &quot;высокий порог вхождения&quot;. Входи - понравится  :lol: <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-01T07:54:20+00:00">01.03.12, 07:54</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352199&view=findpost&p=3087670'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>tomboy1 &#064; <time class="tag-quote__quoted-time" datetime="2012-03-01T07:29:53+00:00">01.03.12, 07:29</time></span><div class='quote '>Как я понимаю, этот шаблон ничего не делает. Зачем тогда он?</div></div>Он отлавливает остатки.<br>
Даже если ты такой шаблон не напишешь, &quot;всё остальное&quot;, что ты явно не match&#39;ишь своими шаблонами, будет поймано built-in шаблоном (одним из), а они только и делают, что в итоге выводят всё (что могут) в output. Как правило, такой вывод не нужен.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087670</guid>
        <pubDate>Thu, 01 Mar 2012 07:29:53 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087670</link>
        <description><![CDATA[tomboy1: <strong class='tag-b'>ss</strong>, большое спасибо&#33; Прям огромное. То, что нужно.<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">&nbsp;&nbsp;&#60;xsl:template match=&quot;*&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:param name=&quot;accumulated-string&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;xsl:value-of select=&quot;concat(&#39;- &#39;, $wire-name, &#39;: [&#39;, $accumulated-string, &#39;]&#39;, &#39;&amp;#xa;&#39;)&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &#60;/xsl:template&#62;</div></ol></div></div></div></div><br>
Ну и вначале поставил тип вывода на текстовый. В общем, это было несложно :).<br>
Еще вопрос: а как теперь выводить только те элементы, у которых isSimple = &quot;yes&quot;? Куда надо добавить это условие?<br>
Всего третий день изучаю xsl. Как же это сложно. Мне кажется, что я никогда это не пойму  :no-sad:.<br>
<br>
И еще: может дадите какие-нибудь рекомендации по изучению? Чувствую, что андроид-программисту по текущей ситуации еще долго придется разбираться в xsl :). Книжки, задания, справочники? Кто по чему изучал?<br>
Спасибо&#33; <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-01T07:43:15+00:00">01.03.12, 07:43</time></span></span><br>
<strong class='tag-b'>ss</strong>, скажи пожалуйста, а нужна зачем строчка<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">&nbsp;&nbsp;&#60;xsl:template match=&quot;*&quot; mode=&quot;recursive-combine&quot;/&#62;</div></ol></div></div></div></div><br>
Как я понимаю, этот шаблон ничего не делает. Зачем тогда он?]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087434</guid>
        <pubDate>Wed, 29 Feb 2012 19:10:07 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087434</link>
        <description><![CDATA[ss: <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;UTF-8&quot;?&#62;</div><div class="code_line">&#60;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:output method=&quot;xml&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;/&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;intermediate/type&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;type&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;field[1]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;@wireName&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;field&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;accumulated-string&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;hidden&quot; select=&quot;false()&quot;/&#62; &nbsp;&#60;!-- в первый раз никто не скрыт, то есть опциональный field будет выведен --&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:variable name=&quot;is-last&quot; select=&quot;not(following-sibling::field)&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:variable name=&quot;comma&quot; select=&quot;substring(&#39;, &#39;, 1 div (not($hidden) and not($is-last)) )&quot;/&#62; &#60;!-- это - сильное колдунство --&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:variable name=&quot;new-accumulated&quot; select=&quot;concat($accumulated-string, @name[not($hidden)], $comma)&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:if test=&quot;not($is-last)&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;following-sibling::field[1]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;accumulated-string&quot; select=&quot;$new-accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:if&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;current()[$is-last]&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;accumulated-string&quot; select=&quot;$new-accumulated&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates select=&quot;current()[@isOptional=&#39;yes&#39;][not($hidden)]&quot; mode=&quot;recursive-combine&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;hidden&quot; select=&quot;true()&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;accumulated-string&quot; select=&quot;$accumulated-string&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:with-param name=&quot;wire-name&quot; select=&quot;$wire-name&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:apply-templates&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;*&quot; mode=&quot;recursive-combine&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;!-- жрёт всё подряд, потому что я люблю пихать условия в виде current()[$is-last]. можно заменить на именованый шаблон и xsl:if --&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;*&quot; mode=&quot;output&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;accumulated-string&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:param name=&quot;wire-name&quot;/&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;!-- вывод в таком виде, потому что на выходе всё-таки XML. переделывай как хочешь. --&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;entry value=&quot;{concat(&#39;- &#39;, $wire-name, &#39;: [&#39;, $accumulated-string, &#39;]&#39;)}&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&#60;/xsl:stylesheet&#62;</div></ol></div></div></div></div><br>
По-хорошему надо оперировать не строками, а node-set&#39;ами, запятые тыкать в процессе вывода, а не обхода. Это тебе будет домашняя работа - переделать недолго.]]></description>
        <author>ss</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087273</guid>
        <pubDate>Wed, 29 Feb 2012 15:36:06 +0000</pubDate>
        <title>Интересная задачка по XSL</title>
        <link>https://forum.sources.ru/index.php?showtopic=352199&amp;view=findpost&amp;p=3087273</link>
        <description><![CDATA[tomboy1: Добрый день, форумчане&#33;<br>
Только зарегистрировался, встречайте новичка&#33; :thanks: <br>
<br>
Собственно, интересный, на мой взгляд, сабж.<br>
Есть 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;UTF-8&quot;?&#62;</div><div class="code_line">&#60;intermediate name=&quot;Simple&quot; package=&quot;simple&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;type wireName=&quot;point&quot; &nbsp;name=&quot;Point&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; package=&quot;simple.data&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; isAbstract=&quot;no&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; base=&quot;Element&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lat&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lat&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lon&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lon&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lur&quot; type=&quot;double&quot; isOptional=&quot;yes&quot; isArray=&quot;no&quot; wireName=&quot;lur&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;&#60;field name=&quot;lit&quot; type=&quot;double&quot; isOptional=&quot;no&quot; isArray=&quot;no&quot; wireName=&quot;lit&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isSimple=&quot;yes&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &#60;/type&#62;</div><div class="code_line">&#60;/intermediate&#62;</div></ol></div></div></div></div><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">&nbsp;- point: [lat, lon, lur, lit]</div></ol></div></div></div></div><br>
, НО&#33;&#33;&#33;<br>
Не совсем так. Строчек point должно быть столько, сколько есть всевозможных комбинаций опциональных параметров (isOptional=&quot;yes&quot;) + обязательных (isOptional=&quot;no&quot;). То есть точно вывод должен быть такой:<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">&nbsp;- point: [lat, lon, lur, lit]</div><div class="code_line">&nbsp;- point: [lon, lur, lit]</div><div class="code_line">&nbsp;- point: [lat, lur, lit]</div><div class="code_line">&nbsp;- point: [lat, lon, lit]</div><div class="code_line">&nbsp;- point: [lat, lit]</div><div class="code_line">&nbsp;- point: [lon, lit]</div><div class="code_line">&nbsp;- point: [lur, lit]</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">&#60;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&#62;</div><div class="code_line">&#60;xsl:stylesheet version=&quot;2.0&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:fn=&quot;http://www.w3.org/2005/xpath-functions&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xmlns:navbuilder=&quot;http://www.navbuilder.com&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:output method=&quot;text&quot; omit-xml-declaration=&quot;yes&quot; indent=&quot;yes&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:strip-space elements=&quot;*&quot; /&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;/&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:call-template name=&quot;recursive&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template name = &quot;recursive&quot; match=&quot;package&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:apply-templates /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;xsl:template match=&quot;type&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62; - &#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;@wireName&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;: [&#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:for-each select=&quot;field&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:sort select=&quot;@wireName&quot; data-type=&quot;text&quot; order=&quot;ascending&quot;/&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:if test=&quot;@isSimple = &#39;yes&#39;&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:choose&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:when test=&quot;@isOptional = &#39;yes&#39;&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;@wireName&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;]&#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;&amp;#xa;&#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:call-template name=&quot;recursive&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:when&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:otherwise&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:value-of select=&quot;@wireName&quot; /&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:if test=&quot;position() != last()&quot;&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;, &#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:if&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:otherwise&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:choose&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:if&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;/xsl:for-each&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;]&#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&#60;xsl:text&#62;&amp;#xa;&#60;/xsl:text&#62;</div><div class="code_line">&nbsp;&nbsp; &nbsp;&#60;/xsl:template&#62;</div><div class="code_line">&#60;/xsl:stylesheet&#62;</div></ol></div></div></div></div><br>
В этом шаблоне я заодно сортирую атрибуты в строчке.<br>
Но это все равно должным образом не работает. Кто-нибудь может помочь? Вообще, обход всевозможных вариантов средством xsl возможен? Бьюсь с этим уже неделю. Боюсь, что скоро мысли иссякнут.<br>
П.С. Сильно не пинайте, если шаблон кривой. Я в этом новичок, но к сожалению, приходится уже решать нетривиальные задачи.]]></description>
        <author>tomboy1</author>
        <category>XML, XSL, XSLT</category>
      </item>
	
      </channel>
      </rss>
	