PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/Source/Sandcastle/ProductionTransforms/CreatePrototypeToc.xsl

#
Extensible Stylesheet Language Transformations | 142 lines | 130 code | 12 blank | 0 comment | 0 complexity | d9b7f70329932baef3cdde246b2d9b43 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
  3. <xsl:param name="segregated" select="false()" />
  4. <xsl:output indent="yes" />
  5. <xsl:key name="index" match="/reflection/apis/api" use="@id" />
  6. <xsl:template match="/">
  7. <topics>
  8. <xsl:choose>
  9. <xsl:when test="count(/reflection/apis/api[apidata/@group='root']) > 0">
  10. <xsl:apply-templates select="/reflection/apis/api[apidata/@group='root']" />
  11. </xsl:when>
  12. <xsl:when test="count(/reflection/apis/api[apidata/@group='namespace']) > 0">
  13. <xsl:apply-templates select="/reflection/apis/api[apidata/@group='namespace']">
  14. <xsl:sort select="apidata/@name" />
  15. </xsl:apply-templates>
  16. </xsl:when>
  17. <xsl:otherwise>
  18. <xsl:apply-templates select="/reflection/apis/api[apidata/@group='type']">
  19. <xsl:sort select="apidata/@name" />
  20. </xsl:apply-templates>
  21. </xsl:otherwise>
  22. </xsl:choose>
  23. </topics>
  24. </xsl:template>
  25. <!-- create a root entry and namespace sub-entries -->
  26. <xsl:template match="api[apidata/@group='root']">
  27. <topic id="{@id}" file="{file/@name}">
  28. <xsl:apply-templates select="key('index',elements/element/@api)">
  29. <xsl:sort select="apidata/@name" />
  30. </xsl:apply-templates>
  31. </topic>
  32. </xsl:template>
  33. <!-- for each namespace, create namespace entry and type sub-entries -->
  34. <xsl:template match="api[apidata/@group='namespace']">
  35. <topic id="{@id}" file="{file/@name}">
  36. <xsl:apply-templates select="key('index',elements/element/@api)">
  37. <xsl:sort select="@id" />
  38. </xsl:apply-templates>
  39. </topic>
  40. </xsl:template>
  41. <!-- for each type, create type entry and either overload entries or member entries as sub-entries -->
  42. <xsl:template match="api[apidata/@group='type']">
  43. <xsl:choose>
  44. <xsl:when test="$segregated">
  45. <stopic id="{@id}" project="{containers/library/@assembly}" file="{file/@name}">
  46. <xsl:call-template name="processType" />
  47. </stopic>
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <topic id="{@id}" file="{file/@name}">
  51. <xsl:call-template name="processType" />
  52. </topic>
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. <xsl:template name="processType">
  57. <xsl:variable name="typeId" select="@id" />
  58. <xsl:variable name="members" select="key('index',elements/element/@api)[containers/type/@api=$typeId]" />
  59. <xsl:for-each select="$members">
  60. <xsl:sort select="apidata/@name" />
  61. <xsl:variable name="name" select="apidata/@name" />
  62. <xsl:variable name="subgroup" select="apidata/@subgroup" />
  63. <xsl:variable name="set" select="$members[apidata/@name=$name and apidata/@subgroup=$subgroup]" />
  64. <xsl:choose>
  65. <xsl:when test="count($set) &gt; 1">
  66. <xsl:if test="($set[1]/@id)=@id">
  67. <xsl:variable name="overloadId">
  68. <xsl:value-of select="overload/@api" />
  69. </xsl:variable>
  70. <xsl:choose>
  71. <xsl:when test="$segregated">
  72. <stopic id="{@id}" project="{containers/library/@assembly}" file="{key('index',$overloadId)/file/@name}">
  73. <xsl:for-each select="$set">
  74. <xsl:apply-templates select="." />
  75. </xsl:for-each>
  76. </stopic>
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <topic id="{@id}" file="{key('index',$overloadId)/file/@name}">
  80. <xsl:for-each select="$set">
  81. <xsl:apply-templates select="." />
  82. </xsl:for-each>
  83. </topic>
  84. </xsl:otherwise>
  85. </xsl:choose>
  86. </xsl:if>
  87. </xsl:when>
  88. <xsl:otherwise>
  89. <xsl:apply-templates select="." />
  90. </xsl:otherwise>
  91. </xsl:choose>
  92. </xsl:for-each>
  93. </xsl:template>
  94. <!-- for each member, create a leaf entry -->
  95. <xsl:template match="api[apidata/@group='member']">
  96. <xsl:choose>
  97. <xsl:when test="$segregated">
  98. <stopic id="{@id}" project="{containers/library/@assembly}" file="{file/@name}" />
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <topic id="{@id}" file="{file/@name}" />
  102. </xsl:otherwise>
  103. </xsl:choose>
  104. </xsl:template>
  105. <xsl:template name="overloadId">
  106. <xsl:param name="memberId" />
  107. <xsl:text>Overload:</xsl:text>
  108. <xsl:variable name="noParameters">
  109. <xsl:choose>
  110. <xsl:when test="contains($memberId,'(')">
  111. <xsl:value-of select="substring-before($memberId,'(')" />
  112. </xsl:when>
  113. <xsl:otherwise>
  114. <xsl:value-of select="$memberId" />
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:variable>
  118. <xsl:variable name="noGeneric">
  119. <xsl:choose>
  120. <xsl:when test="contains($noParameters,'``')">
  121. <xsl:value-of select="substring-before($noParameters,'``')" />
  122. </xsl:when>
  123. <xsl:otherwise>
  124. <xsl:value-of select="$noParameters" />
  125. </xsl:otherwise>
  126. </xsl:choose>
  127. </xsl:variable>
  128. <xsl:value-of select="substring($noGeneric,3)" />
  129. </xsl:template>
  130. </xsl:stylesheet>