[mdoc-x-msitomsx] Additional <token/> replacement values.
[mono.git] / mcs / tools / mdoc / Resources / msitomsx.xsl
1 <?xml version="1.0"?>
2 <!--
3   Converts the "Microsoft Internal XML Documentation Format" into the 
4   "Microsoft XML Documentation Format".
5
6   The "Microsoft Internal XML Documentation Format" (msidoc) is whatever XML
7   format is used within Microsoft to document the BCL, as deduced from reading
8   their ECMA documentation dump.
9
10   The "Microsoft XML Documentation Format" (msxdoc) is what 'gmcs /doc' 
11   produces, and is documented in ECMA 334 §E.
12
13   msidoc is similar, but not identical to, msxdoc.  For example, where msxdoc
14   uses <see cref="FOO"/>, msidoc uses
15   <codeEntityReference>FOO</codeEntityReference>.  They also introduce
16   additional "wrapping" elements in various places (e.g. <content/>), useful
17   extensions (such as documenting method overload lists), and other oddities.
18   -->
19 <xsl:stylesheet
20   version="1.0"
21   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
23   xmlns:authoring="http://ddue.schemas.microsoft.com/authoring/2003/5"
24   exclude-result-prefixes="msxsl authoring"
25   >
26
27   <xsl:output omit-xml-declaration="yes" />
28
29   <xsl:template match="assembly" />
30   <xsl:template match="authoring:changeHistory" />
31   <xsl:template match="authoring:clsCompliantAlternative" />
32   <xsl:template match="authoring:internalOnly" />
33   <xsl:template match="authoring:notesForCallers" />
34   <xsl:template match="authoring:notesForImplementers" />
35   <xsl:template match="authoring:notesForInheritors" />
36   <xsl:template match="authoring:overload" />
37   <xsl:template match="authoring:relatedTopics" />
38
39   <xsl:template match="member">
40     <!-- skip Overload: members, as these have no msxdoc equivalent. -->
41     <xsl:if test="not (starts-with (@name, 'Overload:'))">
42       <member name="{@name}">
43         <xsl:apply-templates />
44       </member>
45     </xsl:if>
46   </xsl:template>
47
48   <xsl:template match="authoring:remarks">
49     <remarks>
50       <xsl:apply-templates />
51       <xsl:for-each select="../authoring:notesForInheritors">
52         <block subset="none" type="overrides">
53           <xsl:apply-templates />
54         </block>
55       </xsl:for-each>
56       <xsl:for-each select="../authoring:notesForImplementers">
57         <block subset="none" type="behaviors">
58           <xsl:apply-templates />
59         </block>
60       </xsl:for-each>
61       <xsl:for-each select="../authoring:notesForCallers">
62         <block subset="none" type="usage">
63           <xsl:apply-templates />
64         </block>
65       </xsl:for-each>
66     </remarks>
67   </xsl:template>
68
69   <xsl:template match="authoring:dduexml" >
70     <xsl:apply-templates />
71   </xsl:template>
72
73   <xsl:template match="authoring:codeEntityReference">
74     <see cref="{.}" />
75   </xsl:template>
76
77   <xsl:template match="authoring:equivalentCodeEntity">
78     <seealso cref="{authoring:codeEntityReference}" />
79   </xsl:template>
80
81   <xsl:template match="authoring:codeInline">
82     <c>
83       <xsl:apply-templates />
84     </c>
85   </xsl:template>
86
87   <xsl:template match="authoring:codeReference">
88     <code src="{.}" />
89   </xsl:template>
90
91   <xsl:template match="authoring:parameters">
92     <xsl:apply-templates />
93   </xsl:template>
94
95   <xsl:template match="authoring:parameter">
96     <param name="{authoring:parameterReference}">
97       <xsl:for-each select="*">
98         <xsl:if test="not (position () = 1)">
99           <xsl:apply-templates />
100         </xsl:if>
101       </xsl:for-each>
102     </param>
103   </xsl:template>
104
105   <xsl:template match="authoring:genericParameters">
106     <xsl:apply-templates />
107   </xsl:template>
108
109   <xsl:template match="authoring:genericParameter">
110     <typeparam name="{authoring:parameterReference}">
111       <xsl:for-each select="*">
112         <xsl:if test="not (position () = 1)">
113           <xsl:apply-templates />
114         </xsl:if>
115       </xsl:for-each>
116     </typeparam>
117   </xsl:template>
118
119   <xsl:template match="authoring:parameterReference">
120     <paramref name="{.}" />
121   </xsl:template>
122
123   <xsl:template match="authoring:returnValue">
124     <returns>
125       <xsl:apply-templates />
126     </returns>
127   </xsl:template>
128
129   <xsl:template match="authoring:exceptions">
130     <xsl:apply-templates />
131   </xsl:template>
132
133   <xsl:template match="authoring:exception">
134     <exception cref="{authoring:codeEntityReference}">
135       <xsl:apply-templates select="authoring:content" />
136     </exception>
137   </xsl:template>
138
139   <xsl:template match="authoring:codeExamples">
140     <xsl:apply-templates />
141   </xsl:template>
142
143   <xsl:template match="authoring:codeExample">
144     <xsl:choose>
145       <xsl:when test="count(authoring:legacy) &gt; 0">
146       </xsl:when>
147       <xsl:otherwise>
148         <example>
149           <xsl:apply-templates select="authoring:description/authoring:content" />
150           <xsl:apply-templates select="authoring:codeReference" />
151         </example>
152       </xsl:otherwise>
153     </xsl:choose>
154   </xsl:template>
155
156   <xsl:template match="authoring:content">
157     <xsl:apply-templates />
158   </xsl:template>
159
160   <xsl:template match="authoring:languageKeyword">
161     <see langword="{.}" />
162   </xsl:template>
163
164   <xsl:template match="authoring:table">
165     <list type="table">
166       <xsl:apply-templates />
167     </list>
168   </xsl:template>
169
170   <xsl:template match="authoring:tableHeader">
171     <listheader>
172       <xsl:for-each select="authoring:row/authoring:entry">
173         <xsl:choose>
174           <xsl:when test="position() = 1">
175             <term>
176               <xsl:apply-templates />
177             </term>
178           </xsl:when>
179           <xsl:otherwise>
180             <description>
181               <xsl:apply-templates />
182             </description>
183           </xsl:otherwise>
184         </xsl:choose>
185       </xsl:for-each>
186     </listheader>
187   </xsl:template>
188
189   <xsl:template match="authoring:row">
190     <item>
191       <xsl:for-each select="authoring:entry">
192         <xsl:choose>
193           <xsl:when test="position() = 1">
194             <term>
195               <xsl:apply-templates />
196             </term>
197           </xsl:when>
198           <xsl:otherwise>
199             <description>
200               <xsl:apply-templates />
201             </description>
202           </xsl:otherwise>
203         </xsl:choose>
204       </xsl:for-each>
205     </item>
206   </xsl:template>
207
208   <xsl:template match="authoring:list">
209     <list type="{@class}">
210       <xsl:apply-templates />
211     </list>
212   </xsl:template>
213
214   <xsl:template match="authoring:listItem">
215     <item><term>
216       <xsl:apply-templates />
217     </term></item>
218   </xsl:template>
219
220   <xsl:template match="authoring:alert">
221     <block subset="none" type="note">
222       <xsl:apply-templates />
223     </block>
224   </xsl:template>
225
226   <xsl:template match="authoring:permissions">
227     <xsl:apply-templates />
228   </xsl:template>
229
230   <xsl:template match="authoring:permission">
231     <permission cref="{authoring:codeEntityReference}">
232       <xsl:apply-templates select="authoring:content" />
233     </permission>
234   </xsl:template>
235
236   <xsl:template match="authoring:threadSafety">
237     <threadsafe>
238       <xsl:apply-templates />
239     </threadsafe>
240   </xsl:template>
241
242   <xsl:template match="authoring:embeddedLabel">
243     <i>
244       <xsl:value-of select="*" />
245       <xsl:text>:</xsl:text>
246     </i>
247   </xsl:template>
248
249   <xsl:template match="authoring:token">
250     <xsl:choose>
251       <xsl:when test=". = 'compact_v20_long'">
252         <xsl:text>.NET Compact Framework version 2.0</xsl:text>
253       </xsl:when>
254       <xsl:when test=". = 'compact_v35_long'">
255         <xsl:text>.NET Compact Framework version 3.5</xsl:text>
256       </xsl:when>
257       <xsl:when test=". = 'dnprdnext'">
258         <xsl:text>.NET Framework version 2.0</xsl:text>
259       </xsl:when>
260       <xsl:when test=". = 'vbprvbext'">
261         <xsl:text>Microsoft Visual Basic 2005</xsl:text>
262       </xsl:when>
263       <xsl:when test=". = 'vbprvblong'">
264         <xsl:text>Visual Basic 2005</xsl:text>
265       </xsl:when>
266       <xsl:otherwise>
267         <xsl:text>UNKNOWN_TOKEN(</xsl:text>
268         <xsl:value-of select="." />
269         <xsl:text>)</xsl:text>
270       </xsl:otherwise>
271     </xsl:choose>
272   </xsl:template>
273
274   <!-- cute trick to remove the xmlns attributes on copied nodes. -->
275   <xsl:template match="*">
276     <xsl:element name="{local-name()}">
277       <xsl:apply-templates />
278     </xsl:element>
279   </xsl:template>
280 </xsl:stylesheet>
281