xsl-list
[Top] [All Lists]

Re: finding nodes

2003-03-16 07:25:41
thanks a lot - it works

cheers
jm

On Sat, 15 Mar 2003 18:47:39 -0000
Americo Albuquerque <aalbuquerque(_at_)viseu(_dot_)ipiaget(_dot_)pt> wrote:

Hi.

-----Mensagem original-----
De: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] Em nome de 
jm
Enviada: sabado, 15 de Marco de 2003 15:14
Para: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Assunto: [xsl] finding nodes

(...)
in my xsl-document I have the following parameter:
(later given via GET-request-params/Cocoon)

<xsl:param name="goto_page" 
select="SECTION_1/SUB_SECTION_1_1/SUB_SUB_SECTION_1_1_1"/>

an now I want to enter the node specified by the path given 
in $goto_page. this path 
has no restriction in depth.


If goto_page is a nodeset then you just need to do
<xsl:apply-templates select="$goto_page"/>

If it is a string then you need an xxx:evaluate function (xxx depends on
your processor)

You could also use this templates, but they split the path:

 <xsl:param name="goto_page"
select="'SECTION_1/SUB_SECTION_1_1/SUB_SUB_SECTION_1_1_1'"/>
 
 <xsl:template match="pages">
  <xsl:param name="page" select="substring-before($goto_page,'/')"/>
  <xsl:apply-templates select="page[(_at_)id=$page]">
   <xsl:with-param name="passed" select="$page"/>
  </xsl:apply-templates>
 </xsl:template>
 
 <xsl:template match="page">
  <xsl:param name="passed" select="''"/>
  <xsl:param name="next"
select="substring-before(concat(substring($goto_page,string-length($pass
ed)+2),'/'),'/')"/>
  <xsl:choose>
   <xsl:when test="not($next)">
   <!-- page found -->
   <xsl:comment> Just arrived to page </xsl:comment>
   <xsl:copy-of select="."/>
   </xsl:when>
   <xsl:otherwise>
   <!-- continue the searching -->
   <xsl:apply-templates select="page[(_at_)id=$next]">
    <xsl:with-param name="passed" select="concat($passed,'/',$next)"/>
   </xsl:apply-templates>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>