<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html" version="1.0" encoding="UTF-8" />

        <!-- match all -->
        <xsl:template match="/">
                <div><xsl:apply-templates select="*"/></div>
        </xsl:template>
        
        <!-- match <typechooser/> -->
        <xsl:template match="typechooser">
                <xsl:apply-templates select="root"/>        
        </xsl:template>
        
        <!-- match <root /> -->
        <xsl:template match="root">
                <div id="divRootA">
                        <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                        <tr>
                                                <xsl:if test="not(//@showicons='false')">
                                                        <td class="node-icon"><img src="images/{@icon}" alt="{@text}" width="16" height="16"/></td>
                                                </xsl:if>
                                                <td class="node-text"><xsl:value-of select="@text"/></td>
                                        </tr>
                                </tbody>
                        </table>
                </div>
                <div id="divRootB">
                        <xsl:apply-templates select="type"/>
                </div>
        </xsl:template>

        <!-- match <type /> -->
        <xsl:template match="type">
                <xsl:variable name="divId" select="generate-id()"/>
                <div id="div{$divId}A">
                        <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                        <tr>
                                                <xsl:if test="../type and ../../type">
                                                        <td><xsl:apply-templates select="." mode="miscimages"/></td>
                                                </xsl:if>
                                                <td onclick="objTypeChooser.toggleExpand(&apos;{$divId}&apos;)" id="td{$divId}"><xsl:apply-templates select="." mode="plusminusimage"/></td>
                                                <xsl:choose>
                                                        <xsl:when test="//@multiselect = 'true'"><td><input id="chk{$divId}" type="checkbox" value="{@type}|{@text}" style="height: 16px;"><xsl:if test="@abstract='true' and //@abstractselect='false'"><xsl:attribute name="disabled">disabled</xsl:attribute></xsl:if></input></td></xsl:when>
                                                        <xsl:otherwise><td><input type="radio" name="radType" value="{@type}|{@text}" style="height: 16px"><xsl:if test="@abstract='true' and //@abstractselect='false'"><xsl:attribute name="disabled">disabled</xsl:attribute></xsl:if></input></td></xsl:otherwise>
                                                </xsl:choose>
                                                                             
                                                <xsl:if test="not(//@showicons = 'false')">
                                                        <td class="node-icon"><img src="images/{@icon}" alt="{@text}" width="16" height="16"/></td>
                                                </xsl:if>                                                 
                                                <td class="node-text" nowrap="nowrap"><xsl:value-of select="@text"/></td>
                                        </tr>
                                </tbody>
                        </table>
                </div>
                <div id="div{$divId}B" style="display:none">
                        <xsl:choose>
                                <xsl:when test="type"><xsl:apply-templates select="type"/></xsl:when>
                                <xsl:otherwise><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></xsl:otherwise>
                        </xsl:choose>                        
                </div>
        </xsl:template>

        <!-- match <type /> -->
        <xsl:template match="type" mode="miscimages">
                <xsl:for-each select="ancestor::node()[not(name() = 'root') and not(name() = 'typechooser') and not(name() = '')]"><xsl:if test="not(../root)"><img height="19" width="19">
                                <xsl:attribute name="src">
                                        <xsl:choose>
                                                <xsl:when test="parent::node() and not(following-sibling::node())">images/utilSpacer.gif</xsl:when>
                                                <xsl:otherwise>images/utilTreeLineVert.gif</xsl:otherwise>
                                        </xsl:choose>                                                                
                                </xsl:attribute>
                        </img></xsl:if></xsl:for-each>
        </xsl:template>

        <!-- match <type /> -->
        <xsl:template match="type" mode="plusminusimage">
                <xsl:choose>
                        <xsl:when test="../root"></xsl:when>
                        <xsl:otherwise><img width="19" height="19"><xsl:attribute name="src">
                                <xsl:choose>
                                        <xsl:when test="following-sibling::node()">
                                                <xsl:choose>
                                                        <xsl:when test="child::node()">images/utilTreeLineNodeClosed.gif</xsl:when>
                                                        <xsl:otherwise>images/utilTreeLineNode.gif</xsl:otherwise>
                                                </xsl:choose>
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:choose>
                                                        <xsl:when test="child::node()">images/utilTreeLineLastClosed.gif</xsl:when>
                                                        <xsl:otherwise>images/utilTreeLineLast.gif</xsl:otherwise>
                                                </xsl:choose>
                                        </xsl:otherwise>
                                </xsl:choose>
                        </xsl:attribute></img></xsl:otherwise>
                </xsl:choose>
        </xsl:template>



</xsl:stylesheet>
