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

Re: Need Help

Subject: Re: Need Help
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 8 Dec 2006 23:55:40 GMT
Re:  Need Help
(please see the list posting guidelines about choosing subject lines
that help the archives later)


> I want to transform it to this
> ..
> Is this possible?  

not exactly as your requested format isn't well formed (<a> elements not
closed) but  essentially I suspect you want something like

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="menu">
  <ul>
    <xsl:apply-templates/>
  </ul>
</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>

which produces

<ul>
   <li>
      <a href="#">Home</a>
   </li>
   <li>
      <a href="#">My Stuff</a>
      <ul>
         <li>
            <a href="#">Backgrounds</a>
         </li>
         <li>
            <a href="#">Flyers</a>
         </li>
        <li>
            <a href="#">Posters</a>
         </li>
      </ul>
   </li>
   <li>
      <a href="#">Portfolio</a>
      <ul>
         <li>
            <a href="#">Backgrounds</a>
         </li>
         <li>
            <a href="#">Flyers</a>
         </li>
         <li>
            <a href="#">Posters</a>
         </li>
         <li>
            <a href="#">More Information</a>
            <ul>
               <li>
                  <a href="#">Resume</a>
               </li>
               <li>
                  <a href="#">Contact Me</a>
               </li>
            </ul>
         </li>
      </ul>
   </li>
</ul>


> Also I would like to apply CSS Classes to certain nodes depending if
> they are selected or not.

selected by what, where?


>   And can I hide child nodes if the p=arent node is not selected?

xslt doesn't interact with the browser at all (even if you are using a
client side xslt that's in the browser) it just generates an html page
that is then rendered, so if you know what css and/or javascript you
need to get whatever dynamic effect that you want, then you can generate
that code in xslt, but xslt doesn't "know" anyting about css or
javascript (or html) it's just generating an element tree, and the
javascript is just text as fas as xslt is concerned.

David

Current Thread

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.