Re: [xsl] Dynamic Menu Using XSL

Subject: Re: [xsl] Dynamic Menu Using XSL
From: Brant Schroeder <brantschr@xxxxxxxxx>
Date: Mon, 11 Dec 2006 14:59:00 -0800 (PST)
Micheal,
   I already know how I would like the HTML to look.  The XSLT is
currently applying the HTML format I would like to have.  I would like to
however construct the HTML via the XSLT depending on the page selected.
Example of Home being selected

<ul>
<li class="selected"><a
href="default.aspx">Home</a></li>
<li><a
href="training.aspx">Training</a></li>
<li><a href="othertraining.aspx">Other
Training</a></li>
<li><a href="aboutus.aspx">About Us</a></li>
</ul>

Example
of Training being selected

<ul>

<li><a href="default.aspx">Home</a></li>
<li class="selected"><a href="training.aspx">Training</a>
    <ul>
<li><a href="#">Search Training</a></li>
       <li><a href="#">Post
Training</a></li>
    </ul>
</li>

<li><a href="othertraining.aspx">Other
Training</a></li>

<li><a href="aboutus.aspx">About Us</a></li>

</ul>
Example of sub page of Training being selected



<ul>


<li><a
href="default.aspx">Home</a></li>


<li><a href="training.aspx">Training</a>
<ul>

        
<li class="selected"><a href="#">Search Training</a></li>
<li><a href="#">Post Training</a></li>

    </ul>

</li>


<li><a
href="othertraining.aspx">Other Training</a></li>


<li><a
href="aboutus.aspx">About Us</a></li>


</ul>

I would like to use the url as
the parameter that defines what page is picked.

Thanks
Brant


----- Original
Message ----
From: Michael Kay <mike@xxxxxxxxxxxx>
To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Monday, December 11, 2006 11:19:26 AM
Subject: RE: [xsl] Dynamic Menu Using XSL

Remember that XSLT is used to
generate the target HTML page, and if you want
any interaction on that page,
e.g. hiding things when other things are
selected, that's purely a question of
generating the HTML that exhibits that
behaviour.

So it's a two-stage
process:

(a) design the (dynamic) HTML that you want to display 

(b) design
the XSLT that generates it from your source XML.

I get the impression you
haven't separated the two stages. It's a good idea
not to start on (b) until
you have completed (a).

Michael Kay
http://www.saxonica.com/


>
-----Original Message-----
> From: Brant Schroeder
[mailto:brantschr@xxxxxxxxx] 
> Sent: 11 December 2006 18:01
> To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Dynamic Menu Using XSL
> 
> I
am trying to create a dynamic menu using XML and XSLT.  
> Here is my XML
> 
>
<?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet 
>
type="text/xsl" href="mymenu.xsl"?>
> 
> 
> <menu>
>     <item id = "1"
url="default.aspx" title="Home"></item>  
>         <item id = "2"
url="default.aspx?id=Training" 
> title="Training">
>         <item id = "3"
> url="default.aspx?id=Search_Training" title="Search Training"></item>
>
<item id = "4" 
> url="default.aspx?id=Post_Training" title="Post 
>
Training"></item>                     
>         </item>  
>         <item id
= "7" url="default.aspx?id=Other_Training" 
> title="Other Training">
>
<item id = "8" 
> url="default.aspx?id=Search_Other_Training" title="Search 
>
Other Training"></item>
>                 <item id = "9" 
>
url="default.aspx?id=Post_Other_Training" title="Post Other 
>
Training"></item>
>         </item>
>         <item id = "11"
url="default.aspx?id=About_Us" 
> title="About Us">
>         <item id = "12"
url="default.aspx?id=Location" 
> title="Location">
>             <item id =
"13" 
> url="default.aspx?id=Map" title="View Map"></item>
>         </item>
>
</item>            
> </menu>I am using the following XSLT to generate my HTML
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> 
> 
> <xsl:param name="URL"/>
> 
>   <xsl:output indent="yes"/>
>   <xsl:template match="menu">
>     <html>
>       <body>
>         <ul>
>           <xsl:apply-templates/>
>
</ul>
>       </body>
>     </html>
>   </xsl:template>
>   <xsl:template
match="item">
>     <li>
>       <a href="{@url}">
>         <xsl:value-of
select="@title"/>
>       </a>
>       <xsl:if test="item">
>         <ul>
>
<xsl:apply-templates/>
>         </ul>
>       </xsl:if>
>     </li>
>
</xsl:template>
> 
> </xsl:stylesheet>
> 
> I would like to hide the child
menu if the parent menu is not 
> selected.   I would also like the parent
menu to be expanded 
> if a child menu is selected.  I am passing the url as a
> parameter (ex: default.aspx, default.aspx?id=About_us) this 
> matches the
URL attribute of the item.   I am new to XSLLT 
> and would appreciate any
help.
> 
> Thanks
> Brant
> 
> 
> 
> 
>  
>
______________________________________________________________
>
______________________
> Any questions? Get answers on any topic at 
>
www.Answers.yahoo.com.  Try it now.
> 
>
--~------------------------------------------------------------------
>
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To
unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail:
<mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --~--
_____________________________________________________________________________
_______
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

Current Thread