-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathClassHeader.xslt
185 lines (182 loc) · 6.58 KB
/
ClassHeader.xslt
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="UTF-8"?>
<!--
ADOBE SYSTEMS INCORPORATED
Copyright 2008 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://sf.net/saxon" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ifn="urn:internal:functions" exclude-result-prefixes="saxon xs ifn">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="baseclass" match="apiClassifier" use=".//apiBaseClassifier/text()"/>
<xsl:key name="id" match="//apiClassifier" use="@id"/>
<xsl:key name="idg" match="//apiClassifier" use="substring-after(@id,':')"/>
<xsl:key name="baseInter" match="//apiBaseInterface" use="text()"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="apiPackage">
<apiPackage id="{@id}">
<apiName>
<xsl:value-of select="@id"/>
</apiName>
<xsl:copy-of select="./apiDetail"/>
<xsl:apply-templates select="apiClassifier"/>
</apiPackage>
</xsl:template>
<xsl:template match="apiClassifier">
<apiClassifier id="{@id}">
<apiName>
<xsl:value-of select="./apiName"/>
</apiName>
<xsl:apply-templates select="shortdesc"/>
<xsl:apply-templates select="prolog"/>
<xsl:apply-templates select="Keywords" mode="keys"/>
<xsl:apply-templates select="apiClassifierDetail"/>
<xsl:apply-templates select="related-links"/>
</apiClassifier>
</xsl:template>
<xsl:template match="apiClassifierDetail">
<apiClassifierDetail>
<xsl:apply-templates select="node()"/>
<Inheritancelist>
<BaseInterface>
<xsl:if test="./apiClassifierDef/apiInterface and ./apiClassifierDef/apiBaseInterface">
<xsl:for-each select="./apiClassifierDef/apiBaseInterface">
<xsl:sort select="substring-after(./apiClassifierDef/apiBaseInterface/.,':')" order="ascending" data-type="text"/>
<Interface id="{.}"/>
</xsl:for-each>
<xsl:call-template name="nested"/>
</xsl:if>
</BaseInterface>
<Inheritance>
<xsl:variable name="baseClass" select=".//apiBaseClassifier/text()"/>
<xsl:for-each select=".//apiBaseClassifier">
<Inherit id="{$baseClass}"/>
</xsl:for-each>
<xsl:call-template name="inheritList">
<xsl:with-param name="base" select="$baseClass"/>
</xsl:call-template>
</Inheritance>
<Implements>
<xsl:for-each select=".//apiBaseInterface">
<Implement id="{@*|node()}"/>
</xsl:for-each>
</Implements>
<Subclasses>
<xsl:variable name="apiClass" select="ancestor::apiClassifier/@id"/>
<xsl:variable name="apiClassGlb" select="substring-after($apiClass,'globalClassifier:')"/>
<xsl:for-each select="key('baseclass', $apiClass)">
<class id="{@id}"/>
</xsl:for-each>
<xsl:for-each select="key('baseclass', $apiClassGlb)">
<class id="{@id}"/>
</xsl:for-each>
</Subclasses>
<Implementors>
<xsl:if test=".//apiInterface">
<xsl:variable name="apiClass" select="ancestor::apiClassifier/@id"/>
<xsl:for-each select="key('baseInter',$apiClass)">
<xsl:sort select="substring-after(ancestor::apiClassifier/@id,':')" order="ascending"/>
<xsl:if test="not(parent::apiClassifierDef/apiInterface)">
<Implementor id="{ancestor::apiClassifier/@id}"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</Implementors>
<Excludes>
<xsl:copy-of select="ancestor::apiClassifier/Excludes/Exclude"/>
<xsl:for-each select=".//apiBaseClassifier">
<xsl:call-template name="getexcludes"/>
</xsl:for-each>
</Excludes>
</Inheritancelist>
</apiClassifierDetail>
</xsl:template>
<xsl:template match="Keywords" mode="keys">
<xsl:apply-templates select="node()"/>
</xsl:template>
<xsl:template match="apiClassifierDef">
<apiClassifierDef>
<xsl:apply-templates select="node()"/>
</apiClassifierDef>
</xsl:template>
<xsl:template name="nested">
<xsl:variable name="apiBaseInter" select=".//apiBaseInterface/."/>
<xsl:for-each select="key('id', $apiBaseInter)/apiClassifierDetail/apiClassifierDef/apiBaseInterface">
<xsl:variable name="nested.apiBaseInter" select="."/>
<xsl:choose>
<xsl:when test="$apiBaseInter=$nested.apiBaseInter"/>
<xsl:otherwise>
<Interface id="{.}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:call-template name="sub-nested"/>
</xsl:template>
<xsl:template name="sub-nested">
<xsl:variable name="apiBaseInter" select=".//apiBaseInterface/."/>
<xsl:variable name="subnested.apiBaseInter" select="key('id', $apiBaseInter)/apiClassifierDetail/apiClassifierDef/apiBaseInterface"/>
<xsl:for-each select="key('id', $subnested.apiBaseInter)/apiClassifierDetail/apiClassifierDef/apiBaseInterface">
<xsl:variable name="nested.apiBaseInter" select="."/>
<xsl:choose>
<xsl:when test="$subnested.apiBaseInter=$nested.apiBaseInter"/>
<xsl:otherwise>
<Interface id="{.}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="inheritList">
<xsl:param name="base"/>
<xsl:variable name="match">
<xsl:if test="contains($base,':')">
<xsl:value-of select="$base"/>
</xsl:if>
<xsl:if test="not(contains($base,':'))">
<xsl:text>globalClassifier:</xsl:text>
<xsl:value-of select="$base"/>
</xsl:if>
</xsl:variable>
<xsl:for-each select="key('id',$match)">
<xsl:variable name="find" select=".//apiBaseClassifier/."/>
<xsl:if test=".//apiBaseClassifier/.">
<Inherit id="{$find}"/>
</xsl:if>
<xsl:if test="not($find='Object')">
<xsl:call-template name="inheritList">
<xsl:with-param name="base" select="$find"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="getexcludes">
<xsl:for-each select="key('id', ./text())">
<xsl:copy-of select=".//Excludes/Exclude"/>
<xsl:for-each select=".//apiBaseClassifier">
<xsl:call-template name="getexcludes"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="shortdesc">
<shortdesc>
<xsl:apply-templates select="node()"/>
</shortdesc>
</xsl:template>
<xsl:template match="prolog">
<prolog>
<xsl:apply-templates select="node()"/>
</prolog>
</xsl:template>
<xsl:template match="related-links">
<related-links>
<xsl:apply-templates select="node()"/>
</related-links>
</xsl:template>
<xsl:template match="node()">
<xsl:copy copy-namespaces="no">
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>