asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Advanced UI Design Using XML and XSL - Part 7: Relational Folder Tree Lines
By Joe Slovinski
Rating: 4.4 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Introduction


    Welcome to Advanced UI Design Using XML and XSL. Each article in my series will demonstrate the creation of a specific user interface (UI) component using eXtensible Markup Language (XML) and eXtensible Stylesheet Language (XSL). This article expands on a previous article in this series, Folder Tree Creation (see http://www.15seconds.com/issue/010921.htm). The Folder Tree discussed in this article displays commonly found relational lines from parent to child entities.

    Changes to the tree

    Overview

    Relational lines make a tree structure easier to read by clearly specifying the relationship between parent and child. While potential drawbacks of having many images and objects on the page exist, there should be no real concern with medium loads. Figure 1 shows these new lines in the folder tree.


    Figure 1. Relational Folder Tree Lines.

    All changes to accommodate relational lines take place within the XSLT style-sheet and client-side JavaScript. For those already using the tree, you need only to update the "tree.js" and "tree.xslt" files found within the first article. The next two sections of this article will outline the major changes.

    XSLT Changes

    The actual lines are drawn out within the XSL style-sheet. The changes require two additions. The first addition is an extra table cell in front of an entities icon, which will contain a plus or minus image depending on the state of the entity. Figure 2 below this new table cell within the root table.


    Figure 2. Additional cell within the entities table.

    The second change is the addition of the "hierarchy" template. This template is displayed below.

    
    <xsl:template name="hierarchy">
      <xsl:for-each select="ancestor::*[name() != contents]">
        <xsl:choose>
          <xsl:when test="following-sibling::node()">
            <img src="images/I.png"/>
          </xsl:when>
          <xsl:otherwise>
            <img src="images/blank.png"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
      <xsl:choose>
        <xsl:when test="count(contents/*) > 0">
          <xsl:choose>
            <xsl:when test="following-sibling::node()">
              <img src="images/Tplus.png" _open="images/Tminus.png" _closed="images/Tplus.png">
                <xsl:attribute name="ID">stateImagef<xsl:value-of select="@id"/></xsl:attribute>
              </img>
            </xsl:when>
            <xsl:otherwise>
              <img src="images/Lplus.png" _open="images/Lminus.png" _closed="images/Lplus.png">
                <xsl:attribute name="ID">stateImagef<xsl:value-of select="@id"/></xsl:attribute>
              </img>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="following-sibling::node()">
              <img src="images/T.png"/>
            </xsl:when>
            <xsl:otherwise>
              <img src="images/L.png"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    
    
    This template references the following images, which are discussed in the next few paragraphs.

    This template begins a descent through all of the current entities ancestors by calling an "xsl:for-each" that selects all ancestors whose names are not equal to "contents". This means only "entity" elements are processed, excluding their child contents elements. The purpose of this descent is to draw either a "|" straight line image if the entity's ancestor has sibling nodes or a blank image if the ancestor has no sibling nodes.

    The template then performs another "xsl:when" that checks the number of child elements within an entity's content element. If the element has children, it then draws either an "L" plus or "T" plus image. These letters indicate the basic shape of the line, "L" is a formation from parent to child flowing from top to bottom, left to right. "T", when rotated 90 degrees counter-clockwise, shows the relationship from parent to current node and to the following sibling of the parent, again reading from top to bottom, left to right.

    The style-sheet performs one last "xsl:when" that checks for following siblings. If siblings are found, a "T" image is drawn so that a "|" straight vertical line image will fit perfectly into place. If the entity does not have children, it draws an "L" image, showing that there are no siblings of the immediate parent.

    Client Changes

    The only changes to the client code take place within the expand and collapse methods. No lines were changed or removed, only added. The lines added are targeted in figure 3 below by breakpoints within InterDev.


    Figure 3. Additional lines to "tree.js".

    Each method simply creates a reference, called "oImage", to the entity's plus or minus image. Depending on whether a collapse or expand routine is being performed, the tree then applies either an open or closed image,.

    Demo & Download

    Folder Tree Relational Lines Demo
    Folder Tree Relational Lines Code

    Conclusion

    We can clearly see the benefits of taking advantage of XSLT and XML within an applications client tier by studying the small amount of and precise changes required to implement relational lines within this tree. Prime among these benefits are flexibility, scalability and maintainability.

    Closing

    I hope the contents of this article will help increase the quality of your Web applications. If you have any questions, comments, suggestions or requests please feel free to email me at the address listed in the author section.

    In addition, I'd like to send special thanks Phil Carrillo for doing an excellent job in creating the original "hierarchy" xslt template. Thanks Phil, the logic was concrete, and with very small modifications and a half an hour, I was able to integrate it into this tree.

    Other Articles in This Series

    Advanced UI Design

    Part 1 - Folder Tree Creation
    http://www.15seconds.com/issue/010921.htm

    Part 2 -- Custom Context Menu Creation
    http://www.15seconds.com/issue/010927.htm

    Part 3 -- Folder Tree Administration
    http://www.15seconds.com/issue/011113.htm

    Part 4 - Folder Tree Drag and Drop
    http://www.15seconds.com/issue/011129.htm

    Part 5 - Progress Indicator Creation
    http://www.15seconds.com/issue/011212.htm

    Part 6 -- Progress Indicator Usage
    http://www.15seconds.com/issue/020109.htm

    About the Author

    Joe Slovinski has been programming Web applications since 1993. For more information on the code in this article, contact the Joe Slovinski.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Supporting Products/Tools
    Stonebroom.ASP2XML
    Stonebroom.ASP2XML(c) is an interface component designed to make building applications that transport data in XML format much easier. It can be used to automatically pass updates back to the original data source.
    [Top]
    Other Articles
    Sep 22, 2005 - Implementing Remote Calling Without Using AJAX
    Right now the latest buzzword around town is AJAX. AJAX is an acronym for Asynchronous JavaScript and XML and is a method used to implement remote calling. The problem is that AJAX is only implemented in ASP.NET 2.0. This article will show you one way to implement remote calling without using AJAX or the XMLHttpRequest object. The technique outlined can even be used from classic ASP and is sufficient for most remote calling needs.
    [Read This Article]  [Top]
    Aug 18, 2005 - SQL Server 2005 XQuery and XML-DML - Part 3
    This article is the third and final installment of Alex Homer's series covering the new XML support in Microsoft SQL Server 2005. In it he covers updating the contents of xml columns, comparing traditional XML update techniques with XQuery, and using XQuery in a managed code stored procedure.
    [Read This Article]  [Top]
    Aug 11, 2005 - SQL Server 2005 XQuery and XML-DML - Part 2
    In the second part of his series on SQL Server 2005's new XML support, Alex Homer looks at extracting data from XML columns, comparing traditional XML data access approaches with XQuery, and combining XQuery and XSL-T.
    [Read This Article]  [Top]
    Aug 3, 2005 - SQL Server 2005 XQuery and XML-DML - Part 1
    Microsoft SQL Server 2005 now offers great support for and close integration with XML as a data persistence format. In the first article of his series examining this new support, Alex Homer offers an overview of how SQL Server 2005 stores XML documents and schemas, examines how it supports querying and manipulating XML documents, and provides a simple test application that allows you to experiment with XQuery.
    [Read This Article]  [Top]
    Jun 30, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 3, Cont'd
    In the final article of his series on reading and writing XML in .NET 2.0, Alex Homer looks at how the updated XML document store objects XmlDocument, XmlDataDocument and PathDocument can be used to read, persist and write XML documents and fragments more easily and more efficiently than in .NET 1.x.
    [Read This Article]  [Top]
    Jun 29, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 3
    In the final article of his series on reading and writing XML in .NET 2.0, Alex Homer looks at how the updated XML document store objects XmlDocument, XmlDataDocument and PathDocument can be used to read, persist and write XML documents and fragments more easily and more efficiently than in .NET 1.x.
    [Read This Article]  [Top]
    Jun 16, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 2, Cont'd
    Alex Homer continues his series on reading and writing XML in .NET 2.0. In part one, we focused on the reading side of things, examining the XmlReader and XmlReaderSettings classes. In this article, we move on to look at the XmlWriter and XmlWriterSettings classes, and how they can be used to write XML documents and fragments more easily and more efficiently than in version 1.x of .NET.
    [Read This Article]  [Top]
    Jun 15, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 2
    Alex Homer continues his series on reading and writing XML in .NET 2.0. In part one, we focused on the reading side of things, examining the XmlReader and XmlReaderSettings classes. In this article, we move on to look at the XmlWriter and XmlWriterSettings classes, and how they can be used to write XML documents and fragments more easily and more efficiently than in version 1.x of .NET.
    [Read This Article]  [Top]
    Jun 2, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 1, Cont'd
    In the first part of his series on reading and writing XML in .NET 2.0, Alex Homer discusses the XmlReader and XmlReaderSettings classes. The XmlReader exposes several useful new features and the all new XmlReaderSettings class makes it easy to generate single or multiple instances of an XmlReader with a range of useful properties.
    [Read This Article]  [Top]
    Jun 1, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 1
    In the first part of his series on reading and writing XML in .NET 2.0, Alex Homer discusses the XmlReader and XmlReaderSettings classes. The XmlReader exposes several useful new features and the all new XmlReaderSettings class makes it easy to generate single or multiple instances of an XmlReader with a range of useful properties.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry