What the heck have I done last week?

Every Wednesday we’ve got team meeting and I need to find out what the heck I was doing last week :). SVN Repository logs are very helpfull whith that concern. Here a little bash script that extracts the log entries of a given user for the last 7 days…

#!/bin/bash

REPOS="TetraTrans Libraries IDDS IDDS2010"
MYSVNUSER="meckschlager"

for repo in $REPOS
do
	svn log $repo -r {`date --date="7 days ago" +%Y-%m-%d`}:{`date +%Y-%m-%d`} | sed -n "/"$MYSVNUSER"/,/-----$/ p"
done

xslt to document xml schemas

Here a little XSLT code that transforms the documentation fields of any XSD Schema into a nicely formatted html page. There are several tools (especially commercial ones) that will do the task as well. But what I found was that all of them meant it too well and presented too much information.

This solution tries to keep it simple and presents elements and their attributes; with the appropriate documentation for each of them …

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:ex="http://exslt.org/dates-and-times" 
  extension-element-prefixes="ex"
  >
<xsl:output method="html" indent="yes" version="4.0"/>
<xsl:strip-space elements="section"/>
<!--exclude-result-prefixes="xs" -->

<xsl:template match="/">
<html>
	<head>
<style type="text/css">
table.gridtable {
	font-family: verdana,arial,sans-serif;
	font-size:12px;
	color:#333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}
table.gridtable th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}
table.gridtable td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}
body { font-family: verdana,arial,sans-serif;
	font-size:12px;
	color:#333333;
}
.heading { font-family: verdana,arial,sans-serif;
	font-size:14px;
	font-weight:bolder;
	color:#333333;
}
</style>
</head>
	<body>
		<basefont size="2" color="#CC00CC" face="Verdana" />
		<h2>Configuration Documentation</h2>
		<xsl:apply-templates/> 
		<br /> <br /> <span> gernerated by document.xslt <br /><xsl:value-of select="ex:date-time()"/></span>
	</body>
</html>
</xsl:template>

<xsl:template match="xs:element">
<br /> <hr /> <br /> <br />
<xsl:variable name="elname"><xsl:value-of select="@name"/></xsl:variable>
<span class="heading" id="{$elname}">Element <xsl:value-of select="@name"/></span><br />
Description:<xsl:value-of select="xs:annotation/xs:documentation"/>
<xsl:for-each select="xs:complexType">
<!-- list all attributes -->
<p>
<xsl:if test="xs:attribute or xs:simpleContent/xs:extension/xs:attribute">
<span class="heading">Attributes:</span>
<table class="gridtable">
<tr>
<th>Name</th><th>Type</th><th>Description</th><th>Use</th><th>Possible Values</th>
</tr>
	<xsl:apply-templates select="xs:attribute"/>
<xsl:for-each select="xs:simpleContent/xs:extension">
	<xsl:apply-templates select="xs:attribute"/>
</xsl:for-each>
</table>	
</xsl:if>
</p>

<!-- list all subelements -->
<xsl:if test="xs:all/xs:element or xs:sequence/xs:element">
<p><span class="heading">Subelements: </span>
<xsl:for-each select="xs:all/xs:element">
 <xsl:variable name="elinklname"><xsl:value-of select="@name"/></xsl:variable>
 <a href="#{$elinklname}"><xsl:value-of select="@name"/></a><xsl:if test="position() &lt;  last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>
<xsl:for-each select="xs:sequence/xs:element">
 <xsl:variable name="elinklname"><xsl:value-of select="@name"/></xsl:variable>
 <a href="#{$elinklname}"><xsl:value-of select="@name"/></a><xsl:if test="position() &lt;  last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each> 
</p>
</xsl:if>


<!-- recurse into all subelements -->
<xsl:for-each select="xs:all"><xsl:text> </xsl:text>
	<xsl:apply-templates select="xs:element"/>
</xsl:for-each>
<xsl:for-each select="xs:sequence"><xsl:text> </xsl:text>
	<xsl:apply-templates select="xs:element"/>
</xsl:for-each>

</xsl:for-each>
</xsl:template>

<!-- atributes -->
<xsl:template match="xs:attribute">
<tr><td><xsl:value-of select="@name"/></td>
<!-- type, bit dirty since it includes both possibilties without an if statement -->
<td><xsl:value-of select="@type"/><xsl:value-of select="xs:simpleType/xs:restriction/@base"/></td>
<td><xsl:value-of select="xs:annotation/xs:documentation"/></td>
<td><xsl:value-of select="@use"/></td>
<!-- possible values, dirty, but hey :) -->
<td><xsl:for-each select="xs:simpleType/xs:restriction/xs:enumeration">
	<xsl:value-of select="@value"/><xsl:if test="position() &lt;  last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>
<xsl:value-of select="@fixed" />
</td></tr>

</xsl:template>
</xsl:stylesheet>