Skip to content

Instantly share code, notes, and snippets.

@Novakov
Created September 17, 2012 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Novakov/3739658 to your computer and use it in GitHub Desktop.
Save Novakov/3739658 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:funcs="urn:funcs"
>
<xsl:output method="html" indent="yes"/>
<msxsl:script language="C#" implements-prefix="funcs">
<![CDATA[
public string formatDate(string text, string format)
{
return DateTime.Parse(text).ToString(format);
}
]]>
</msxsl:script>
<xsl:template match="Posts">
<table>
<thead>
<tr>
<th>Title</th>
<th>Path</th>
<th>Publish date</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="Post" />
</tbody>
</table>
</xsl:template>
<xsl:template match="Post">
<tr>
<td>
<xsl:value-of select="@Title"/>
</td>
<td>
<xsl:value-of select="@Path"/>
</td>
<td>
<xsl:value-of select="funcs:formatDate(@PublishDate, 'yyyy-MM-dd HH:mm:ss')"/>
</td>
<td>
<xsl:value-of select="@Summary"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment