Дата выводится не так как нужно!
Сначала XML
<?xml version="1.0" encoding="windows-1251"?>
<document>
<site_user_id>0</site_user_id>
<ОтображатьСсылкуНаАрхив>1</ОтображатьСсылкуНаАрхив>
<ОтображатьСсылкиНаСледующиеСтраницы>0</ОтображатьСсылкиНаСледующиеСтраницы>
<blocks id="1">
<name>Обучение</name>
<description><p><a href="/guestbook/"></a></p></description>
<url>/news/</url>
<access>0</access>
<parent_group_id>0</parent_group_id>
<count_items>19</count_items>
<count_items_on_page>3</count_items_on_page>
<count_all_items>19</count_all_items>
<count_groups>0</count_groups>
<count_all_groups>0</count_all_groups>
<tags>
</tags>
<items>
<count_items>19</count_items>
<current_page>0</current_page>
<items_on_page>4</items_on_page>
<item id="95" group_id="0">
<item_date>09.Ноября.2008</item_date>
<item_datetime>09.Ноября.2008 10:48:03</item_datetime>
<item_time>10:48:03</item_time>
<item_putoff_date>09.Ноября.2008 10:48:03</item_putoff_date>
<item_putend_date>00.00.0000 00:00:00</item_putend_date>
<item_name>Лето - время подарков! Только у нас этим летом Вы сможете получить скидки на обучение до 40%!</item_name>
<item_description>А для&nbsp;оформивших абонемент в&nbsp;июне, мы&nbsp;дарим до&nbsp;6 дополнительных занятий.</item_description>
<part count="1">0</part>
<item_text>Приглашайте к&nbsp;нам&nbsp;своих друзей, и&nbsp;Вас&nbsp;ждет новый сюрприз! Вы&nbsp;получаете бонус 300р за&nbsp;каждого приглашенного человека, а&nbsp;Ваши друзья скидку 5%<span style="margin-right: 0.3em"> </span> <span style="margin-left: -0.3em">(для</span> клиентов)</item_text>
<item_image width="0" height="0"></item_image>
<item_small_image width="0" height="0"></item_small_image>
<item_status>1</item_status>
<item_seo_title></item_seo_title>
<item_seo_description></item_seo_description>
<item_seo_keywords></item_seo_keywords>
<item_access>-1</item_access>
<item_path>/news/95/</item_path>
<item_path_field>95</item_path_field>
<item_show_count>6</item_show_count>
<item_blog_accessibility>0</item_blog_accessibility>
<item_blog_show_comments_mode>0</item_blog_show_comments_mode>
<item_blog_add_comments_mode>0</item_blog_add_comments_mode>
<item_propertys>
<item_property type="WYSIWYG" xml_name="text1_text" parent_id="0" id="8">
<property_id>158</property_id>
<property_xml_name>text1_text</property_xml_name>
<property_name>Текст1-тестовое свойство</property_name>
<property_order>20</property_order>
<text1_text></text1_text>
<value></value>
</item_property>
</item_propertys>
<item_comments>
<count_comments>0</count_comments>
<grade_sum>0</grade_sum>
<grade_count>0</grade_count>
<average_grade>0</average_grade>
</item_comments>
</item>
</items>
</blocks>
</document>
XSL стандартный из шаблона:
<div class="date">
<xsl:value-of disable-output-escaping="yes" select="item_date"/>
</div>
я выделил жирным в XML то что по идее меня должно интересовать, но проблема в том что я пока не разобрался как управлять этими параметрами. и как происходит разбивка.
<?xml version="1.0" encoding="windows-1251"?>
<document>
<site_user_id>0</site_user_id>
<ОтображатьСсылкуНаАрхив>1</ОтображатьСсылкуНаАрхив>
<ОтображатьСсылкиНаСледующиеСтраницы>0</ОтображатьСсылкиНаСледующиеСтраницы>
<blocks id="1">
<name>Обучение</name>
<description><p><a href="/guestbook/"></a></p></description>
<url>/news/</url>
<access>0</access>
<parent_group_id>0</parent_group_id>
<count_items>19</count_items>
<count_items_on_page>3</count_items_on_page>
<count_all_items>19</count_all_items>
<count_groups>0</count_groups>
<count_all_groups>0</count_all_groups>
<tags>
</tags>
<items>
<count_items>19</count_items>
<current_page>0</current_page>
<items_on_page>4</items_on_page>
<item id="95" group_id="0">
<item_date>09.Ноября.2008</item_date>
<item_datetime>09.Ноября.2008 10:48:03</item_datetime>
<item_time>10:48:03</item_time>
<item_putoff_date>09.Ноября.2008 10:48:03</item_putoff_date>
<item_putend_date>00.00.0000 00:00:00</item_putend_date>
<item_name>Лето - время подарков! Только у нас этим летом Вы сможете получить скидки на обучение до 40%!</item_name>
<item_description>А для&nbsp;оформивших абонемент в&nbsp;июне, мы&nbsp;дарим до&nbsp;6 дополнительных занятий.</item_description>
<part count="1">0</part>
<item_text>Приглашайте к&nbsp;нам&nbsp;своих друзей, и&nbsp;Вас&nbsp;ждет новый сюрприз! Вы&nbsp;получаете бонус 300р за&nbsp;каждого приглашенного человека, а&nbsp;Ваши друзья скидку 5%<span style="margin-right: 0.3em"> </span> <span style="margin-left: -0.3em">(для</span> клиентов)</item_text>
<item_image width="0" height="0"></item_image>
<item_small_image width="0" height="0"></item_small_image>
<item_status>1</item_status>
<item_seo_title></item_seo_title>
<item_seo_description></item_seo_description>
<item_seo_keywords></item_seo_keywords>
<item_access>-1</item_access>
<item_path>/news/95/</item_path>
<item_path_field>95</item_path_field>
<item_show_count>6</item_show_count>
<item_blog_accessibility>0</item_blog_accessibility>
<item_blog_show_comments_mode>0</item_blog_show_comments_mode>
<item_blog_add_comments_mode>0</item_blog_add_comments_mode>
<item_propertys>
<item_property type="WYSIWYG" xml_name="text1_text" parent_id="0" id="8">
<property_id>158</property_id>
<property_xml_name>text1_text</property_xml_name>
<property_name>Текст1-тестовое свойство</property_name>
<property_order>20</property_order>
<text1_text></text1_text>
<value></value>
</item_property>
</item_propertys>
<item_comments>
<count_comments>0</count_comments>
<grade_sum>0</grade_sum>
<grade_count>0</grade_count>
<average_grade>0</average_grade>
</item_comments>
</item>
</items>
</blocks>
</document>
XSL стандартный из шаблона:
<div class="date">
<xsl:value-of disable-output-escaping="yes" select="item_date"/>
</div>
я выделил жирным в XML то что по идее меня должно интересовать, но проблема в том что я пока не разобрался как управлять этими параметрами. и как происходит разбивка.
BarS
Вот XSL-шаблон с примером разделения даты на день, месяц и год:
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:template match="/">
<xsl:apply-templates select="/document"/>
</xsl:template>
<xsl:template match="/document">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="blocks/parent_group_id"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:if test="blocks/parent_group_id = 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="blocks/name"/>
</h1>
<!-- Описание выводится при отсутствии фильтрации по тэгам -->
<xsl:if test="count(blocks/tags/tag) = 0">
<xsl:value-of disable-output-escaping="yes" select="blocks/description"/>
</xsl:if>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:if test="blocks/parent_group_id != 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/>
</h1>
<!-- Описание выводим только на первой странице -->
<xsl:if test="blocks/items/current_page = 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/description"/>
</xsl:if>
<!-- Путь к группе -->
<p>
<xsl:apply-templates select=".//group[@id=$parent_group_id]" mode="goup_path"/>
</p>
</xsl:if>
<!-- Обработка выбранных тэгов -->
<xsl:if test="count(blocks/selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="blocks/selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(blocks/selected_tags/tag) = 0 and count(.//group[@parent_id=$parent_group_id]) > 0">
<ul class="news_group">
<xsl:apply-templates select=".//group[@parent_id=$parent_group_id]" mode="groups"/>
</ul>
</xsl:if>
<!-- Отображение записи информационной системы -->
<xsl:apply-templates select="blocks/items/item[item_status=1]"/>
<!-- Строка ссылок на другие страницы информационной системы -->
<xsl:if test="ОтображатьСсылкиНаСледующиеСтраницы=1">
<p>
<!-- Ссылка, для которой дописываются суффиксы page-XX/ -->
<xsl:variable name="link">
<xsl:value-of select="/document/blocks/url"/>
<xsl:if test="$parent_group_id != 0">
<xsl:value-of select="/document/blocks//group[@id = $parent_group_id]/fullpath"/>
</xsl:if>
</xsl:variable>
<xsl:call-template name="for">
<xsl:with-param name="link" select="$link"/>
<xsl:with-param name="items_on_page" select="blocks/items/items_on_page"/>
<xsl:with-param name="current_page" select="blocks/items/current_page"/>
<xsl:with-param name="count_items" select="blocks/items/count_items"/>
<xsl:with-param name="visible_pages">5</xsl:with-param>
</xsl:call-template>
</p>
</xsl:if>
<xsl:if test="count(blocks/properties_groups_dir) and blocks/parent_group_id != 0">
<div style="margin: 10px 0px;">
<h2>Атрибуты группы инфоэлементов</h2>
<xsl:if test="count(blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = 0])">
<table border="0">
<xsl:apply-templates select="blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = 0]"/>
</table>
</xsl:if>
<xsl:apply-templates select="blocks/properties_groups_dir"/>
</div>
</xsl:if>
<div style="clear: both"></div>
<!-- Rss -->
<div class="rss_4_ie"></div>
<a href="{blocks/url}rss/">
<img src="/images/rss/rss_2.0.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px"/>
</a>
<a href="{blocks/url}rss/">RSS</a>
<xsl:if test="ОтображатьСсылкуНаАрхив=1">
<div class="archives_4_ie"></div>
<a href="{blocks/url}">
<img src="/images/archives.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px"/>
</a>
<a href="{blocks/url}">Архив "<xsl:value-of disable-output-escaping="yes" select="blocks/name"/>"</a>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<tr>
<td style="padding: 5px" bgcolor="#E5DFDA">
<b><xsl:value-of select="name"/></b>
</td>
<td style="padding: 5px" bgcolor="#E5DFDA">
<xsl:choose>
<xsl:when test="type = 1">
<a href="{file_path}">Скачать файл</a>
</xsl:when>
<xsl:when test="type = 7">
<xsl:choose>
<xsl:when test="value = 1">
<input type="checkbox" checked="" disabled="" />
</xsl:when>
<xsl:otherwise>
<input type="checkbox" disabled="" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
<xsl:template match="group" mode="goup_path">
<xsl:variable name="parent_id" select="@parent_id"/>
<xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
<xsl:if test="@parent_id=0">
<a href="{/document/blocks/url}">
<xsl:value-of disable-output-escaping="yes" select="/document/blocks/name"/>
</a>
</xsl:if>
<span class="path_arrow">→</span>
<a href="{/document/blocks/url}{fullpath}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:template>
<!-- Шаблон выводит группы свойств для группы инфосистемы -->
<xsl:template match="properties_groups_dir">
<p><b><xsl:value-of select="information_propertys_groups_dir_name"/></b></p>
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(//blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = $dir_id])">
<table border="0">
<xsl:apply-templates select="//blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(properties_groups_dir)">
<blockquote>
<xsl:apply-templates select="properties_groups_dir"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Шаблон выводит ссылки подгруппы информационного элемента -->
<xsl:template match="group" mode="groups">
<li>
<xsl:if test="small_image!=''">
<a href="{/document/blocks/url}{fullpath}" target="_blank">
<img src="{small_image}"/>
</a> </xsl:if>
<a href="{/document/blocks/url}{fullpath}">
<b>
<xsl:value-of disable-output-escaping="yes" select="name"/>
</b>
</a> <span style="color: #cacaca">(<xsl:value-of select="count_all_items"/>)</span></li>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="blocks/items/item">
<div style="margin-right: 10px; margin-bottom: 20px;">
<!-- Дата время -->
<span class="date">
Исходная дата: <xsl:value-of disable-output-escaping="yes" select="item_date"/>
</span>
<!-- Переменная для хранения исходной даты -->
<xsl:variable name="item_date" select="item_date"/>
<!-- Переменная содержащая значение дня -->
<xsl:variable name="item_day" select="substring($item_date, 1, 2)"/>
<!-- Переменная содержащая значение месяца -->
<xsl:variable name="item_month" select="substring-before(substring-after(item_date,concat($item_day, '.')), '.')"/>
<!-- Переменная содержащая значение года -->
<xsl:variable name="item_year" select="substring-after(item_date, concat($item_month, '.'))"/>
<p>Дата: <xsl:value-of disable-output-escaping="yes" select="$item_day" /> </p>
<p>Месяц: <xsl:value-of disable-output-escaping="yes" select="$item_month" /> </p>
<p>Год: <xsl:value-of disable-output-escaping="yes" select="$item_year" /> </p>
<!-- Название -->
<p class="news_title">
<a href="{item_path}">
<xsl:value-of disable-output-escaping="yes" select="item_name"/>
</a>
</p>
<!-- Изображение для информационного элемента (если есть) -->
<xsl:if test="item_small_image!=''">
<a href="{item_path}" class="news_title">
<img src="{item_small_image}" class="news_img" alt="" align="left"/>
</a>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="item_description"/>
<xsl:if test="count(tags/tag) > 0">
<p class="tags">
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<xsl:if test="count(site_user) > 0">
<p>
<img src="/hostcmsfiles/images/user.gif" style="margin: 0px 5px -4px 0px"/>
<strong>
<a href="/users/info/{site_user/site_user_login}/" class="c_u_l">
<xsl:value-of select="site_user/site_user_login"/>
</a>
</strong>
<xsl:if test="count(item_comments/comment) > 0">,
<img src="/hostcmsfiles/images/comments.gif" style="margin: 0px 5px -4px 0px"/>
<a href="{item_path}#comments">
<xsl:value-of select="count(item_comments//comment)"/> <xsl:call-template name="declension">
<xsl:with-param name="number" select="count(item_comments//comment)"/></xsl:call-template></a>
</xsl:if>
</p>
</xsl:if>
<div style="clear: both;"></div>
</div>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tags/tag">
<a href="{/document/blocks/url}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> </xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="prefix">page</xsl:param>
<xsl:param name="link"/>
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="$count_items div $items_on_page"/>
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/document/blocks/parent_group_id"/>
<!-- Считаем количество выводимых ссылок перед текущим элементом -->
<xsl:variable name="pre_count_page">
<xsl:choose>
<xsl:when test="$current_page > ($n - (round($visible_pages div 2) - 1))">
<xsl:value-of select="$visible_pages - ($n - $current_page)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($visible_pages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Считаем количество выводимых ссылок после текущего элемента -->
<xsl:variable name="post_count_page">
<xsl:choose>
<xsl:when test="0 > $current_page - (round($visible_pages div 2) - 1)">
<xsl:value-of select="$visible_pages - $current_page - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="round($visible_pages div 2) = ($visible_pages div 2)">
<xsl:value-of select="$visible_pages div 2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($visible_pages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$i = 0 and $current_page != 0">
<span class="ctrl">
← Ctrl
</span>
</xsl:if>
<xsl:if test="$i >= $n and ($n - 1) > $current_page">
<span class="ctrl">
Ctrl →
</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and $n > $i">
<!-- Определяем адрес тэга -->
<xsl:variable name="tag_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/document/blocks/selected_tags/tag) != 0">tag/<xsl:value-of select="/document/blocks/selected_tags/tag/tag_path_name"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">
<xsl:value-of select="$prefix"/>-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = 0">
<a href="{$link}" class="page_link" style="text-decoration: none;">←</a>
</xsl:if>
<xsl:choose>
<xsl:when test="$i >= ($current_page - $pre_count_page) and ($current_page + $post_count_page) >= $i">
<!-- Выводим ссылки на видимые страницы -->
<a href="{$link}{$tag_link}{$number_link}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= $n and $n > ($current_page + 1 + $post_count_page)">
<xsl:choose>
<xsl:when test="$n > round($n)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{$link}{$prefix}-{round($n+1)}/" class="page_link" style="text-decoration: none;">→</a>
</xsl:when>
<xsl:otherwise>
<a href="{$link}{$prefix}-{round($n)}/" class="page_link" style="text-decoration: none;">→</a>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$link}{$tag_link}{$prev_number_link}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{$link}{$tag_link}page-{$current_page+2}/" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_page">
<span class="current">
<xsl:value-of select="$i+1"/>
</span>
</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="prefix" select="$prefix"/>
<xsl:with-param name="link" select="$link"/>
<xsl:with-param name="items_on_page" select="$items_on_page"/>
<xsl:with-param name="current_page" select="$current_page"/>
<xsl:with-param name="count_items" select="$count_items"/>
<xsl:with-param name="visible_pages" select="$visible_pages"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Склонение после числительных -->
<xsl:template name="declension">
<xsl:param name="number" select="number"/>
<!-- Именительный падеж -->
<xsl:variable name="nominative">
<xsl:text>комментарий</xsl:text>
</xsl:variable>
<!-- Родительный падеж, единственное число -->
<xsl:variable name="genitive_singular">
<xsl:text>комментария</xsl:text>
</xsl:variable>
<xsl:variable name="genitive_plural">
<xsl:text>комментариев</xsl:text>
</xsl:variable>
<xsl:variable name="last_digit">
<xsl:value-of select="$number mod 10"/>
</xsl:variable>
<xsl:variable name="last_two_digits">
<xsl:value-of select="$number mod 100"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$last_digit = 1 and $last_two_digits != 11">
<xsl:value-of select="$nominative"/>
</xsl:when>
<xsl:when test="$last_digit = 2 and $last_two_digits != 12
or $last_digit = 3 and $last_two_digits != 13
or $last_digit = 4 and $last_two_digits != 14">
<xsl:value-of select="$genitive_singular"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$genitive_plural"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:template match="/">
<xsl:apply-templates select="/document"/>
</xsl:template>
<xsl:template match="/document">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="blocks/parent_group_id"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:if test="blocks/parent_group_id = 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="blocks/name"/>
</h1>
<!-- Описание выводится при отсутствии фильтрации по тэгам -->
<xsl:if test="count(blocks/tags/tag) = 0">
<xsl:value-of disable-output-escaping="yes" select="blocks/description"/>
</xsl:if>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:if test="blocks/parent_group_id != 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/>
</h1>
<!-- Описание выводим только на первой странице -->
<xsl:if test="blocks/items/current_page = 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/description"/>
</xsl:if>
<!-- Путь к группе -->
<p>
<xsl:apply-templates select=".//group[@id=$parent_group_id]" mode="goup_path"/>
</p>
</xsl:if>
<!-- Обработка выбранных тэгов -->
<xsl:if test="count(blocks/selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="blocks/selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(blocks/selected_tags/tag) = 0 and count(.//group[@parent_id=$parent_group_id]) > 0">
<ul class="news_group">
<xsl:apply-templates select=".//group[@parent_id=$parent_group_id]" mode="groups"/>
</ul>
</xsl:if>
<!-- Отображение записи информационной системы -->
<xsl:apply-templates select="blocks/items/item[item_status=1]"/>
<!-- Строка ссылок на другие страницы информационной системы -->
<xsl:if test="ОтображатьСсылкиНаСледующиеСтраницы=1">
<p>
<!-- Ссылка, для которой дописываются суффиксы page-XX/ -->
<xsl:variable name="link">
<xsl:value-of select="/document/blocks/url"/>
<xsl:if test="$parent_group_id != 0">
<xsl:value-of select="/document/blocks//group[@id = $parent_group_id]/fullpath"/>
</xsl:if>
</xsl:variable>
<xsl:call-template name="for">
<xsl:with-param name="link" select="$link"/>
<xsl:with-param name="items_on_page" select="blocks/items/items_on_page"/>
<xsl:with-param name="current_page" select="blocks/items/current_page"/>
<xsl:with-param name="count_items" select="blocks/items/count_items"/>
<xsl:with-param name="visible_pages">5</xsl:with-param>
</xsl:call-template>
</p>
</xsl:if>
<xsl:if test="count(blocks/properties_groups_dir) and blocks/parent_group_id != 0">
<div style="margin: 10px 0px;">
<h2>Атрибуты группы инфоэлементов</h2>
<xsl:if test="count(blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = 0])">
<table border="0">
<xsl:apply-templates select="blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = 0]"/>
</table>
</xsl:if>
<xsl:apply-templates select="blocks/properties_groups_dir"/>
</div>
</xsl:if>
<div style="clear: both"></div>
<!-- Rss -->
<div class="rss_4_ie"></div>
<a href="{blocks/url}rss/">
<img src="/images/rss/rss_2.0.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px"/>
</a>
<a href="{blocks/url}rss/">RSS</a>
<xsl:if test="ОтображатьСсылкуНаАрхив=1">
<div class="archives_4_ie"></div>
<a href="{blocks/url}">
<img src="/images/archives.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px"/>
</a>
<a href="{blocks/url}">Архив "<xsl:value-of disable-output-escaping="yes" select="blocks/name"/>"</a>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<tr>
<td style="padding: 5px" bgcolor="#E5DFDA">
<b><xsl:value-of select="name"/></b>
</td>
<td style="padding: 5px" bgcolor="#E5DFDA">
<xsl:choose>
<xsl:when test="type = 1">
<a href="{file_path}">Скачать файл</a>
</xsl:when>
<xsl:when test="type = 7">
<xsl:choose>
<xsl:when test="value = 1">
<input type="checkbox" checked="" disabled="" />
</xsl:when>
<xsl:otherwise>
<input type="checkbox" disabled="" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
<xsl:template match="group" mode="goup_path">
<xsl:variable name="parent_id" select="@parent_id"/>
<xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
<xsl:if test="@parent_id=0">
<a href="{/document/blocks/url}">
<xsl:value-of disable-output-escaping="yes" select="/document/blocks/name"/>
</a>
</xsl:if>
<span class="path_arrow">→</span>
<a href="{/document/blocks/url}{fullpath}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:template>
<!-- Шаблон выводит группы свойств для группы инфосистемы -->
<xsl:template match="properties_groups_dir">
<p><b><xsl:value-of select="information_propertys_groups_dir_name"/></b></p>
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(//blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = $dir_id])">
<table border="0">
<xsl:apply-templates select="//blocks/group[@id = //blocks/parent_group_id]/propertys/property[@parent_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(properties_groups_dir)">
<blockquote>
<xsl:apply-templates select="properties_groups_dir"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Шаблон выводит ссылки подгруппы информационного элемента -->
<xsl:template match="group" mode="groups">
<li>
<xsl:if test="small_image!=''">
<a href="{/document/blocks/url}{fullpath}" target="_blank">
<img src="{small_image}"/>
</a> </xsl:if>
<a href="{/document/blocks/url}{fullpath}">
<b>
<xsl:value-of disable-output-escaping="yes" select="name"/>
</b>
</a> <span style="color: #cacaca">(<xsl:value-of select="count_all_items"/>)</span></li>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="blocks/items/item">
<div style="margin-right: 10px; margin-bottom: 20px;">
<!-- Дата время -->
<span class="date">
Исходная дата: <xsl:value-of disable-output-escaping="yes" select="item_date"/>
</span>
<!-- Переменная для хранения исходной даты -->
<xsl:variable name="item_date" select="item_date"/>
<!-- Переменная содержащая значение дня -->
<xsl:variable name="item_day" select="substring($item_date, 1, 2)"/>
<!-- Переменная содержащая значение месяца -->
<xsl:variable name="item_month" select="substring-before(substring-after(item_date,concat($item_day, '.')), '.')"/>
<!-- Переменная содержащая значение года -->
<xsl:variable name="item_year" select="substring-after(item_date, concat($item_month, '.'))"/>
<p>Дата: <xsl:value-of disable-output-escaping="yes" select="$item_day" /> </p>
<p>Месяц: <xsl:value-of disable-output-escaping="yes" select="$item_month" /> </p>
<p>Год: <xsl:value-of disable-output-escaping="yes" select="$item_year" /> </p>
<!-- Название -->
<p class="news_title">
<a href="{item_path}">
<xsl:value-of disable-output-escaping="yes" select="item_name"/>
</a>
</p>
<!-- Изображение для информационного элемента (если есть) -->
<xsl:if test="item_small_image!=''">
<a href="{item_path}" class="news_title">
<img src="{item_small_image}" class="news_img" alt="" align="left"/>
</a>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="item_description"/>
<xsl:if test="count(tags/tag) > 0">
<p class="tags">
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<xsl:if test="count(site_user) > 0">
<p>
<img src="/hostcmsfiles/images/user.gif" style="margin: 0px 5px -4px 0px"/>
<strong>
<a href="/users/info/{site_user/site_user_login}/" class="c_u_l">
<xsl:value-of select="site_user/site_user_login"/>
</a>
</strong>
<xsl:if test="count(item_comments/comment) > 0">,
<img src="/hostcmsfiles/images/comments.gif" style="margin: 0px 5px -4px 0px"/>
<a href="{item_path}#comments">
<xsl:value-of select="count(item_comments//comment)"/> <xsl:call-template name="declension">
<xsl:with-param name="number" select="count(item_comments//comment)"/></xsl:call-template></a>
</xsl:if>
</p>
</xsl:if>
<div style="clear: both;"></div>
</div>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tags/tag">
<a href="{/document/blocks/url}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> </xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="prefix">page</xsl:param>
<xsl:param name="link"/>
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="$count_items div $items_on_page"/>
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/document/blocks/parent_group_id"/>
<!-- Считаем количество выводимых ссылок перед текущим элементом -->
<xsl:variable name="pre_count_page">
<xsl:choose>
<xsl:when test="$current_page > ($n - (round($visible_pages div 2) - 1))">
<xsl:value-of select="$visible_pages - ($n - $current_page)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($visible_pages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Считаем количество выводимых ссылок после текущего элемента -->
<xsl:variable name="post_count_page">
<xsl:choose>
<xsl:when test="0 > $current_page - (round($visible_pages div 2) - 1)">
<xsl:value-of select="$visible_pages - $current_page - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="round($visible_pages div 2) = ($visible_pages div 2)">
<xsl:value-of select="$visible_pages div 2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($visible_pages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$i = 0 and $current_page != 0">
<span class="ctrl">
← Ctrl
</span>
</xsl:if>
<xsl:if test="$i >= $n and ($n - 1) > $current_page">
<span class="ctrl">
Ctrl →
</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and $n > $i">
<!-- Определяем адрес тэга -->
<xsl:variable name="tag_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/document/blocks/selected_tags/tag) != 0">tag/<xsl:value-of select="/document/blocks/selected_tags/tag/tag_path_name"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">
<xsl:value-of select="$prefix"/>-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = 0">
<a href="{$link}" class="page_link" style="text-decoration: none;">←</a>
</xsl:if>
<xsl:choose>
<xsl:when test="$i >= ($current_page - $pre_count_page) and ($current_page + $post_count_page) >= $i">
<!-- Выводим ссылки на видимые страницы -->
<a href="{$link}{$tag_link}{$number_link}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= $n and $n > ($current_page + 1 + $post_count_page)">
<xsl:choose>
<xsl:when test="$n > round($n)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{$link}{$prefix}-{round($n+1)}/" class="page_link" style="text-decoration: none;">→</a>
</xsl:when>
<xsl:otherwise>
<a href="{$link}{$prefix}-{round($n)}/" class="page_link" style="text-decoration: none;">→</a>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$link}{$tag_link}{$prev_number_link}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{$link}{$tag_link}page-{$current_page+2}/" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_page">
<span class="current">
<xsl:value-of select="$i+1"/>
</span>
</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="prefix" select="$prefix"/>
<xsl:with-param name="link" select="$link"/>
<xsl:with-param name="items_on_page" select="$items_on_page"/>
<xsl:with-param name="current_page" select="$current_page"/>
<xsl:with-param name="count_items" select="$count_items"/>
<xsl:with-param name="visible_pages" select="$visible_pages"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Склонение после числительных -->
<xsl:template name="declension">
<xsl:param name="number" select="number"/>
<!-- Именительный падеж -->
<xsl:variable name="nominative">
<xsl:text>комментарий</xsl:text>
</xsl:variable>
<!-- Родительный падеж, единственное число -->
<xsl:variable name="genitive_singular">
<xsl:text>комментария</xsl:text>
</xsl:variable>
<xsl:variable name="genitive_plural">
<xsl:text>комментариев</xsl:text>
</xsl:variable>
<xsl:variable name="last_digit">
<xsl:value-of select="$number mod 10"/>
</xsl:variable>
<xsl:variable name="last_two_digits">
<xsl:value-of select="$number mod 100"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$last_digit = 1 and $last_two_digits != 11">
<xsl:value-of select="$nominative"/>
</xsl:when>
<xsl:when test="$last_digit = 2 and $last_two_digits != 12
or $last_digit = 3 and $last_two_digits != 13
or $last_digit = 4 and $last_two_digits != 14">
<xsl:value-of select="$genitive_singular"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$genitive_plural"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Авторизация
Спасибо громадное, это как раз то что нужно..