<?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"/>
<xsl:variable name="username" select="/widgetinfo/activeuser/username/@uri"/>

 <xsl:template match="widgetinfo">
 
 <h1><xsl:value-of select="concat(activeuser/username, ' -- ', activeuser/name)"/></h1>
 
<!-- *************************************** --> 
 <h3><xsl:value-of select="count(friends/friend[@online = 'Y'])"/> Online friends</h3>
  <table>
   <xsl:for-each select="friends/friend[@online = 'Y']">
    <xsl:sort select="@username" data-type="text" order="ascending"/>
    <tr>
     <td>
     <a>
     <xsl:attribute name="href">http://my.opera.com/<xsl:value-of select="@username"/>/about/sendmsg.dml</xsl:attribute>
     <!-- todo: urlescape -->
      <xsl:value-of select="@username"/>
      </a>
     </td>
<!--     <td>
      <xsl:value-of select="blog/lastpost/@posted"/>
     </td> -->
    </tr>
   </xsl:for-each>
  </table>
 
<!-- *************************************** --> 
  <h3><xsl:value-of select="subscriptions/@num"/> Forum threads</h3>
 <table>
   <xsl:for-each select="subscriptions/topic">
    <!-- to sort oldest threads last ? -->
    <tr>
     <td>
      <xsl:value-of select="forum/name"/>
     </td>
     <td>
      <a>
	<xsl:attribute name="href">http://my.opera.com/community/forums/findpost.pl?mode=new&amp;id=<xsl:value-of select="@id"/></xsl:attribute>
	[<xsl:value-of select="title"/>]
	</a>
     </td>
    </tr>
   </xsl:for-each>
  </table>


<!-- *************************************** -->
<h3><xsl:value-of select="messages/@total"/> PMs</h3>
 <table>
   <xsl:for-each select="messages/message">
    <xsl:sort select="@id" data-type="number" order="ascending"/>
    <tr>
     <td>
      <xsl:value-of select="sender"/>
     </td>
     <td>
      <xsl:value-of select="sent"/>
     </td>
     <td>
      <a>
	<xsl:attribute name="href">http://my.opera.com/<xsl:value-of select="$username"/>/messages/?mid=<xsl:value-of select="@id"/></xsl:attribute>
	[<xsl:value-of select="title"/>]
	</a>
     </td>
     <td>
      <xsl:value-of select="content"/>
     </td>
     
    </tr>
   </xsl:for-each>
  </table>
  
  <!-- *************************************** -->
  <h3><xsl:value-of select="count(watches/watch)"/> Watches</h3>
 <table>
   <xsl:for-each select="watches/watch">
    <!-- no sort, default should be fine -->
    <tr>
     <th colspan="2">
      <!--<xsl:attribute name="colspan"><xsl:value-of select="count(items/item)"/></xsl:attribute>-->
      <xsl:value-of select="concat(author/username, ' -- ', author/name)"/>
     </th>
     </tr>
   <xsl:for-each select="items/item">
    <!-- no sort, default should be fine -->
    <tr>
     <td><xsl:value-of select="itemauthor/username"/></td>
     <td><xsl:value-of select="@type"/></td>     
     <td><a>
		<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
		[<xsl:value-of select="title"/>]
	 </a>	
     </td>
     </tr>
     </xsl:for-each>
     
     
   </xsl:for-each>
  </table>
  

<!-- *************************************** -->
<h3><xsl:value-of select="count(whatsnew/logitem)"/> Logitems</h3>
 <table>
   <xsl:for-each select="whatsnew/logitem">
    <!-- no sort, default should be fine -->
    <tr>
     <td>
      <xsl:value-of select="author"/>
     </td>
     <td>
      <xsl:value-of select="rtype"/>
     </td>
     <td>
      <a>
	<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
	[<xsl:value-of select="title"/>]
	</a>
     </td>
     <td>
      <xsl:value-of select="lastaction"/>
     </td>
     <td>
      <xsl:value-of select="comment"/>
     </td>
     
    </tr>
   </xsl:for-each>
  </table>
 </xsl:template>
 
</xsl:stylesheet>