|
1 <?xml version="1.0"?> |
|
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="exslt"> |
|
3 <xsl:output method="xml" indent="yes"/> |
|
4 |
|
5 <!-- filter a sysdef (2.0 or 3.0 syntax)--> |
|
6 |
|
7 <xsl:param name="filter-type">only</xsl:param> <!-- only, has or with --> |
|
8 |
|
9 <xsl:param name="filter"/> <!-- comma-separated list --> |
|
10 |
|
11 <xsl:param name="addbuild" select="0"/> <!-- add a system build section that accepts everything --> |
|
12 |
|
13 |
|
14 <xsl:template match="node()|@*"><xsl:copy-of select="."/></xsl:template> |
|
15 <xsl:template match="*"><xsl:param name="data"/> |
|
16 <xsl:copy> |
|
17 <xsl:copy-of select="@*"/> |
|
18 <xsl:apply-templates select="node()"> |
|
19 <xsl:with-param name="data" select="$data"/> |
|
20 </xsl:apply-templates> |
|
21 </xsl:copy> |
|
22 </xsl:template> |
|
23 |
|
24 <xsl:template match="component|unit"><xsl:param name="data"/> <!-- filterable items --> |
|
25 <xsl:variable name="display"> |
|
26 <xsl:apply-templates select="$data" mode="filter"> |
|
27 <xsl:with-param name="item" select="current()"/> |
|
28 </xsl:apply-templates> |
|
29 </xsl:variable> |
|
30 |
|
31 <xsl:if test="$display != 'hide' "> <!-- if hide, remove completely from the output--> |
|
32 <xsl:copy> |
|
33 <xsl:copy-of select="@*"/> |
|
34 <xsl:apply-templates select="node()"> |
|
35 <xsl:with-param name="data" select="$data"/> |
|
36 </xsl:apply-templates> |
|
37 </xsl:copy> |
|
38 </xsl:if> |
|
39 </xsl:template> |
|
40 |
|
41 <xsl:template match="/SystemDefinition"> |
|
42 <xsl:variable name="f"> |
|
43 <xsl:element name="filter-{$filter-type}"> |
|
44 <xsl:call-template name="filter-list"> |
|
45 <xsl:with-param name="f" select="$filter"/> |
|
46 </xsl:call-template> |
|
47 </xsl:element> |
|
48 </xsl:variable> |
|
49 <xsl:choose> |
|
50 <xsl:when test="starts-with(@schema,'3.0')"/> <!-- no DTD needed for 3.0 sysdef --> |
|
51 <xsl:when test="$addbuild"> |
|
52 <xsl:call-template name="DTD-bld"/> <!-- insert 2.0.1 DTD w/sysbuild parts--> |
|
53 </xsl:when> |
|
54 <xsl:otherwise> |
|
55 <xsl:call-template name="DTD"/> <!-- insert 2.0.1 DTD --> |
|
56 </xsl:otherwise> |
|
57 </xsl:choose> |
|
58 <xsl:copy> |
|
59 <xsl:copy-of select="@*"/> |
|
60 <xsl:variable name="content"> <!-- save content for potential further processing --> |
|
61 <xsl:apply-templates select="node()"> |
|
62 <xsl:with-param name="data" select="exslt:node-set($f)/*"/> |
|
63 </xsl:apply-templates> |
|
64 </xsl:variable> |
|
65 <!-- just output content as is. We could create a template to remove any filtered out items, but so far there's no compelling need --> |
|
66 <xsl:copy-of select="$content"/> |
|
67 |
|
68 <xsl:if test="$addbuild"> |
|
69 <SystemBuild schema="1.0.0"> |
|
70 <configuration name="any" description="text"> |
|
71 <xsl:attribute name="filter"> |
|
72 <xsl:for-each select="//@filter[not(.=following::*/@filter)]"> |
|
73 <xsl:value-of select="."/><xsl:if test="position()!=last()">,</xsl:if> |
|
74 </xsl:for-each> |
|
75 </xsl:attribute> |
|
76 <xsl:for-each select="exslt:node-set($content)/systemModel/layer[descendant::unit]"> |
|
77 <!-- only include layers we know have units --> |
|
78 <ref item="{@name}"/> |
|
79 </xsl:for-each> |
|
80 </configuration> |
|
81 </SystemBuild> |
|
82 </xsl:if> |
|
83 </xsl:copy> |
|
84 </xsl:template> |
|
85 |
|
86 |
|
87 <xsl:include href="filter-module.xsl"/> |
|
88 |
|
89 <xsl:template name="DTD-bld"> |
|
90 <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE SystemDefinition [ |
|
91 <!ELEMENT SystemDefinition ( systemModel?, SystemBuild? )> |
|
92 <!ATTLIST SystemDefinition |
|
93 name CDATA #REQUIRED |
|
94 schema CDATA #REQUIRED> |
|
95 <!ELEMENT systemModel (layer+)> |
|
96 <!ELEMENT layer (block* | collection*)*> |
|
97 <!ATTLIST layer |
|
98 name CDATA #REQUIRED |
|
99 long-name CDATA #IMPLIED |
|
100 levels NMTOKENS #IMPLIED |
|
101 span CDATA #IMPLIED> |
|
102 <!ELEMENT block (subblock* | collection*)*> |
|
103 <!ATTLIST block |
|
104 levels NMTOKENS #IMPLIED |
|
105 span CDATA #IMPLIED |
|
106 level NMTOKEN #IMPLIED |
|
107 name CDATA #REQUIRED |
|
108 long-name CDATA #IMPLIED> |
|
109 <!ELEMENT subblock (collection)*> |
|
110 <!ATTLIST subblock |
|
111 name CDATA #REQUIRED |
|
112 long-name CDATA #IMPLIED> |
|
113 <!ELEMENT collection (component)*> |
|
114 <!ATTLIST collection |
|
115 name CDATA #REQUIRED |
|
116 long-name CDATA #IMPLIED |
|
117 level NMTOKEN #IMPLIED> |
|
118 <!ELEMENT component (unit)*> |
|
119 <!ATTLIST component |
|
120 name CDATA #REQUIRED |
|
121 long-name CDATA #IMPLIED |
|
122 deprecated CDATA #IMPLIED |
|
123 introduced CDATA #IMPLIED |
|
124 contract CDATA #IMPLIED |
|
125 plugin (Y|N) "N" |
|
126 filter CDATA #IMPLIED |
|
127 class NMTOKENS #IMPLIED |
|
128 supports CDATA #IMPLIED |
|
129 purpose ( optional | mandatory | development ) "optional"> |
|
130 <!ELEMENT unit EMPTY> |
|
131 <!ATTLIST unit |
|
132 mrp CDATA #IMPLIED |
|
133 filter CDATA #IMPLIED |
|
134 bldFile CDATA #IMPLIED |
|
135 root CDATA #IMPLIED |
|
136 version NMTOKEN #IMPLIED |
|
137 prebuilt NMTOKEN #IMPLIED |
|
138 late (Y|N) #IMPLIED |
|
139 priority CDATA #IMPLIED> |
|
140 <!ELEMENT SystemBuild (option* | target+ | targetList+ | list+ | configuration+)*> |
|
141 <!ATTLIST SystemBuild schema CDATA #REQUIRED> |
|
142 <!ELEMENT list (ref+)> |
|
143 <!ATTLIST list |
|
144 name ID #REQUIRED |
|
145 description CDATA #REQUIRED> |
|
146 <!ELEMENT ref EMPTY> |
|
147 <!ATTLIST ref item CDATA #REQUIRED> |
|
148 <!ELEMENT targetList EMPTY> |
|
149 <!ATTLIST targetList |
|
150 name ID #REQUIRED |
|
151 description CDATA #REQUIRED |
|
152 target IDREFS #REQUIRED> |
|
153 <!ELEMENT target EMPTY> |
|
154 <!ATTLIST target |
|
155 name ID #REQUIRED |
|
156 abldTarget CDATA #REQUIRED |
|
157 description CDATA #REQUIRED> |
|
158 <!ELEMENT option EMPTY> |
|
159 <!ATTLIST option |
|
160 name ID #REQUIRED |
|
161 abldOption CDATA #REQUIRED |
|
162 description CDATA #REQUIRED |
|
163 enable (Y | N ) #REQUIRED> |
|
164 <!ELEMENT configuration (listRef+ | ref+ | task+)*> |
|
165 <!ATTLIST configuration |
|
166 name ID #REQUIRED |
|
167 description CDATA #REQUIRED |
|
168 filter CDATA #REQUIRED> |
|
169 <!ELEMENT task (listRef* , (buildLayer | specialInstructions))> |
|
170 <!ELEMENT listRef EMPTY> |
|
171 <!ATTLIST listRef list CDATA #REQUIRED> |
|
172 <!ELEMENT buildLayer EMPTY> |
|
173 <!ATTLIST buildLayer |
|
174 command CDATA #REQUIRED |
|
175 targetList IDREFS #IMPLIED |
|
176 unitParallel (Y | N ) #REQUIRED |
|
177 targetParallel (Y | N ) "N"> |
|
178 <!ELEMENT specialInstructions EMPTY> |
|
179 <!ATTLIST specialInstructions |
|
180 name CDATA #REQUIRED |
|
181 cwd CDATA #REQUIRED |
|
182 root CDATA #IMPLIED |
|
183 command CDATA #REQUIRED> |
|
184 ]> |
|
185 ]]></xsl:text> |
|
186 </xsl:template> |
|
187 |
|
188 <xsl:template name="DTD"> |
|
189 <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE SystemDefinition [ |
|
190 <!ELEMENT SystemDefinition ( systemModel )> |
|
191 <!ATTLIST SystemDefinition |
|
192 name CDATA #REQUIRED |
|
193 schema CDATA #REQUIRED |
|
194 > |
|
195 <!-- all paths are relative to the environment variable specified by the root attribute, or SOURCEROOT if not. --> |
|
196 |
|
197 <!-- System Model Section of DTD --> |
|
198 <!ELEMENT systemModel (layer+)> |
|
199 |
|
200 <!ELEMENT layer (block* | collection*)*> |
|
201 <!-- Kernel Services, Base Services, OS Services, Etc --> |
|
202 <!ATTLIST layer |
|
203 name CDATA #REQUIRED |
|
204 long-name CDATA #IMPLIED |
|
205 levels NMTOKENS #IMPLIED |
|
206 span CDATA #IMPLIED |
|
207 > |
|
208 |
|
209 <!ELEMENT block (subblock* | collection*)*> |
|
210 <!-- Generic OS services, Comms Services, etc --> |
|
211 <!ATTLIST block |
|
212 levels NMTOKENS #IMPLIED |
|
213 span CDATA #IMPLIED |
|
214 level NMTOKEN #IMPLIED |
|
215 name CDATA #REQUIRED |
|
216 long-name CDATA #IMPLIED |
|
217 > |
|
218 |
|
219 <!ELEMENT subblock (collection)*> |
|
220 <!-- Cellular Baseband Services, Networking Services, etc --> |
|
221 <!ATTLIST subblock |
|
222 name CDATA #REQUIRED |
|
223 long-name CDATA #IMPLIED |
|
224 > |
|
225 |
|
226 <!ELEMENT collection (component)*> |
|
227 <!-- Screen Driver, Content Handling, etc --> |
|
228 <!ATTLIST collection |
|
229 name CDATA #REQUIRED |
|
230 long-name CDATA #IMPLIED |
|
231 level NMTOKEN #IMPLIED |
|
232 > |
|
233 |
|
234 <!ELEMENT component (unit)*> |
|
235 <!-- contains units or is a package or prebuilt --> |
|
236 <!ATTLIST component |
|
237 name CDATA #REQUIRED |
|
238 long-name CDATA #IMPLIED |
|
239 deprecated CDATA #IMPLIED |
|
240 introduced CDATA #IMPLIED |
|
241 contract CDATA #IMPLIED |
|
242 plugin (Y|N) "N" |
|
243 filter CDATA #IMPLIED |
|
244 class NMTOKENS #IMPLIED |
|
245 supports CDATA #IMPLIED |
|
246 purpose ( optional | mandatory | development ) "optional" |
|
247 > |
|
248 |
|
249 <!ELEMENT unit EMPTY > |
|
250 <!-- must be buildable (bld.inf) --> |
|
251 <!-- bldFile may someday be removed in favour of mrp --> |
|
252 <!ATTLIST unit |
|
253 mrp CDATA #IMPLIED |
|
254 filter CDATA #IMPLIED |
|
255 bldFile CDATA #IMPLIED |
|
256 root CDATA #IMPLIED |
|
257 version NMTOKEN #IMPLIED |
|
258 prebuilt NMTOKEN #IMPLIED |
|
259 late (Y|N) #IMPLIED |
|
260 priority CDATA #IMPLIED |
|
261 > |
|
262 ]> |
|
263 ]]></xsl:text> |
|
264 </xsl:template> |
|
265 </xsl:stylesheet> |