blob: 5204996ad2082b079bbbe3acd386e099fed4ff78 (
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
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
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output indent="yes" encoding="UTF-8" />
<!-- <xsl:key name="typeIndex" match="/reflection/types/type" use="@id" /> -->
<xsl:key name="defaultContructorIndex" match="/*/apis/api[apidata[@subgroup='constructor'] and not(parameters) and memberdata[@visibility='public']]" use="@id" />
<xsl:key name="typeIndex" match="/*/apis/api[apidata[@group='type']]" use="@id" />
<xsl:key name="settablePropertyIndex" match="/*/apis/api[apidata[@subgroup='property']][propertydata[@set='true']][(memberdata[@visibility='public'] and not(propertydata[@set-visibility!='public'])) or propertydata[@set-visibility='public']]" use="@id" />
<xsl:template match="/">
<reflection>
<!-- assemblies and namespaces get copied undisturbed -->
<xsl:copy-of select="/*/assemblies" />
<apis>
<xsl:apply-templates select="/*/apis/api" />
</apis>
</reflection>
</xsl:template>
<xsl:template match="api">
<xsl:choose>
<xsl:when test="apidata[@group='type']">
<xsl:call-template name="updateTypeNode"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="GetContentProperty">
<xsl:if test="apidata[@subgroup='class' or @subgroup='structure']">
<xsl:variable name="contentPropertyName">
<xsl:value-of select="attributes/attribute[type[contains(@api,'.ContentPropertyAttribute')]]/argument/value"/>
</xsl:variable>
<xsl:if test="$contentPropertyName!=''">
<xsl:value-of select="concat('P:',substring-after(@id,'T:'),'.',$contentPropertyName)"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="updateTypeNode">
<xsl:variable name="defaultConstructor">
<xsl:if test="apidata[@subgroup='class' or @subgroup='structure']">
<xsl:for-each select="elements/element">
<xsl:if test="key('defaultContructorIndex',@api)">
<xsl:value-of select="@api"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:variable>
<xsl:variable name="hasSettableProperties">
<xsl:if test="apidata[@subgroup='structure']">
<xsl:for-each select="elements/element">
<xsl:if test="key('settablePropertyIndex',@api)">true</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:variable>
<xsl:variable name="contentPropertyId">
<xsl:call-template name="GetContentProperty"/>
</xsl:variable>
<xsl:variable name="typeSubGroup">
<xsl:value-of select="apidata/@subgroup"/>
</xsl:variable>
<api>
<xsl:copy-of select="@*"/>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="local-name()='typedata'">
<typedata>
<xsl:copy-of select="@*"/>
<xsl:if test="normalize-space($defaultConstructor)!=''">
<xsl:attribute name="defaultConstructor">
<xsl:value-of select="normalize-space($defaultConstructor)"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$contentPropertyId!=''">
<xsl:attribute name="contentProperty">
<xsl:value-of select="$contentPropertyId"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$typeSubGroup='structure' and normalize-space($hasSettableProperties)=''">
<xsl:attribute name="noSettableProperties">
<xsl:value-of select="'true'"/>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="*"/>
</typedata>
</xsl:when>
<xsl:when test="local-name()='family'">
<xsl:choose>
<xsl:when test="$contentPropertyId=''">
<family>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="local-name()='ancestors'">
<ancestors>
<xsl:for-each select="type">
<xsl:variable name="ancestorContentPropertyId">
<xsl:for-each select="key('typeIndex', @api)">
<xsl:call-template name="GetContentProperty"/>
</xsl:for-each>
</xsl:variable>
<type>
<xsl:copy-of select="@*"/>
<xsl:if test="$ancestorContentPropertyId!=''">
<xsl:attribute name="contentProperty">
<xsl:value-of select="$ancestorContentPropertyId"/>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="*"/>
</type>
</xsl:for-each>
</ancestors>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</family>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</api>
</xsl:template>
</xsl:stylesheet>
|