1<?xml version='1.0'?>
2<xsl:stylesheet version='1.0'
3                xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
4		xmlns='http://www.w3.org/TR/xhtml1/strict'>
5
6<!--<xsl:key name="decl" match="type-decl" use="@name" />-->
7
8
9<!-- MACRO get-module-uri: Given an element with an attribute `module',
10     produces the URI for the module's HTML document.  The attribute is
11     taken as a module's alias name and resolved using the import declarations.
12     Result is empty if no alias name is given.  -->
13<xsl:template name="get-module-uri">
14  <xsl:variable name="alias" select="@module"/>
15
16  <xsl:if test="$alias != ''">
17    <xsl:for-each select="/interface-description/import-decl[$alias=@name]">
18      <xsl:variable name="module" select="@module"/>
19      <xsl:value-of select="../module-ref[@name=$module]/
20                                ref-target[@type='html']/@relative-uri"/>
21    </xsl:for-each>
22  </xsl:if>
23</xsl:template>
24
25
26<xsl:template match="text()|@*" mode="decl-anchor"/>
27<xsl:template match="const-decl|type-decl|var-decl|procedure|field-decl|receiver-decl|parameter-decl" mode="decl-anchor">
28  <xsl:param name='prefix'/>
29
30  <a name="{concat($prefix,@id)}">
31<!--    <xsl:text> [ANCHOR </xsl:text>
32    <xsl:value-of select="@id"/>
33    <xsl:text>] </xsl:text>-->
34  </a>
35</xsl:template>
36
37
38<!-- MACRO decl-href: Given a declaration element, write an href anchor tag
39     pointing to the declaration.  If the parameter `content' is defined,
40     use its value as the anchor content.  Otherwise, use the attribute
41     `name' of the declaration.  -->
42<xsl:template match="const-decl|type-decl|var-decl|procedure|field-decl|receiver-decl|parameter-decl" mode="decl-href">
43  <xsl:param name="content" select="@name"/>
44  <xsl:param name='prefix' select="''"/>
45
46  <b>
47    <a href="#{concat($prefix, @id)}">
48<!--      <xsl:text>[HREF #</xsl:text>
49      <xsl:value-of select="@id"/>
50      <xsl:text>] </xsl:text>-->
51      <xsl:value-of select="$content"/>
52    </a>
53  </b>
54</xsl:template>
55<xsl:template match="text()|@*" mode="decl-href"/>
56
57
58
59<!-- MACRO ext-ref-type: Given an element `type-name', emit a href to the
60     type's declaration.  -->
61<xsl:template match="type-name" mode="ext-ref-type">
62  <a>
63    <xsl:attribute name="href">
64      <xsl:call-template name="get-module-uri"/>
65      <xsl:text>#</xsl:text>
66      <xsl:value-of select="@name"/>
67    </xsl:attribute>
68<!--    <xsl:text>[HREF </xsl:text>
69    <xsl:value-of select="@module"/>
70    <xsl:text>.</xsl:text>
71    <xsl:value-of select="@name"/>
72    <xsl:text>] </xsl:text>-->
73    <xsl:value-of select="@name"/>
74  </a>
75</xsl:template>
76
77
78<!-- MACRO ref-base-obj: Given a matching element, emit a href to the class or
79     the indicated object.  -->
80<xsl:template match="base-class|inherited-field|
81                     inherited-method|redefined-method|
82                     doc-inherited-from|known-extension"
83              mode="ref-base-obj">
84  <xsl:variable name="module-name" select="@module"/>
85
86  <a>
87    <xsl:attribute name="href">
88      <xsl:variable name="fragment" select="substring-after(@href, '#')"/>
89      <xsl:value-of select="concat(
90        /interface-description/module-ref[@name=$module-name]/ref-target[@type='html']/@relative-uri,
91        '#', $fragment)"/>
92    </xsl:attribute>
93
94    <xsl:choose>
95      <xsl:when test="@name">
96        <xsl:value-of select="@name"/>
97      </xsl:when>
98
99      <xsl:otherwise>
100        <xsl:value-of select="concat(@module, '.')"/>
101        <b><xsl:value-of select="@class"/></b>
102      </xsl:otherwise>
103    </xsl:choose>
104  </a>
105</xsl:template>
106
107
108</xsl:stylesheet>
109