Hi.
> -----Mensagem original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Em nome de jm
> Enviada: sabado, 15 de Marco de 2003 15:14
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Assunto: 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[@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[@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
| Current Thread |
- finding nodes
- jm - Sat, 15 Mar 2003 11:05:17 -0500 (EST)
- Americo Albuquerque - Sat, 15 Mar 2003 13:45:14 -0500 (EST) <=
- jm - Sun, 16 Mar 2003 09:17:02 -0500 (EST)
|
|