[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Process Children Before Parents Recursively!

Subject: Re: [xsl] Process Children Before Parents Recursively!
From: Stuart Jansen <sjansen@xxxxxxxxxxxx>
Date: Mon, 18 Jul 2005 11:18:09 -0600

On Mon, 2005-07-18 at 17:26 +1000, Adam J Knight wrote:
> I would really appreciate if some one can demonstrate how I would alter the
> logic of this style sheet, so that all child menus are generated before
> their parents (recursively). Thus I should be error free.
> I would appreciate any help!!!!!!!!!!

The trick is to make the recursive call before producing any output.
There's alot that could be done to clean up your stylesheet, but with
minimal changes to it, here's a version that should do what you want:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.1"

  <xsl:param name="url"/>
  <xsl:output method="html" encoding="ISO-8859-1"/>

  <xsl:template match="/dfile">
  <script language="javascript">
    function loadMenus() {
        <xsl:call-template name="sub_menus"/>
  <script language="JavaScript">loadMenus();</script>

  <xsl:template name="sub_menus">
    <xsl:for-each select="df_data_row">
        <xsl:if test="child::df_data_row">
        <xsl:call-template name="sub_menus"/>
        window.mnu_<xsl:value-of select="document_id"/> = new
Menu('<xsl:value-of select="name"/>','Verdana, Arial, Helvetica,

<xsl:call-template name="menu_items"/>

<xsl:template name="menu_items">
  <xsl:for-each select="child::df_data_row">
        <xsl:when test="child::df_data_row">
select="document_id"/>,"document.location.href='index.php?pg=<xsl:value-of select="document_id"/>'");
select="name"/>", "document.location.href='index.php?pg=<xsl:value-of
select="document_id"/>'" );


Stuart Jansen <sjansen@xxxxxxxxxxxx>
Guru Labs, L.C.

Current Thread