Последний элемент xsl

#
Последний элемент xsl
Подскажите пожалуйста, имея такую структуру

<group id="587" parent="586">
         <name>Плазменные панели</name>
         <description></description>
         <order>20</order>
         <indexation>0</indexation>
         <path>plazmen_panel</path>
         <fullpath>videokamery/plazmen_panel/</fullpath>
         <count_items>10</count_items>
         <count_groups>1</count_groups>
         <count_all_items>24</count_all_items>
         <count_all_groups>2</count_all_groups>
         <seo_title></seo_title>
         <seo_description></seo_description>
         <seo_keywords></seo_keywords>
         <group id="588" parent="587">
            <name>Цифровые фотоаппараты</name>
            <description></description>
            <order>30</order>
            <indexation>0</indexation>
            <path>cifrov_foto</path>
            <fullpath>videokamery/plazmen_panel/cifrov_foto/</fullpath>
            <count_items>7</count_items>
            <count_groups>1</count_groups>
            <count_all_items>14</count_all_items>
            <count_all_groups>1</count_all_groups>
            <seo_title></seo_title>
            <seo_description></seo_description>
            <seo_keywords></seo_keywords>
            <group id="590" parent="588">
               <name>Холодильники</name>
               <description></description>
               <order>40</order>
               <indexation>0</indexation>
               <path>kholodilniki</path>
               <fullpath>videokamery/plazmen_panel/cifrov_foto/kholodilniki/</fullpath>
               <count_items>7</count_items>
               <count_groups>0</count_groups>
               <count_all_items>7</count_all_items>
               <count_all_groups>0</count_all_groups>
               <seo_title></seo_title>
               <seo_description></seo_description>
               <seo_keywords></seo_keywords>
            </group>
         </group>
      </group>
   </group>

получить самую последнию группу. Делал так:
<xsl:variable name="parent_group_id_l" select="group[last()]/@id"/>

получаю не последнию группу, а следующую после активной
#
Re: Последний элемент xsl
group[position()=last()]/@id

хотя в этой структуре по 1 группе на каждом уровне вложенности, будет выбираться одна и та же группа, что с условием, что без

а последнюю по уровню вложенности можно, например, так выбрать
//group[count_all_groups=0]/@id
#
Re: Последний элемент xsl
h4mpy, Спасибо дружище, как раз то что нужно
//group[count_all_groups=0]/@id


Только вот не пойму в чем проблема имея такую структуру

   <group id="586" parent="0">
      <name>Видеокамеры</name>
      <description></description>
      <order>10</order>
      <indexation>0</indexation>
      <path>videokamery</path>
      <fullpath>videokamery/</fullpath>
      <count_items>10</count_items>
      <count_groups>1</count_groups>
      <count_all_items>34</count_all_items>
      <count_all_groups>3</count_all_groups>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
      <group id="587" parent="586">
         <name>Плазменные панели</name>
         <description></description>
         <order>20</order>
         <indexation>0</indexation>
         <path>plazmen_panel</path>
         <fullpath>videokamery/plazmen_panel/</fullpath>
         <count_items>10</count_items>
         <count_groups>1</count_groups>
         <count_all_items>24</count_all_items>
         <count_all_groups>2</count_all_groups>
         <seo_title></seo_title>
         <seo_description></seo_description>
         <seo_keywords></seo_keywords>
         <group id="588" parent="587">
            <name>Цифровые фотоаппараты</name>
            <description></description>
            <order>30</order>
            <indexation>0</indexation>
            <path>cifrov_foto</path>
            <fullpath>videokamery/plazmen_panel/cifrov_foto/</fullpath>
            <count_items>7</count_items>
            <count_groups>1</count_groups>
            <count_all_items>14</count_all_items>
            <count_all_groups>1</count_all_groups>
            <seo_title></seo_title>
            <seo_description></seo_description>
            <seo_keywords></seo_keywords>
            <group id="590" parent="588">
               <name>Холодильники</name>
               <description></description>
               <order>40</order>
               <indexation>0</indexation>
               <path>kholodilniki</path>
               <fullpath>videokamery/plazmen_panel/cifrov_foto/kholodilniki/</fullpath>
               <count_items>7</count_items>
               <count_groups>0</count_groups>
               <count_all_items>7</count_all_items>
               <count_all_groups>0</count_all_groups>
               <seo_title></seo_title>
               <seo_description></seo_description>
               <seo_keywords></seo_keywords>
            </group>
         </group>
      </group>
   </group>
   <group id="591" parent="0">
      <name>Плиты</name>
      <description></description>
      <order>50</order>
      <indexation>0</indexation>
      <path>plity</path>
      <fullpath>plity/</fullpath>
      <count_items>7</count_items>
      <count_groups>0</count_groups>
      <count_all_items>7</count_all_items>
      <count_all_groups>0</count_all_groups>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
   </group>
   <group id="592" parent="0">
      <name>Посудомоечные машины</name>
      <description></description>
      <order>60</order>
      <indexation>0</indexation>
      <path>posudomoichnye_mashiny</path>
      <fullpath>posudomoichnye_mashiny/</fullpath>
      <count_items>7</count_items>
      <count_groups>0</count_groups>
      <count_all_items>7</count_all_items>
      <count_all_groups>0</count_all_groups>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
   </group>
   <group id="589" parent="0">
      <name>MP3-плееры</name>
      <description></description>
      <order>70</order>
      <indexation>0</indexation>
      <path>mp3</path>
      <fullpath>mp3/</fullpath>
      <count_items>7</count_items>
      <count_groups>1</count_groups>
      <count_all_items>14</count_all_items>
      <count_all_groups>1</count_all_groups>
      <seo_title></seo_title>
      <seo_description></seo_description>
      <seo_keywords></seo_keywords>
      <group id="593" parent="589">
         <name>Обогреватели</name>
         <description></description>
         <order>80</order>
         <indexation>0</indexation>
         <path>obogrevateli</path>
         <fullpath>mp3/obogrevateli/</fullpath>
         <count_items>7</count_items>
         <count_groups>0</count_groups>
         <count_all_items>7</count_all_items>
         <count_all_groups>0</count_all_groups>
         <seo_title></seo_title>
         <seo_description></seo_description>
         <seo_keywords></seo_keywords>
      </group>
   </group>
</shop>


в шаблоне

<xsl:template match="group">
    <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
      <xsl:variable name="parent_group_id" select="/shop/thisgroup"/>
      <xsl:variable name="parent_group_id_l" select="//group[count_all_groups=0]"/>

<a href="{/shop/path}{fullpath}" onClick="return show_hide_menu('{@id}');" alt="{$parent_group_id_l}">      
               <xsl:value-of disable-output-escaping="yes" select="name"/>
         </a>

<xsl:if test="group">
<xsl:apply-templates select="group">
                     <xsl:with-param name="current_position" select="$current_position + 1"/>
                  </xsl:apply-templates>

</xsl:if>
</xsl:template>

проходя по всем элементам везде получаю холодильники, а мне надо, чтобы проходя по дереву элементов необходимо было получить самый последний по уровню вложености элемент группы
#
Re: Последний элемент xsl
тогда
.//group[count_all_groups=0]/@id

если последнюю в текущем дереве
#
Re: Последний элемент xsl
Большое человеческое спасибо!
Авторизация