xsl-list
[Top] [All Lists]

Efficient Templating - Concise Template Design

2005-02-21 03:01:41
Hi guys,

 

I have created the template below (a part of my first ever complete
stylesheet). To me it seems a little long winded, and I wonder if it could
be put more concisely. Be a better example of template design.

I would welcome any improvements to this stylesheet template.
And would love to hear your pointers as to how to write this template more
concisely and implement a better template design. Demonstrations would be
muchly appreciated!!!!!

<xsl:template match="tree_node">

  <tr>
     <td>
       <table width="100%">
         <tr>
          <td align="right" width="{(count(ancestor-or-self::*) - 1) * 20}">
          <xsl:choose>
           <xsl:when test="child::tree_node">
            <xsl:choose>
             <xsl:when test="@id = $id or descendant::tree_node/@id = $id">
              <xsl:choose>
               <xsl:when test="@id = $id">
                 <xsl:choose>
                   <xsl:when test="$node = 'collapse'">
                    <a href="{$url}&amp;id={(_at_)id}&amp;node=expand">
<img border="0" width="16" height="16" src="images/ui_tree/book_close.gif"/>
                   </a>
                   </xsl:when>
                   <xsl:otherwise>
                    <a href="{$url}&amp;id={(_at_)id}&amp;node=collapse">
 <img border="0" width="16" height="16" src="images/ui_tree/book_open.gif"/>
                   </a>
                   </xsl:otherwise>
                 </xsl:choose>    
               </xsl:when>
               <xsl:otherwise>
                 <a href="{$url}&amp;id={(_at_)id}&amp;node=collapse">
<img border="0" width="16" height="16" src="images/ui_tree/book_open.gif"/>
                 </a>
               </xsl:otherwise>
             </xsl:choose>
           </xsl:when>
           <xsl:otherwise>
             <a href="{$url}&amp;id={(_at_)id}&amp;node=expand">
<img border="0" width="16" height="16" src="images/ui_tree/book_close.gif"/>
             </a>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:when>
      <xsl:otherwise>
<img border="0" width="16" height="16" src="images/ui_tree/paper.gif"/>
      </xsl:otherwise>
    </xsl:choose>
    </td>
    <td>
      <a href="{$url}&amp;page={(_at_)id}">
        <xsl:value-of select="@value"/>
      </a>
    </td>
    <td align="right" width="5%">
      <a href="{$url}&amp;action=edit&amp;node={(_at_)id}">edit</a>
    </td>
    <td align="right" width="5%">
      <a href="{$url}&amp;action=delete&amp;node={(_at_)id}" onClick="return
deleteConfirm();">delete</a>
    </td>
  </tr>
</table>
</td>
</tr> 
</xsl:template>

Cheers, 

Adam 

 



Cheers, 
Adam 
 
NB: "Pray as if everything depended upon God and work as if everything
depended upon man."



--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>