Wiki Documentation XSLT

The following XSLT script can be used against NDoc generated Xml files which contain the Xml document comments within your source. The XSLT will format the documentation according to the WikiDot markup syntax. While it's not 100% completed yet, it's in 'beta' at least. Enjoy :)

<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="text"/>

<template match="/">
+ Namespace: Nvigorate.Reflection

 <for-each select="//namespace[@name = 'Nvigorate.Reflection']">
     <call-template name="Class"/>
 </for-each>
</template>

<template match="namespace" name="Class">
 <for-each select="class">
++ Class: <value-of select="@name"/>

&gt;<value-of select="normalize-space(documentation/summary)"/>
<text>

</text>
    <call-template name="MemberList"/>
    <call-template name="Properties"/>
    <call-template name="Methods"/>

----
 </for-each>
</template>

<template match="constructor" name="Constructor">
+++ Constructors
</template>

<template match="*" name="MemberList">
+++ Member Listing
<text>
</text>

||~ Element Name||~ Element Type||~ Element Summary||<for-each select="member">
|| **<value-of select="@name"/>** || Member || <call-template name="Description"/> ||</for-each>
<for-each select="property">
|| **<value-of select="@name"/>** || Property || <call-template name="Description"/> ||</for-each>
<for-each select="method">
|| **<value-of select="@name"/>** || Method || <call-template name="Description"/> ||</for-each>
<text>
</text>
</template>

<template match="property" name="Properties">
+++ Properties
<text>
</text>

||~ Property Name||~ Access||~ Contract||~ Type||~ Read||~ Write||
<for-each select="property">|| **<value-of select="@name"/>** || <value-of select="@access"/> || <value-of select="@contract"/> || <value-of select="@displayName"/> || <if test="@get='true'">[[=]][[span style="color:blue"]]**X**[[/span]][[/=]]</if> || <if test="@set='true'">[[=]][[span style="color:blue"]]**X**[[/span]][[/=]]</if> ||
</for-each>
<text>
</text>
</template>

<template match="method" name="Methods">
+++ Methods
<text>
</text>
||~ Method Name||~ Access||~ Contract||~ Type||~ Signature||
<for-each select="method">|| **<value-of select="@name"/>**<if test="genericArgument/@name != ''">&lt;<for-each select="genericArgument"> <value-of select="@name"/> </for-each>&gt;</if> || <value-of select="@access"/> || <value-of select="@contract"/> || <value-of select="@displayName"/> || ||
||||||||||<call-template name="Description"/>||
</for-each>
<text>
</text>
</template>

<template match="documentation/summary" name="Description">
    <choose>
        <when test=".//see/@cref != ''">
            <for-each select=".//summary">
                <call-template name="SummaryBuilder"/>
            </for-each>
        </when>
        <otherwise>
            <value-of select="."/>
        </otherwise>
    </choose>

</template>

<template match ="summary" name="SummaryBuilder">

<variable name="textbefore"
       select="child::node()"/>
<variable name="textafter"
       select="child::node()"/>

<for-each select="child::node()">
    <choose>
        <when test="@cref != ''">
            <value-of select="substring-after(@cref, ':')"/><text> </text>
        </when>
        <otherwise>
            <value-of select="normalize-space(.)"/><text> </text>
        </otherwise>
    </choose>    
</for-each>

</template>

</stylesheet>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.