Skip to content

Instantly share code, notes, and snippets.

@seankearney
Last active October 12, 2016 20:52
Show Gist options
  • Save seankearney/f66eca25fa0fa2eb29aa33a3fb18fac3 to your computer and use it in GitHub Desktop.
Save seankearney/f66eca25fa0fa2eb29aa33a3fb18fac3 to your computer and use it in GitHub Desktop.
XSLT for TDS Item Reports
<?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">
<xsl:output method="html" indent="yes"/>
<xsl:template match="ItemReport">
<html>
<head>
<title>
<xsl:value-of select="ProjectName"/>
</title>
<style>
/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */
/* Author: Nicolas Hery - http://nicolashery.com */
/* Version: b13fe65ca28d2e568c6ed5d7f06581183df8f2ff */
/* Source: https://github.com/nicolahery/markdownpad-github */
/* RESET
=============================================================================*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
}
/* BODY
=============================================================================*/
body {
font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif;
font-size: 14px;
line-height: 1.6;
color: #333;
background-color: #fff;
padding: 20px;
max-width: 960px;
margin: 0 auto;
}
body>*:first-child {
margin-top: 0 !important;
}
body>*:last-child {
margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: #000;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777;
font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
color: #4183C4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt>:first-child {
margin-top: 0px;
}
dl dt>:last-child {
margin-bottom: 0px;
}
dl dd {
margin: 0 0 15px;
padding: 0 15px;
}
dl dd>:first-child {
margin-top: 0px;
}
dl dd>:last-child {
margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}
pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}
pre code, pre tt {
background-color: transparent;
border: none;
}
kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif;
line-height: 10px;
padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}
blockquote>:first-child {
margin-top: 0px;
}
blockquote>:last-child {
margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}
/* TABLES
=============================================================================*/
table th {
font-weight: bold;
}
table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}
table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
/* IMAGES
=============================================================================*/
img {
max-width: 100%
}
/* TDS Changes
=============================================================================*/
h3 {
border-bottom: 1px solid #ddd;
}
code, tt {
background-color: transparent;
border: none;
}
.item-header{
}
.item-header img{
width:24px;
height:24px;
padding: 4px 4px 4px 0;
}
.item-header span{
line-height:30px;
}
.layout-section {
}
.layout-section .thumbnail{
#float:left;
width:25%;
}
table.template-fields{
border-collapse: collapse;
}
table.template-fields th.section-name{
text-align:left;
}
table.template-fields th.section-name img{
width:16px;
height:16px;
padding: 4px 4px 4px 0;
}
table.template-fields th.section-name span{
line-height:22px;
}
/* we don't want to blow the table out with long queries */
table.template-fields tr.field td code{
white-space: normal;
}
table.template-fields tr.section{
background-color: #ccc;
}
.inheriting-templates ul {
list-style: none;
padding: 0px;
}
.inheriting-templates ul li:before
{
content: '↳';
margin: 0 .75em; /* any design */
}
/* Charlie Original
=================================== */
.item-icon
{
width: 24px;
height: 24px;
float: left;
padding-top: 2px;
}
label
{
padding-right: 4px;
font-weight: bold;
}
.description label
{
float:left;
}
.description .long-description
{
margin: 1px;
float:left;
white-space: pre;
}
.inherited-templates, .inheriting-templates, .insert-options, .referenced-renderings
{
margin-top: 10px;
}
.inherited-templates ul, .inheriting-templates ul, .insert-options ul, .referenced-renderings ul
{
margin-top: 0px;
}
.section-icon
{
float: left;
padding-top: 1px;
}
.standard-values
{
margin-top: 10px;
margin-left 20px;
padding: 10px;
border: 1px solid #aaa;
background-color: #EEE;
color: #444;
float: left;
}
.standard-values h3
{
margin-top: 0px;
}
.standard-values .multi-list-field label, .standard-values .multi-list-field ul, .standard-values .lookup-field label, .standard-values .lookup-field table
{
float:left;
margin-top: 0px;
}
.clear
{
clear: both;
}
table.lookup-field-values tr td
{
color: #444;
border-color: #aaa;
}
.standard-values .field
{
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>
<xsl:value-of select="ProjectName"/>
</h1>
<div>
Project file: <xsl:value-of select="ProjectFile"/>
</div>
<ul>
<xsl:apply-templates select="Section" mode="toc" />
</ul>
<xsl:apply-templates select="Section" />
</body>
</html>
</xsl:template>
<xsl:template match="Section" mode="toc">
<li>
<a>
<xsl:attribute name="href">
#section-<xsl:value-of select="@Name"/>
</xsl:attribute>
<xsl:value-of select="@Name"/>
</a>
</li>
</xsl:template>
<xsl:template match="Section">
<div>
<xsl:attribute name="class">
report-section <xsl:value-of select="@Name"/>
</xsl:attribute>
<h2>
<xsl:attribute name="id">section-<xsl:value-of select="@Name"/></xsl:attribute>
<xsl:value-of select="@Name"/> Section
</h2>
<div class="section-description">
<xsl:value-of select="@Description"/>
</div>
<xsl:apply-templates select="*"/>
</div>
<hr/>
</xsl:template>
<xsl:template match="Template|Layout|Rendering|Content|PlaceholderSettings" mode="SectionCommon">
<h3 class="item-header">
<xsl:attribute name="id">
<xsl:value-of select="@ID"/>
</xsl:attribute>
<xsl:if test="Icon != ''">
<img class="item-icon">
<xsl:attribute name="src">
<xsl:value-of select="Icon"/>
</xsl:attribute>
</img>
</xsl:if>
<span class="item-name">
<xsl:value-of select="Name"/>
</span>
</h3>
<xsl:if test="Thumbnail">
<div class="thumbnail">
<img>
<xsl:attribute name="alt">
<xsl:value-of select="Thumbnail/@AltTag"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="Thumbnail"/>
</xsl:attribute>
</img>
</div>
<div class="clear"></div>
</xsl:if>
<div>
<label>Path:</label>
<code><xsl:value-of select="Path"/></code>
</div>
<div>
<label>Template: </label>
<xsl:value-of select="TemplateName"/>
</div>
</xsl:template>
<!--Templates-->
<xsl:template match="Template">
<div class="template-section">
<xsl:apply-templates select="." mode="SectionCommon"/>
<xsl:apply-templates select="Field[@Name='__Long description']" mode="Template"/>
<xsl:apply-templates select="InheritedTemplates"/>
<xsl:apply-templates select="InheritingTemplates"/>
<xsl:apply-templates select="TemplateSections"/>
<xsl:if test="StandardValues/*">
<xsl:apply-templates select="StandardValues"/>
</xsl:if>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="Field[@Name='__Long description']" mode="Template">
<div class="description">
<label>Description:</label>
<div class="long-description">
<xsl:value-of select="."/>
</div>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="InheritedTemplates">
<div class="inherited-templates">
<label>Base Templates:</label>
<ul>
<xsl:apply-templates select="*"/>
</ul>
</div>
</xsl:template>
<xsl:template match="InheritingTemplates">
<div class="inheriting-templates">
<label>Inheritance:</label>
<ul>
<xsl:apply-templates select="*"/>
</ul>
</div>
</xsl:template>
<xsl:template match="InheritedTemplate|InheritingTemplate|InsertOption|ReferencedRendering|CompatibleRendering|AllowedControl">
<li>
<code>
<xsl:choose>
<xsl:when test="//Template[@ID=current()/@ID]|//Layout[@ID=current()/@ID]|//Rendering[@ID=current()/@ID]">
<a>
<xsl:attribute name="href">
#<xsl:value-of select="@ID"/>
</xsl:attribute>
<xsl:value-of select="."/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</code>
</li>
</xsl:template>
<xsl:template match="TemplateSections">
<table class="template-fields">
<tr>
<th>Name</th>
<th>Type</th>
<th>Source</th>
<th>Unversioned</th>
<th>Shared</th>
</tr>
<xsl:apply-templates select="TemplateSection"/>
</table>
</xsl:template>
<xsl:template match="TemplateSection">
<tr class="section">
<th class="section-name" colspan="5">
<xsl:if test="Icon != ''">
<img class="section-icon">
<xsl:attribute name="src">
<xsl:value-of select="Icon"/>
</xsl:attribute>
</img>
</xsl:if>
<span><xsl:value-of select="Name"/></span>
</th>
</tr>
<xsl:apply-templates select="TemplateFields/TemplateField"/>
</xsl:template>
<xsl:template match="TemplateField">
<tr class="field">
<td class="template-field-name">
<xsl:value-of select="Name"/>
</td>
<td>
<xsl:value-of select="Type"/>
</td>
<td>
<code><xsl:value-of select="Source"/></code>
</td>
<td>
<xsl:value-of select="Unversioned"/>
</td>
<td>
<xsl:value-of select="Shared"/>
</td>
</tr>
<xsl:if test="Validators/Validator">
<tr class="validators">
<td></td>
<td colspan="4">
<label>Validators:</label>
<xsl:apply-templates select="Validators/Validator"/>
</td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template match="Validator">
<xsl:if test="position()!=1">, </xsl:if>
<xsl:value-of select="@Name"/>
</xsl:template>
<xsl:template match="StandardValues">
<div class="standard-values">
<h3>Standard Values</h3>
<xsl:if test="Workflow">
<div>
<label>Workflow:</label>
<xsl:value-of select="Workflow"/>
</div>
</xsl:if>
<xsl:if test="DefaultWorkflowState">
<div>
<label>Default Workflow State:</label>
<xsl:value-of select="DefaultWorkflowState"/>
</div>
</xsl:if>
<xsl:apply-templates select="InsertOptions"/>
<xsl:apply-templates select="ReferencedRenderings"/>
<xsl:apply-templates select="ItemFields"/>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="InsertOptions">
<div class="insert-options">
<label>Insert Options:</label>
<ul>
<xsl:apply-templates select="*"/>
</ul>
</div>
</xsl:template>
<xsl:template match="ReferencedRenderings">
<div class="referenced-renderings">
<label>Referenced Renderings:</label>
<ul>
<xsl:apply-templates select="*"/>
</ul>
</div>
</xsl:template>
<xsl:template match="ItemFields">
<div class="item-fields">
<h3>Item Fields</h3>
<xsl:apply-templates select="*" mode="GenericField"/>
</div>
</xsl:template>
<xsl:template match="Field" mode="GenericField">
<div class="field">
<label>
<xsl:value-of select="@Label"/>:
</label>
<xsl:value-of select="."/>
</div>
</xsl:template>
<xsl:template match="LinkField[Link[@Name='mediaid']]" mode="GenericField">
<div class="link-field field">
<label>
<xsl:value-of select="@Label"/> (media):
</label>
<xsl:value-of select="Link[@Name='mediaid']"/>
</div>
</xsl:template>
<xsl:template match="LinkField[Link[@Name='id']]" mode="GenericField">
<div class="field">
<label>
<xsl:value-of select="@Label"/> (link):
</label>
<xsl:value-of select="Link[@Name='id']"/>
</div>
</xsl:template>
<xsl:template match="MultiListField" mode="GenericField">
<div class="multi-list-field field">
<label>
<xsl:value-of select="@Label"/>:
</label>
<ul>
<xsl:apply-templates select="Item" mode="GenericField"/>
</ul>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="Item" mode="GenericField">
<li>
<xsl:value-of select="."/>
</li>
</xsl:template>
<xsl:template match="LookupField" mode="GenericField">
<div class="lookup-field field">
<label>
<xsl:value-of select="@Label"/>:
</label>
<table class="lookup-field-values">
<xsl:apply-templates select="Lookup" mode="GenericField"/>
</table>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="Lookup" mode="GenericField">
<tr>
<td>
<xsl:value-of select="@Name"/>
</td>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:template>
<!--Layouts-->
<xsl:template match="Layout">
<div class="layout-section">
<xsl:apply-templates select="." mode="SectionCommon"/>
<xsl:apply-templates select="Field[@Name='Path']" mode="Layout"/>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="Field[@Name='Path']" mode="Layout">
<div class="layout-path">
<label>Layout Path:</label>
<span>
<xsl:value-of select="."/>
</span>
</div>
<div class="clear"/>
</xsl:template>
<!--Renderings-->
<xsl:template match="Rendering">
<div class="layout-section">
<xsl:apply-templates select="." mode="SectionCommon"/>
<xsl:apply-templates select="CompatibleRenderings"/>
<xsl:apply-templates select="RenderingFields"/>
<xsl:apply-templates select="CacheFields"/>
<xsl:apply-templates select="ItemFields"/>
</div>
<div class="clear"/>
</xsl:template>
<xsl:template match="CompatibleRenderings">
<h3>Compatible Renderings</h3>
<ul>
<xsl:apply-templates select="CompatibleRendering"/>
</ul>
</xsl:template>
<xsl:template match="RenderingFields">
<xsl:if test="RenderingFields/*">
<h3>Rendering Fields</h3>
<xsl:apply-templates select="RenderingFields/*" mode="GenericField"/>
</xsl:if>
</xsl:template>
<xsl:template match="CacheFields">
<xsl:if test="CacheFields/*">
<h3>Caching Fields</h3>
<xsl:apply-templates select="CacheFields/*" mode="GenericField"/>
</xsl:if>
</xsl:template>
<!--Content-->
<xsl:template match="Content">
<div class="content-section">
<xsl:apply-templates select="." mode="SectionCommon"/>
<div>
<label>Template: </label>
<xsl:value-of select="Template"/>
</div>
<xsl:apply-templates select="ItemFields"/>
</div>
<div class="clear"/>
</xsl:template>
<!--PlaceholderSettings-->
<xsl:template match="PlaceholderSettings">
<div class="placeholder-settings-section">
<xsl:apply-templates select="." mode="SectionCommon"/>
<xsl:apply-templates select="Field[@Name='Placeholder Key']" mode="PlaceholderSettings"/>
<xsl:apply-templates select="AllowedControls"/>
<xsl:apply-templates select="ItemFields"/>
</div>
</xsl:template>
<xsl:template match="AllowedControls">
<h3>Allowed Controls</h3>
<ul>
<xsl:apply-templates select="AllowedControl"/>
</ul>
</xsl:template>
<xsl:template match="Field[@Name='Placeholder Key']" mode="PlaceholderSettings">
<div class="placeholder-key">
<label>Placeholder Key:</label>
<span>
<xsl:value-of select="."/>
</span>
</div>
<div class="clear"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment