Altova Mailing List Archives


RE: [xsl] finding nodes

From: Americo Albuquerque <aalbuquerque@---------------->
To:
Date: 3/15/2003 8:45:00 AM
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: [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[@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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.