blob: 3a1c510809f9e19d5f91b2ef4313b9a45682ba60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
<!-- project name something like "fxref" -->
<xsl:param name="projectName" />
<!-- can be assembly or namespace for HXT generation -->
<xsl:param name="createBy" />
<!-- Maximum project length allowed. Below is the default provided by paorear, bug 230840 -->
<xsl:param name="maxProjectNameLength" select="49" />
<xsl:output indent="yes" encoding="UTF-8" doctype-system="MS-Help://Hx/Resources/HelpTOC.dtd" />
<xsl:variable name="leftLength" select="$maxProjectNameLength div 2 - 1" />
<xsl:variable name="rightLength" select="$maxProjectNameLength - $leftLength - 2" />
<xsl:variable name="projectPrefix">
<xsl:if test="boolean($projectName)">
<xsl:value-of select="concat($projectName,'_')"/>
</xsl:if>
</xsl:variable>
<xsl:template match="/">
<HelpTOC DTDVersion="1.0">
<xsl:choose>
<xsl:when test="$createBy = 'assembly'">
<xsl:apply-templates select="/reflection/assemblies/assembly">
<xsl:sort select="@name" />
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/reflection/apis/api[apidata/@group='namespace']">
<xsl:sort select="apidata/@name" />
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</HelpTOC>
</xsl:template>
<!-- Apply the template for assembly level -->
<xsl:template match="assembly">
<xsl:variable name="componentName">
<xsl:call-template name="GetComponentName">
<xsl:with-param name="initialName" select="concat($projectPrefix, @name)" />
</xsl:call-template>
</xsl:variable>
<HelpTOCNode NodeType="TOC" Url="{$componentName}" />
</xsl:template>
<!-- Apply the template for namespace level -->
<xsl:template match="api[apidata/@group='namespace']">
<xsl:variable name="componentName">
<xsl:call-template name="GetComponentName">
<xsl:with-param name="initialName">
<xsl:choose>
<xsl:when test="apidata/@name = ''">
<xsl:value-of select="concat($projectPrefix, 'default_namespace')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($projectPrefix, apidata/@name)" />
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<HelpTOCNode NodeType="TOC" Url="{$componentName}" />
</xsl:template>
<!-- logic to shorten component names if needed -->
<xsl:template name="GetComponentName">
<xsl:param name="initialName" />
<xsl:variable name="componentNameLength" select="string-length($initialName)" />
<xsl:choose>
<xsl:when test="$componentNameLength >= $maxProjectNameLength">
<xsl:variable name="left" select="substring($initialName, 1, $leftLength)" />
<xsl:variable name="right" select="substring($initialName, $componentNameLength - $rightLength)" />
<xsl:value-of select="concat($left,'_',$right)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$initialName" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|