Login   Register  
PHP Classes
elePHPant
Icontem

File: Datalus/XSL/view_ajax.xsl

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Abbey Sparrow  >  Datalus  >  Datalus/XSL/view_ajax.xsl  >  Download  
File: Datalus/XSL/view_ajax.xsl
Role: Auxiliary data
Content type: text/plain
Description: view transformation
Class: Datalus
Build Web applications from XML definitions
Author: By
Last change:
Date: 2006-11-07 18:55
Size: 44,371 bytes
 

Contents

Class file image Download
<?xml version="1.0" encoding="iso-8859-1" ?> 
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dyn="http://exslt.org/dynamic"
                extension-element-prefixes="dyn"> 

  <xsl:template match="container">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            <head>
                <title><xsl:value-of select="@title" /></title>
                <xsl:choose>
                    <xsl:when test="comments">
                        <script language="javascript" type="text/javascript" src="Datalus/Javascript/tiny_mce/tiny_mce.js" >
                            dummy();
                        </script>
                    </xsl:when>
                </xsl:choose>
                
                <script type="text/javascript" src="Datalus/Javascript/ibox/ibox.js">
                    dummy();
                </script>
                <script type="text/javascript" src="Datalus/Javascript/TableSort/Event.js">
                    dummy();
                </script>
                <script type="text/javascript" src="Datalus/Javascript/TableSort/SortedTable.js">
                    dummy();
                </script>
                <script type="text/javascript">
                    var sourceTable, destTable;
                    function table_row_init() {
                        sourceTable = new SortedTable('s');
                        destTable = new SortedTable('d');
                        mySorted = new SortedTable();
                    }
                    function moveRows(s,d) {
                        var a = new Array();
                        for (var o in s.selectedElements) {
                            a.push(s.selectedElements[o]);
                        }
                        for (var o in a) {
                            var elm = a[o];
                            var tds = elm.getElementsByTagName('td');
                            for (var i in tds) {
                                if (tds[i].headers) tds[i].headers = d.table.id+''+tds[i].headers.substr(d.table.id.length);
                            }
                            d.body.appendChild(a[o]);
                            d.deselect(a[o]);
                            d.init(d.table);
                            d.sort();
                            s.deselect(a[o]);
                            s.init(s.table);
                        }
                    }
                </script>
                <script language="javascript" type="text/javascript">
                    var READY_STATE_UNINITIALIZED=0;
                    var READY_STATE_LOADING=1;
                    var READY_STATE_LOADED=2;
                    var READY_STATE_INTERACTIVE=3;
                    var READY_STATE_COMPLETE=4;
                    var req;

                    function getXMLHTTPRequest(){
                        var xRequest=null;
                        if (window.XMLHttpRequest){
                            xRequest = new XMLHttpRequest();
                        }else if (typeof ActiveXObject != "undefined"){
                            XRequest = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        return xRequest;
                    }

                    function sendRequest(url, params, callback, method){
                        if(!method){
                            method = "GET";
                        }
                        req = getXMLHTTPRequest();
                        if(req){
                            req.onreadystatechange=callback;
                            req.open(method,url,true);
                            req.setRequestHeader("Content-Type", 
                                "application/x-www-form-urlencoded");
                            req.send(params);
                        }
                    }

                    function login(){
                        sendRequest("ajax_server.php", 
                            "loginname="+document.account.loginname.value+
                                "<xsl:text disable-output-escaping="yes">&#38;</xsl:text>loginpassword="+
                                document.account.loginpassword.value, 
                            onLogin, "POST");
                    }

                    function onLogin(){
                        var ready = req.readyState;
                        var data = null;
                        if (ready == READY_STATE_COMPLETE){
                            data = req.responseText;
                            document.getElementById("accountpane").innerHTML=data;
                            updateMenus();
                        }
                    }

                    function logout(){
                        sendRequest("ajax_server.php", 
                            "loginname="+document.account.loginname.value,
                            onLogout, "POST");
                    }

                    function onLogout(){
                        var ready = req.readyState;
                        var data = null;
                        if (ready == READY_STATE_COMPLETE){
                            data = req.responseText;
                            document.getElementById("accountpane").innerHTML=data;
                            updateMenus();
                        }
                    }

                    function updateMenus(){
                        sendRequest("ajax_server.php", 
                            "updatemenus=true", 
                            onUpdateMenus, "POST");
                    }
                        
                    function onUpdateMenus(){
                        var ready = req.readyState;
                        var data = null;
                        if (ready == READY_STATE_COMPLETE){
                            data = req.responseText;
                            document.getElementById("topmenu").innerHTML=data;
                        }
                    }

                    function onReadyStateChange(){
                        var ready = req.readyState;
                        var data = null;
                        if (ready == READY_STATE_COMPLETE){
                            data = req.responseText;
                            alert(data);
                        }else{
                            data = "loading...["+ready+"]";
                        }
                        //... do something with the data...
                    }
                </script>
                        <script type="text/javascript" src="Datalus/Javascript/SearchInput/searchInput.js" >
                            dummy();
                        </script>
                <xsl:choose>
                    <xsl:when test="comments">
                        <script language="javascript" type="text/javascript">
                    tinyMCE.init({
                        mode : "textareas",
                        safari_warning : "false"
                    });
                
                    function fileBrowserCallBack(field_name, url, type, win) {
                        // This is where you insert your custom filebrowser logic
                        alert("Example of filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);
                
                        // Insert new URL, this would normaly be done in a popup
                        win.document.forms[0].elements[field_name].value = "someurl.htm";
                    }
                </script>
                    </xsl:when>
                </xsl:choose>
                <xsl:choose>
                    <xsl:when test="*[@axis='instant']">
                        <link rel="stylesheet" type="text/css" href="Datalus/Javascript/CalendarView/calendar_view.css" />
                        <script type="text/javascript" language="javascript" src="Datalus/Javascript/CalendarView/CalendarView.js">
                    dummy();
                </script>
                    </xsl:when>
                </xsl:choose>
                <xsl:choose>
                    <xsl:when test="@gmapskey and *[@axis='location']">
                        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={@gmapskey}"
      type="text/javascript">
                    dummy();
                </script>
                    </xsl:when>
                </xsl:choose>
                <xsl:apply-templates select="verifiers"/>
                <link rel="stylesheet" type="text/css" href="{@style}" />
                <link rel="stylesheet" href="Datalus/Javascript/ibox/ibox.css" type="text/css"  media="screen"/>
                <link media="all" type="text/css" href="Datalus/Javascript/TextEditor/rte.css" rel="stylesheet" />
            </head>
            <xsl:variable name="load">
             <xsl:choose>
                <xsl:when test="*[@axis='d']">calendarLoad(); table_row_init()</xsl:when>
                <xsl:otherwise>table_row_init()</xsl:otherwise>
             </xsl:choose>
          </xsl:variable>
            <body onload="{$load}">
            <div id="main_wrapper">
                <div id="titlebar"><img src="Graphics/logo.png" /></div>
                <xsl:apply-templates select="account"/>
                <xsl:apply-templates select="menu"/>
                <div id="container">
                    <xsl:copy-of select="div|p|img|br|ol|ul|li|i|b|a"/>
                    <xsl:apply-templates select="alert"/>
                    <xsl:apply-templates select="chat"/>
                    <xsl:apply-templates select="object"/>
                    <xsl:apply-templates select="object/list"/>
                    <xsl:apply-templates select="object/object"/>
                    <xsl:apply-templates select="list"/>
                    <xsl:apply-templates select="pages"/>
                    <xsl:apply-templates select="footnote"/>
                </div>
                <div id="fixed_container">
                <xsl:apply-templates select="fixed"/>
                </div>
                <div id="badges">
                    <xsl:apply-templates select="badge"/>
                </div>
            </div>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="badge">
        <img src="{@image}"/>
    </xsl:template>
    
    <xsl:template match="account[@loggedin='true']">
        <div id="accountpane"><form name="account" method="post" onsubmit="logout(); return false;">
            <input type="hidden" name="loginname" value="logout" />
            <xsl:value-of select="@name" />
            <input type="submit" value="Logout" class="loginbtn" />
        </form></div>
    </xsl:template>
    
    <xsl:template match="account">
        <div id="accountpane"><form name="account" method="post" onsubmit="login(); return false;">
                <input type="text" name="loginname" size="15" />
                <input type="password" name="loginpassword" size="15" />
                <input type="submit" value="Login" /></form></div>
    </xsl:template>
    
    <xsl:template match="chat">
        <div class="object">
        <div id="object_header"><xsl:value-of select="object/@name" />Chat</div>
        <center><applet codebase="chat" archive="chat.jar" code="Chat" width="85%" height="80%"> 
            <param name="config" value="config.txt" />
            <param name="smiles" value="on" />
            <param name="multi-rooms" value="on" />
            <param name="fgColor" value="#{@fgcolor}" />
            <param name="bgColor" value="#{@bgcolor}" />
            <param name="auto-login" value="{@user}" />
            Your browser is NOT Java enabled 
        </applet></center>
        </div>
    </xsl:template>
    
    <xsl:template match="pages">
        <div class="object">
            <xsl:copy-of select="div|p|img|br|ol|ul|li|i|b|a|text()"/>
        </div>
    </xsl:template>
    
    <xsl:template match="alert">
        <div id="alert">
        Alert! [<a href="#inner_content" rel="ibox" title="Loading Internal HTML Content" >click for details</a>]
        <div id="inner_content" style="display:none;">

<div style="background:#000000;color:#ffffff;border:1px dashed #FFFFFF;padding:15px;margin:15px;">	
	<h2><xsl:value-of select="@name" /></h2>
	<xsl:copy-of select="div|p|img|br|ol|ul|li|i|b|a|text()"/>
</div>
</div>
</div>
    </xsl:template>
    
    <!--match all menus with submenu attr & menu children-->
    <xsl:template match="menu">
        <div id="topmenu">
        <div id="{@type}bar">
            <div id="object_header"><xsl:value-of select="@name" /></div>
            <xsl:apply-templates />
        </div>
        </div>
    </xsl:template>
    
    <!--match all menus with a ancestor menu and a child menu-->
    <xsl:template match="submenu">
        <div id="{@type}item"><a href="{@location}"><xsl:value-of select="@name" /></a>
            <div id="{@type}submenu"><xsl:apply-templates /></div>
        </div>
    </xsl:template>
    
    <!--match all menus without children-->
    <xsl:template match="menuitem"><div id="{@type}item"><a href="{@location}"><xsl:value-of select="@name" /></a></div></xsl:template>
    
    <xsl:template match="list[@expand='true']">
        <form action="view.php"  onsubmit="return submitForm();">
            <div class="object">
            <div id="object_header"><xsl:value-of select="object/@name" /> list</div>
            <table class="sorted" cellspacing="0" cellpadding="0">
            <thead>
            <xsl:apply-templates select="tabhead" />
            </thead>
            <tbody>
            <xsl:apply-templates select="object" />
            </tbody>
            </table>
            <table cellspacing="0" cellpadding="0">
            <tr>
            <td><form name="addGroup" method="get">
                <input type="hidden" name="type" value="{object/@name}" />
                <input type="hidden" name="groupid" value="{@id}" />
                <input type="hidden" name="groupname" value="{@groupname}" />
                <input type="submit" value="Insert  {object/@name}" name="addgroup" />
            </form></td>
            <td><form name="newObject" method="get">
                <input type="hidden" name="type" value="{object/@name}" />
                <input type="hidden" name="id" value="{@id}" />
                <input type="hidden" name="groupname" value="{@groupname}" />
                <input type="submit" value="New {object/@name}" name="addgroup" />
            </form></td>
            </tr>
            </table>
            <span style="width:100%;text-align:center;">
                <a href="rss.php?type={@type}">
                    <img src="Graphics/Default/xml.gif" alt="XML"/>
                </a>
            </span>
            </div>
        </form>
    </xsl:template>
    
    <xsl:template match="list[@script]">
        <xsl:variable name="nombre" >
            <xsl:choose>
                <xsl:when test="@name"><xsl:value-of select="@name" /></xsl:when>
                <xsl:otherwise><xsl:value-of select="object/@name" /></xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <form action="{@script}"  onsubmit="return submitForm();">
            <div class="object">
            <div id="object_header"><xsl:value-of select="$nombre" /></div>
            <table class="sorted" cellspacing="0" cellpadding="0">
            <thead>
            <xsl:apply-templates select="tabhead" />
            </thead>
            <tbody>
            <xsl:apply-templates select="object" />
            </tbody>
            </table>
            <xsl:choose>
                <xsl:when test="@rss"><span style="width:100%;text-align:center;"><a href="rss.php?type={@type}">
                    <img src="Graphics/Default/xml.gif" alt="XML"/>
                </a>
            </span></xsl:when>
                <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
            </div>
        </form>
    </xsl:template>
    
    <xsl:template match="list">
        <form action="view.php"  onsubmit="return submitForm();">
            <div class="object">
            <div id="object_header"><xsl:value-of select="object/@name" /> list</div>
            <table class="sorted" cellspacing="0" cellpadding="0">
            <thead>
            <xsl:apply-templates select="tabhead" />
            </thead>
            <tbody>
            <xsl:apply-templates select="object" />
            </tbody>
            </table>
            <span style="width:100%;text-align:center;">
                <a href="rss.php?type={@type}">
                    <img src="Graphics/Default/xml.gif" alt="XML"/>
                </a>
            </span>
            </div>
        </form>
    </xsl:template>
    
    
    <xsl:template match="list[@axis='location']">
        <div class="object">
            <div id="object_header"><xsl:value-of select="object/@name" /> Map</div>
            <div id="location_map" style="width: 550px; height: 500px;">blah</div>
            <script type="text/javascript" language="javascript">
                var map = new GMap2(document.getElementById('location_map'));
                var geocoder = new GClientGeocoder();
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                map.setCenter(new GLatLng(37.4419, -122.1419), 3);
            </script>
            <xsl:apply-templates select="object" />
            <span style="width:100%;text-align:center;">
                <a href="rss.php?type={@type}">
                    <img src="Graphics/Default/xml.gif" alt="XML"/>
                </a>
            </span>
        </div>
    </xsl:template>
    
    <xsl:template match="list[@axis='instant']">
        <div class="object">
            <div id="object_header"><xsl:value-of select="object/@name" /> Calendar</div>
            <div id="calendar"  class="month_view"><xsl:text> </xsl:text></div>
            <script type="text/javascript" language="javascript">
                var calendar = new CalendarView(document.getElementById("calendar"), "month", "2006-07-20 12:25:32");
            </script>
            <xsl:apply-templates select="object" />
            <span style="width:100%;text-align:center;">
                <a href="rss.php?type={@type}">
                    <img src="Graphics/Default/xml.gif" alt="XML"/>
                </a>
            </span>
        </div>
    </xsl:template>
    
    <xsl:template match="list[@axis='image']">
        <div class="object">
            <div id="object_header"><xsl:value-of select="object/@name" /> Images</div>
            <xsl:apply-templates select="//image[@copy-from]"/>
        </div>
    </xsl:template>
    
    <xsl:template match="list[not(@axis='image')]//image[not(@copy-from)]">
    </xsl:template>
    
    <xsl:template match="list[not(@axis='image')]//image[@copy-from]">
    <td><img height="15px" src="Images/{text()}" /></td>
    </xsl:template>
    
    <xsl:template match="list[@axis='image']//image[@copy-from]">
        <xsl:variable name="source">../image[@name='<xsl:value-of select="@copy-from" />']/text()</xsl:variable>
        <xsl:variable name="name"><xsl:value-of select="../@identifier" /></xsl:variable>
        <xsl:variable name="ident">../*[@name='<xsl:value-of select="$name" />']/text()</xsl:variable>
        <xsl:variable name="val" select="dyn:evaluate($source)" />
        <xsl:variable name="ival" select="dyn:evaluate($ident)" />
        <a href="#inner_content_{../@id}" rel="ibox&amp;height=400&amp;width=600" title="{$ival}" ><img src="Images/{text()}" /></a>
        <div id="inner_content_{../@id}" style="display:none;">
            <div style="background:#000000;min-height:100%"><center>	
	           <a href="view.php?type={../@name}&amp;id={../@id}"><img src="Images/{$val}" /></a>
            </center></div>
        </div>
        
    </xsl:template>
    
    
    
    <xsl:template match="list[@expand='matrix']">
        <form action="{@target}"  onsubmit="return submitForm();">
            <div class="object">
            <div id="object_header"><xsl:value-of select="@name" /> list</div>
            <table class="sorted" cellspacing="0" cellpadding="0">
            <thead>
            <xsl:apply-templates select="tabhead" />
            </thead>
            <tbody>
            <xsl:apply-templates select="row" />
            <xsl:apply-templates select="object" />
            </tbody>
            </table>
            <form name="addrow" method="get">
                <input type="hidden" name="groupid" value="{@id}" />
                <input type="submit" value="new" name="mode" />
            </form>
            </div>
        </form>
    </xsl:template>
    <xsl:template match="list[@expand='matrix']">
        <form action="{@target}"  onsubmit="return submitForm();">
            <div class="object">
            <div id="object_header"><xsl:value-of select="@name" /> list</div>
            <table class="sorted" cellspacing="0" cellpadding="0">
            <thead>
            <xsl:apply-templates select="tabhead" />
            </thead>
            <tbody>
            <xsl:apply-templates select="row" />
            <xsl:apply-templates select="object" />
            </tbody>
            </table>
            <form name="addrow" method="get">
                <input type="hidden" name="groupid" value="{@id}" />
                <input type="submit" value="new" name="mode" />
            </form>
            </div>
        </form>
    </xsl:template>
    
    <xsl:template match="list[@expand='matrix']//row">
        <tr>
            <xsl:apply-templates />
            <td><form action="{@target}"><input type="hidden" name="id" value="{@id}" /><input type="submit" value="edit..." name="edit" /></form></td>
        </tr>
    </xsl:template>
    
    <xsl:template match="list[@expand='true']//tabhead">
        <tr>
            <xsl:apply-templates />
            <th></th>
        </tr>
    </xsl:template>
    
    <xsl:template match="list[not(@expand='true')]//tabhead">
        <tr>
            <xsl:apply-templates />
        </tr>
    </xsl:template>
    
    <xsl:template match="list//colhead">
        <th id="{@name}"><span>
            <xsl:value-of select="text()" />
        </span></th>
    </xsl:template>
    
    <xsl:template match="list[@expand='true']//object">
        <tr>
            <xsl:apply-templates />
            <td><form action="view.php"><input type="hidden" name="type" value="{@name}" /><input type="hidden" name="id" value="{*[@name='id']/text()}" /><input type="submit" value="edit..." name="edit" /></form></td>
        </tr>
    </xsl:template>
    
    <xsl:template match="list[not(@expand='true')]//object">
        <tr>
            <xsl:apply-templates />
        </tr>
    </xsl:template>
    
    <xsl:template match="list[@axis='location']//object">
        <script type="text/javascript" language="javascript">
            var object = "";
            var name = "<xsl:value-of select="@name" />";
            var id = "<xsl:value-of select="@id" />";
        </script>
        <xsl:apply-templates select="string" />
        <xsl:apply-templates select="instant" />
        <xsl:apply-templates select="location" />
    </xsl:template>
    
    <xsl:template match="list[@axis='instant']//object">
        <script type="text/javascript" language="javascript">
            var object = "";
            var name = "<xsl:value-of select="@name" />";
            var id = "<xsl:value-of select="@id" />";
        </script>
        <xsl:apply-templates select="string" />
        <xsl:apply-templates select="instant" />
    </xsl:template>

    <xsl:template match="list[@axis='location']//object//location">
        <script type="text/javascript" language="javascript">
            geocoder.getLatLng("<xsl:value-of select="text()" />",
                function(point){
                    if(point){
                        //map.setCenter(point, 10);
                        var marker = new GMarker(point);
                        map.addOverlay(marker);
                        GEvent.addListener(marker, "click", function() {
                            marker.openInfoWindowHtml('<b><a href="view.php?type='+name+'&amp;id='+id+'">'+name+'</a></b><br /><ul><li><xsl:value-of select="text()" /></li>'+object+'</ul>');
                        });
                        marker.openInfoWindowHtml('<b><a href="view.php?type='+name+'&amp;id='+id+'">'+name+'</a></b><br /><ul><li><xsl:value-of select="text()" /></li>'+object+'</ul>');
                    }
                }
            );
        </script>
    </xsl:template>
    
    <xsl:template match="list[@axis='instant']//object//instant">
        <script type="text/javascript" language="javascript">
            calendar.addCalendarEvent(new CalendarEvent(name, "<xsl:value-of select="text()" />", "<xsl:value-of select="text()" />", name+" @ <xsl:value-of select="text()" />", "view.php?type="+name+"&amp;id="+id));
        </script>
    </xsl:template>

    <xsl:template match="list[@axis='location']//object//string">
        <script type="text/javascript" language="javascript">
            object = object + "<li><xsl:value-of select="@name"/>: <xsl:value-of select="text()" /></li>";
        </script>
    </xsl:template>
    
    <xsl:template match="list[@axis='instant']//object//string">
    </xsl:template>
    
    <xsl:template match="list[@axis='location']//object//integer">
        <script type="text/javascript" language="javascript">
            object = object + "<li><xsl:value-of select="@name"/>: <xsl:value-of select="text()" /></li>";
        </script>
    </xsl:template>

    <xsl:template match="list[@axis='location']//object//instant">
        <script type="text/javascript" language="javascript">
            object = object + "<li><xsl:value-of select="@name"/>: <xsl:value-of select="text()" /></li>";
        </script>
    </xsl:template>

    <xsl:template match="list[not(@axis)]//string">
        <xsl:choose>
            <xsl:when test="../../@script">
                <xsl:param name="thescript" value="{../../@script}"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:param name="thescript" value="view.php"/>
            </xsl:otherwise>
        </xsl:choose>
        <td axis="string" headers="{@name}">
            <a href="{thescript}?type={../@name}&amp;id={../@id}"><xsl:value-of select="text()" /><xsl:copy-of select="div|p|img|br|ol|ul|li|i|b|a"/></a>
        </td>
    </xsl:template>
    
    <xsl:template match="list[not(@axis)]//integer">
        <td axis="number" headers="{@name}">
            <a href="view.php?type={../@name}&amp;id={../@id}"><xsl:value-of select="text()" /></a>
        </td>
    </xsl:template>
    
    <xsl:template match="list[not(@axis)]//user">
        <td axis="number" headers="{@name}">
            <a href="view.php?type={../@name}&amp;id={../@id}"><xsl:value-of select="text()" /></a>
        </td>
    </xsl:template>
    
    <xsl:template match="list[not(@axis)]//location">
        <td axis="string" headers="{@name}">
            <a href="view.php?type={../@name}&amp;id={../@id}"><xsl:value-of select="text()" /></a>
        </td>
    </xsl:template>
    
    <xsl:template match="list//userlink">
        <td axis="string" headers="{@name}">
            <form action="users.php" mode="get"><input type="hidden" name="mode" value="edit" /><input type="hidden" name="id" value="{@id}" /><input type="submit" value="edit..." name="edit" /></form>
        </td>
    </xsl:template>
    
    <xsl:template match="list[not(@axis)]//instant">
        <td axis="string" headers="{@name}">
            <a href="view.php?type={../@name}&amp;id={../@id}"><xsl:value-of select="text()" /></a>
        </td>
    </xsl:template>
    
    <xsl:template match="list//hidden">
    </xsl:template>
    
    <xsl:template match="list//password">
        <td>
            *
        </td>
    </xsl:template>
    
    <xsl:template match="list//string[@obscure='true']">
        <td>
            *
        </td>
    </xsl:template>
    
    <xsl:template match="list//instance">
        <td><xsl:value-of select="text()" /></td>
    </xsl:template>
    
    <xsl:template match="footnote">
            <div id="footnote">
                <p><xsl:copy-of select="br|h4|ol|ul|li|i|b|a|text()"/></p>
            </div>
    </xsl:template>
    
    <xsl:template match="fixed">
            <div class="fixed">
                <div id="object_header"><xsl:value-of select="@name" /></div>
                <div id="padded">
                <xsl:copy-of select="text()|p|img|br|h4|ol|ul|li|i|b|a|form"/>
                </div>
            </div>
    </xsl:template>
    
     <xsl:template match="object[not(ancestor::list) and @editable='true' and not(@name='search')]">
        <form name="{@name}" enctype="multipart/form-data" method="post" onsubmit="tinyMCE.triggerSave(); return allowSubmit();">
            <div class="object"  id="{@name}_{@id}">
                <xsl:param name="label" select="@identifier"/>
                <div id="object_header"><xsl:value-of select="@lprepend" /><xsl:value-of select="./*[@name=$label]/text()" /><xsl:value-of select="@lappend" /></div>
                <div id="padded">
                <xsl:copy-of select="div|p|img|br|h4|ol|ul|li|i|b|a"/>
                <input type="hidden" value="{@name}" name="type"/>
                <div id="{@name}">
                    <xsl:apply-templates select="./*[@name]"/>
                </div>
                <div id="edit_link">[<a href="view.php?type={@name}&amp;id={@id}&amp;edit=true">Edit</a>] </div>
                <xsl:if test="@ratings='true'">
                    <div class="rating">Average Rating:
                    <script type="text/javascript" language="javascript">
                        RatingInput('<xsl:value-of select="@name" />', '<xsl:value-of select="@id" />', <xsl:apply-templates select="rating" />);
                    </script>
                    </div>
                </xsl:if>
                </div>
            </div>
        </form>
        <xsl:apply-templates select="comments"/>
    </xsl:template>
    
    <xsl:template match="object[not(ancestor::list) and not(@editable='true') and not(@name='search')]"> 
        <form name="{@name}" enctype="multipart/form-data" method="post" onsubmit="tinyMCE.triggerSave(); return allowSubmit();">
            <div class="object"  id="{@name}_{@id}">
                <xsl:choose>
                    <xsl:when test="@identifier">
                        <xsl:param name="label" select="@identifier"/>
                        <div id="object_header"><xsl:value-of select="./*[@name=$label]/text()" /></div>
                    </xsl:when>
                    <xsl:otherwise>
                        <div id="object_header"><xsl:value-of select="@name" /></div>
                    </xsl:otherwise>
                </xsl:choose>
                <div id="padded">
                    <xsl:copy-of select="div|p|img|br|ol|ul|li|i|b|a"/>
                    <xsl:param name="count" select="count(./*[@name])"/>
                    <xsl:if test="$count&gt;0">
                        <div class="{@name}" id="object">
                            <xsl:apply-templates select="./*[@name]"/>
                        </div>
                    </xsl:if>
                </div>
            </div>
        </form>
        <xsl:apply-templates select="comments"/>
    </xsl:template>
    
    <xsl:template match="object[not(ancestor::list) and not(@editable='true') and @name='search']"> 
        <form name="{@name}" enctype="multipart/form-data" method="post" onsubmit="tinyMCE.triggerSave(); return allowSubmit();">
            <div class="object">
                <xsl:choose>
                    <xsl:when test="@identifier">
                        <xsl:param name="label" select="@identifier"/>
                        <div id="object_header">Search <xsl:value-of select="./*[@name=$label]/text()" /></div>
                    </xsl:when>
                    <xsl:otherwise>
                        <div id="object_header">Search <xsl:value-of select="@type" /></div>
                    </xsl:otherwise>
                </xsl:choose>
                <div id="padded">
                <table>
                    <tr>
                        <td>
                            <script type="text/javascript" language="javascript">
                                var fields = new Array();
                                <xsl:for-each select="field">
                                fields.push('<xsl:value-of select="@name" />');
                                </xsl:for-each>
                                SearchInput('<xsl:value-of select="@name"/>', fields);
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" name="submit" value="Submit" />
                        </td>
                    </tr>
                </table>
                </div>
            </div>
        </form>
        <xsl:apply-templates select="comments"/>
    </xsl:template>
    
    <xsl:template match="integer[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <xsl:value-of select="text()" />
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="string[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <xsl:value-of select="text()" />
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="location[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <xsl:value-of select="text()" />
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="*[not(ancestor::list) and @obsfuscate='true']"></xsl:template>
    

    <xsl:template match="invisible">
    </xsl:template>
    
    <!-- TODO: this probably shouldn't be shown at all like invisible -->
    <xsl:template match="hidden[not(ancestor::list)]">
        <input type="hidden" value="{text()}" name="{@name}"/>
    </xsl:template>
    
    <xsl:template match="image[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <img src="Images/{text()}"/>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="file[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <a href="Files/{text()}"><xsl:value-of select="text()" /></a>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="password[not(ancestor::list)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                ************
            </div>
        </div>
    </xsl:template>
   
    <!-- figure out what should be displayed for the following things -->
    <xsl:template match="discriminator[not(ancestor::list)]">
        <table border="0">
        <tr>
            <td>
                <xsl:value-of select="@name" />
            </td>
            <td>
                <xsl:apply-templates select="enumerator[@position='opOne']" />
            </td>
            <td>
                <xsl:apply-templates select="enumerator[@position='op']" />
            </td>
            <td>
                 <xsl:apply-templates select="nakedstring" />
            </td>
        </tr>
        </table>
    </xsl:template>
    
    <xsl:template match="action">
        <input type="submit" value="{@value}" name="{@name}" />
    </xsl:template>
    
    <xsl:template match="nakedstring">
        <input type="text" name="{@name}" value="{text()}" />
    </xsl:template>
    
    <xsl:template match="enumerator[not(ancestor::list)]">
        <select name="{@name}" size="1">
            <xsl:apply-templates select="option" />
        </select>
    </xsl:template>
    
    <xsl:template match="enumeration[not(ancestor::list)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <select name="{@name}" size="1">
                    <xsl:apply-templates select="option" />
                </select>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="option[not(ancestor::list)]">
        <option  value="{@value}"><xsl:value-of select="text()" /></option>
    </xsl:template>
    
    <xsl:template match="instant[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <xsl:value-of select="text()" />
            </div>
        </div>
    </xsl:template>
    
    <xsl:template match="block[not(ancestor::list) and not(@obsfuscate)]">
        <div class="object_field" id="{@name}">
            <div class="object_field_label" id="{@name}_label">
                <xsl:choose>
                    <xsl:when test="@label"><xsl:value-of select="@label" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
                </xsl:choose>
            </div>
            <div class="object_field_value" id="{@name}_value">
                <xsl:value-of disable-output-escaping="yes" select="text()" />
            </div>
        </div>
    </xsl:template>

    <xsl:template match="verifiers">
        <script type="text/javascript" language="javascript" src="Datalus/Javascript/Verifiers/verifierCommon.js">
            dummy();
        </script>
        <xsl:for-each select="verifier">
            <script type="text/javascript" language="javascript" src="Datalus/Javascript/Verifiers/{@file}">
                dummy();
            </script>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="comments">
        <div class="object">
            <div id="object_header">Comments</div>
            <div id="padded"> 
                <xsl:for-each select="comment">
                    <div class="comment">
                        <table>
                            <tr>
                                <td>
                                    <div class="subject">
                                        <xsl:value-of select="@subject"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><xsl:value-of disable-output-escaping="yes" select="text()"/></td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="tagline">
                                        Posted by: <xsl:value-of select="@handle"/>
                                        at <xsl:value-of select="@creationdate"/>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </xsl:for-each>
                <h3>Add a comment</h3>
                <table>
                    <form method="post" action="addComment.php" onsubmit="return allowSubmit();">
                        <tr>
                            <td colspan="2">
                                <a href="trackback.php?type={@type}&#38;id={@id}">Trackback URL</a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="openidhandle">OpenID Handle</label>
                            </td>
                            <td>
                                <input class="required" type="text" name="openidhandle" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="subject">Subject</label>
                            </td>
                            <td>
                                <input class="required" type="text" name="subject" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="body">Body</label>
                            </td>
                            <td>
                                <textarea name="body" rows="15" cols="80" style="width: 100%">blah</textarea>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input name="type" type="hidden" value="{@type}" />
                                <input name="id" type="hidden" value="{@id}" />
                                <input name="clear" type="reset" value="Clear" />
                            </td>
                            <td>
                                <input type="submit" value="Submit" name="submit" />
                            </td>
                        </tr>
                    </form>
                </table>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>