Hi, This is relatively easy to do with XSL.
You can mirror your site structure in XML (produced dynamically or manually). Say it turns out to be something like: <folder id="f123" name="aaa" label="blah1"> <page id="p123" label="blah2"/> <folder id="f234" name="bbb" label="blah3"> <page id="p234" label="blah4"/> <page id="p235" label="blah5"/> </folder> </folder> I transform against this XML to get my context in the site (I use more attributes but this gives you the idea - if you like I can post an example site with XSL and XML). Once I have this I can create all my paths based on the relative location of the page. So I might have this defined at the top level: <xsl:key name="site_config_key" match="page | folder" use="@id"/> <xsl:variable name="folder_nodeset" select="key('site_config_key', $folder_idref)"/> <xsl:variable name="page_nodeset" select="key('site_config_key', $page_idref)"/> <xsl:variable name="relative_path_to_root"> <xsl:choose> <xsl:when test="not($root_relative='true')"> <xsl:text>../</xsl:text> <xsl:apply-templates select="$folder_nodeset" mode="rel_path_builder"/> </xsl:when> <xsl:otherwise> <xsl:text>/</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:template match="folder" mode="rel_path_builder"> <xsl:text>../</xsl:text> <xsl:apply-templates select="parent::folder" mode="rel_path_builder"/> </xsl:template> Then wherever I have a link, whether it is a tab, nav item, snail trail, pager, etc I can call a template from a page's context. For example: <xsl:template match="page" mode="nav"> <xsl:variable name="href"> <xsl:call-template name="page_path_builder"/> </xsl:variable> <div class="nav"> <a href="{$href}"> <xsl:value-of select="@label"/> </a> </div </xsl:template> .... <xsl:template name="page_path_builder"> <xsl:value-of select="$relative_path_to_root"/> <xsl:for-each select="ancestor::folder"> <xsl:text>/</xsl:text> <xsl:value-of select="@name"/> </xsl:for-each> <xsl:text>/</xsl:text> <xsl:value-of select="@id"/> <xsl:value-of select="@file_ext"/> </xsl:template> best, -Rob -----Original Message----- From: Koen Pellegrims [mailto:[EMAIL PROTECTED]] Sent: Monday, August 19, 2002 1:43 PM To: Cocoon-Users@Xml. Apache. Org Subject: Common practice: how to keep links to html-trees consistent Guys, This is something that most of you *must* have come across at one point or another, and I am just looking for the best solution (I know it is not really a Cocoon-question, but Cocoon might provide some nice and elegant solution for this...) Menu on my site that contains a link to the index-page (index.html) and links to (among others) a product-page. In the page-hierarchy, the product-pages are contained within a 'products' directory. index.html products/productA.html products/productB.html The problem arises when I display this menu on a product page, because the browser (rightly so) interprets 'index.html' as being relative to the 'products'-directory. So, whereas the link to 'index.html' is correct from the index-page, it refers to 'products/index.html' on any product page. (and even worse: a link to productA suddenly becomes a link to products/products/productsA.html) My question is simple: did any of you encounter this problem? And -of course- how did you solve it? Koen --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>