[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: finding nodes

Subject: RE: finding nodes
From: Americo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Sat, 15 Mar 2003 18:47:39 -0000
RE:  finding nodes
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)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.