Skip to content

Instantly share code, notes, and snippets.

@technolize
Created December 5, 2008 03:27
Show Gist options
  • Save technolize/32219 to your computer and use it in GitHub Desktop.
Save technolize/32219 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output media-type="text/plain" omit-xml-declaration="yes"/>
<xsl:variable name="FocusAreas">
<xsl:copy-of select="//object[@type='TODO' and not(attribute[@name='datecompleted']) and attribute[@name='focuslevel']=2]"/>
</xsl:variable>
<xsl:variable name="Projects">
<xsl:copy-of select="//object[@type='TODO' and not(attribute[@name='datecompleted']) and attribute[@name='focuslevel']=1]"/>
</xsl:variable>
<xsl:variable name="Tasks">
<xsl:copy-of select="//object[@type='TODO' and not(attribute[@name='datecompleted']) and attribute[@name='focuslevel']=0]"/>
</xsl:variable>
<xsl:template match="/">
Areas of focus
<xsl:for-each select="$FocusAreas/object">
* <xsl:call-template name="showtext"/>
</xsl:for-each>
Projects
<xsl:for-each select="$Projects/object">
* <xsl:call-template name="showtext"/>
</xsl:for-each>
Projects and tasks under Areas of focus
<xsl:for-each select="$FocusAreas/object">
<xsl:variable name="kids" select="relationship[@name='children']/@idrefs"/>
- <xsl:call-template name="showtext"/>
<xsl:for-each select="$Projects/object[contains($kids, @id)]">
<xsl:variable name="projkids" select="relationship[@name='children']/@idrefs"/>
[_] <xsl:call-template name="showtext"/>
<xsl:for-each select="$Tasks/object[contains($projkids, @id)]">
[ ] <xsl:call-template name="showtext"/>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="$Tasks/object[contains($kids, @id)]">
[ ] <xsl:value-of select="attribute[@name='title']"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="showtext">
<xsl:variable name="title"><xsl:value-of select="attribute[@name='title']"></xsl:value-of></xsl:variable>
<xsl:choose>
<xsl:when test="contains($title, '\\u')">
<xsl:variable name="output">{<xsl:value-of select="replace($title, '\\u(d+)', '&amp;\#\x$1;')"/>}</xsl:variable>
<xsl:value-of select="$output"></xsl:value-of>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$title"></xsl:value-of></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment