forked from usnistgov/metaschema-xslt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
METASCHEMA-DOCS-TRACE.xpl
404 lines (334 loc) · 16 KB
/
METASCHEMA-DOCS-TRACE.xpl
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step"
version="1.0" xmlns:metaschema="http://csrc.nist.gov/ns/metaschema/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" type="metaschema:metaschema-docs-trace"
name="metaschema-docs-trace">
<!-- Purpose: Emit XML and JSON-oriented metaschema documentation -->
<!-- Input: A valid and correct OSCAL Metaschema instance linked to its modules (also valid and correct) -->
<!-- Input: options 'path' and 'metaschema-id' must be set, to populate a/@href in crosslinks -->
<!-- Output: Ports expose standalone (and linked) HTML for analysis -->
<!-- Note: This is for debugging; see METASCHEMA-HTML-DOCS.xpl for build runtime XProc -->
<!-- NIST/ITL Metaschema github.com/usnistgov/metaschema https://pages.nist.gov/metaschema/ -->
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Ports -->
<p:input port="METASCHEMA" primary="true"/>
<p:input port="parameters" kind="parameter"/>
<!--<p:option name="metaschema-id" select="'oscal'"/>-->
<p:option name="metaschema-id" select="'oscal_catalog_metaschema'"/>
<p:option name="json-outline-filename" select="'json-outline.html'"/>
<p:option name="json-reference-filename" select="'json-reference.html'"/>
<p:option name="json-index-filename" select="'json-index.html'"/>
<p:option name="json-definitions-filename" select="'json-definitions.html'"/>
<p:option name="xml-outline-filename" select="'xml-outline.html'"/>
<p:option name="xml-reference-filename" select="'xml-reference.html'"/>
<p:option name="xml-index-filename" select="'xml-index.html'"/>
<p:option name="xml-definitions-filename" select="'xml-definitions.html'"/>
<!-- preview ports permit examining pipeline inputs -->
<p:serialization port="INT_0_echo-input" indent="true"/>
<p:output port="INT_0_echo-input" primary="false">
<p:pipe port="result" step="input"/>
</p:output>
<p:serialization port="INT_1_composed" indent="true"/>
<p:output port="INT_1_composed" primary="false">
<p:pipe port="result" step="composed"/>
</p:output>
<p:serialization port="INT_2_abstract-model-map" indent="true"/>
<p:output port="INT_2_abstract-model-map" primary="false">
<p:pipe port="result" step="make-abstract-map"/>
</p:output>
<p:serialization port="INT_3_unfolded-instance-map" indent="true"/>
<p:output port="INT_3_unfolded-instance-map" primary="false">
<p:pipe port="result" step="unfold-instance-map"/>
</p:output>
<p:serialization port="INT_4_marked-instance-map" indent="true"/>
<p:output port="INT_4_marked-instance-map" primary="false">
<p:pipe port="result" step="annotate-instance-map"/>
</p:output>
<p:serialization port="JSON-object-tree-xml" indent="true"/>
<p:output port="JSON-object-tree-xml" primary="false">
<p:pipe port="result" step="make-json-object-tree"/>
</p:output>
<p:serialization port="JSON-object-map-div" indent="true"/>
<p:output port="JSON-object-map-div" primary="false">
<p:pipe port="result" step="make-json-model-map"/>
</p:output>
<p:serialization port="JSON-object-map-html" indent="true"/>
<p:output port="JSON-object-map-html" primary="false">
<p:pipe port="result" step="style-json-model-map"/>
</p:output>
<p:serialization port="JSON-object-reference-div" indent="true"/>
<p:output port="JSON-object-reference-div" primary="false">
<p:pipe port="result" step="render-json-object-reference"/>
</p:output>
<p:serialization port="JSON-object-reference-html" indent="true"/>
<p:output port="JSON-object-reference-html" primary="false">
<p:pipe port="result" step="style-json-object-reference"/>
</p:output>
<p:serialization port="JSON-object-index-div" indent="true"/>
<p:output port="JSON-object-index-div" primary="false">
<p:pipe port="result" step="render-json-object-index"/>
</p:output>
<p:serialization port="JSON-object-index-html" indent="true"/>
<p:output port="JSON-object-index-html" primary="false">
<p:pipe port="result" step="style-json-object-index"/>
</p:output>
<p:serialization port="JSON-definitions-div" indent="true"/>
<p:output port="JSON-definitions-div" primary="false">
<p:pipe port="result" step="render-json-definitions"/>
</p:output>
<p:serialization port="JSON-definitions-html" indent="true"/>
<p:output port="JSON-definitions-html" primary="false">
<p:pipe port="result" step="style-json-definitions"/>
</p:output>
<p:serialization port="XML-element-tree-xml" indent="true"/>
<p:output port="XML-element-tree-xml" primary="false">
<p:pipe port="result" step="make-xml-element-tree"/>
</p:output>
<p:serialization port="XML-element-map-div" indent="true"/>
<p:output port="XML-element-map-div" primary="false">
<p:pipe port="result" step="make-xml-model-map"/>
</p:output>
<p:serialization port="XML-element-map-html" indent="true"/>
<p:output port="XML-element-map-html" primary="false">
<p:pipe port="result" step="style-xml-model-map"/>
</p:output>
<p:serialization port="XML-element-reference-div" indent="true"/>
<p:output port="XML-element-reference-div" primary="false">
<p:pipe port="result" step="render-xml-element-reference"/>
</p:output>
<p:serialization port="XML-element-reference-html" indent="true"/>
<p:output port="XML-element-reference-html" primary="false">
<p:pipe port="result" step="style-xml-element-reference"/>
</p:output>
<p:serialization port="XML-element-index-div" indent="true"/>
<p:output port="XML-element-index-div" primary="false">
<p:pipe port="result" step="render-xml-element-index"/>
</p:output>
<p:serialization port="XML-element-index-html" indent="true"/>
<p:output port="XML-element-index-html" primary="false">
<p:pipe port="result" step="style-xml-element-index"/>
</p:output>
<p:serialization port="XML-definitions-div" indent="true"/>
<p:output port="XML-definitions-div" primary="false">
<p:pipe port="result" step="render-xml-definitions"/>
</p:output>
<p:serialization port="XML-definitions-html" indent="true"/>
<p:output port="XML-definitions-html" primary="false">
<p:pipe port="result" step="style-xml-definitions"/>
</p:output>
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Import (subpipeline) -->
<p:import href="../compose/metaschema-compose.xpl"/>
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Pipeline -->
<p:identity name="input"/>
<metaschema:metaschema-compose name="compose"/>
<p:identity name="composed"/>
<!--<p:identity name="render-xml-model-map"/>-->
<!--<p:xslt name="annotate-composition">
<p:input port="stylesheet">
<p:document href="compose/annotate-composition.xsl"/>
</p:input>
</p:xslt>-->
<p:xslt name="make-abstract-map">
<p:input port="stylesheet">
<p:document href="../compose/make-model-map.xsl"/>
</p:input>
</p:xslt>
<!-- next step unfolds map (making groups into wrappers)
and expands identifiers -->
<p:xslt name="unfold-instance-map">
<p:input port="stylesheet">
<p:document href="../compose/unfold-model-map.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="annotate-instance-map">
<p:input port="stylesheet">
<p:document href="../compose/annotate-model-map.xsl"/>
</p:input>
</p:xslt>
<!--Making the XML model map -->
<p:xslt name="make-xml-element-tree">
<!--<p:input port="source">
<p:pipe port="result" step="unfold-model-map"/>
</p:input>-->
<p:input port="stylesheet">
<p:document href="xml/element-tree.xsl"/>
</p:input>
</p:xslt>
<p:xslt name="make-xml-model-map">
<p:input port="stylesheet">
<p:document href="xml/element-map-html.xsl"/>
</p:input>
<p:with-param name="outline-page" select="$xml-outline-filename"/>
<p:with-param name="reference-page" select="$xml-reference-filename"/>
</p:xslt>
<p:xslt name="style-xml-model-map">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="with-toc" select="'no'"/>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
</p:xslt>
<!-- Done with that. -->
<p:sink/>
<p:xslt name="render-xml-element-reference">
<p:input port="source">
<p:pipe port="result" step="make-xml-element-tree"/>
</p:input>
<p:input port="stylesheet">
<p:document href="xml/element-reference-html.xsl"/>
</p:input>
<p:with-param name="xml-reference-page" select="$xml-reference-filename"/>
<p:with-param name="xml-definitions-page" select="$xml-definitions-filename"/>
<p:with-param name="json-reference-page" select="$json-reference-filename"/>
<p:with-param name="xml-map-page" select="$xml-outline-filename"/>
</p:xslt>
<!-- Wrapping this up to write and view locally/standalone if wanted -->
<p:xslt name="style-xml-element-reference">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
</p:xslt>
<p:sink/>
<!-- The JSON object index is produced from the full blown out instance tree
as already rendered into HTML -->
<p:xslt name="render-xml-element-index">
<p:input port="source">
<p:pipe port="result" step="make-xml-element-tree"/>
</p:input>
<!--<p:with-option name="initial-mode" select="QName('','make-page')"/>-->
<p:input port="stylesheet">
<p:document href="xml/element-index-html.xsl"/>
</p:input>
<p:with-param name="index-page" select="$xml-index-filename"/>
<p:with-param name="reference-page" select="$xml-reference-filename"/>
<p:with-param name="definitions-page" select="$xml-definitions-filename"/>
</p:xslt>
<p:xslt name="style-xml-element-index">
<!--<p:with-option name="initial-mode" select="QName('','make-page')"/>-->
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
</p:xslt>
<p:sink/>
<!-- For the straight-up definitions directory we go back to the composed metaschema before explosion -->
<p:xslt name="render-xml-definitions">
<p:input port="source">
<p:pipe port="result" step="composed"/>
</p:input>
<p:input port="stylesheet">
<!-- XXX fix up / reduce this XSLT (from RC2) -->
<p:document href="xml/xml-definitions.xsl"/>
</p:input>
<p:with-param name="xml-definitions-page" select="$xml-definitions-filename"/>
<p:with-param name="json-definitions-page" select="$json-definitions-filename"/>
<p:with-param name="xml-reference-page" select="$xml-reference-filename"/>
</p:xslt>
<p:xslt name="style-xml-definitions">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
</p:xslt>
<p:sink/>
<!-- JSON pipelines start here -->
<!-- A representation of the JSON object tree is rendered out from the unfolded blown out model map -->
<p:xslt name="make-json-object-tree">
<p:input port="source">
<p:pipe port="result" step="annotate-instance-map"/>
</p:input>
<p:input port="stylesheet">
<p:document href="json/object-tree.xsl"/>
</p:input>
</p:xslt>
<!-- From this, we first make the model map (ready to inject into the web build) -->
<p:xslt name="make-json-model-map">
<p:input port="stylesheet">
<p:document href="json/object-map-html.xsl"/>
</p:input>
<p:with-param name="outline-page" select="$json-outline-filename"/>
<p:with-param name="reference-page" select="$json-reference-filename"/>
</p:xslt>
<!-- Next we wrap this up to write and view locally/standalone if wanted -->
<p:xslt name="style-json-model-map">
<!--<p:with-option name="initial-mode" select="QName('','make-page')"/>-->
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="with-toc" select="'no'"/>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
<p:with-param name="format" select="'json'"/>
</p:xslt>
<!-- Done with that. -->
<p:sink/>
<!--Next, picking up from the object tree we make the main reference document -->
<!-- Making page contents for site -->
<p:xslt name="render-json-object-reference">
<p:input port="source">
<p:pipe port="result" step="make-json-object-tree"/>
</p:input>
<!--<p:with-option name="initial-mode" select="QName('','make-page')"/>-->
<p:input port="stylesheet">
<p:document href="json/object-reference-html.xsl"/>
</p:input>
<p:with-param name="json-reference-page" select="$json-reference-filename"/>
<p:with-param name="json-definitions-page" select="$json-definitions-filename"/>
<p:with-param name="xml-reference-page" select="$xml-reference-filename"/>
<p:with-param name="json-map-page" select="$json-outline-filename"/>
</p:xslt>
<!-- Wrapping this up to write and view locally/standalone if wanted -->
<p:xslt name="style-json-object-reference">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
<p:with-param name="format" select="'json'"/>
</p:xslt>
<p:sink/>
<!-- The JSON object index is produced from the full blown out instance tree
as already rendered into HTML -->
<p:xslt name="render-json-object-index">
<!--<p:with-option name="initial-mode" select="QName('','make-page')"/>-->
<p:input port="source">
<p:pipe port="result" step="make-json-object-tree"/>
</p:input>
<p:input port="stylesheet">
<p:document href="json/object-index-html.xsl"/>
</p:input>
<p:with-param name="index-page" select="$json-index-filename"/>
<p:with-param name="reference-page" select="$json-reference-filename"/>
<p:with-param name="definitions-page" select="$json-definitions-filename"/>
</p:xslt>
<p:xslt name="style-json-object-index">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
<p:with-param name="format" select="'json'"/>
</p:xslt>
<p:sink/>
<!-- For the straight-up definitions directory we go back to the composed metaschema before explosion -->
<p:xslt name="render-json-definitions">
<p:input port="source">
<p:pipe port="result" step="composed"/>
</p:input>
<p:input port="stylesheet">
<!-- XXX fix up / reduce this XSLT (from RC2) -->
<p:document href="json/json-definitions.xsl"/>
</p:input>
<p:with-param name="json-definitions-page" select="$json-definitions-filename"/>
<p:with-param name="xml-definitions-page" select="$xml-definitions-filename"/>
<p:with-param name="json-reference-page" select="$json-reference-filename"/>
</p:xslt>
<p:xslt name="style-json-definitions">
<p:input port="stylesheet">
<p:document href="common/hugo-css-emulator.xsl"/>
</p:input>
<p:with-param name="metaschema-code" select="$metaschema-id"/>
<p:with-param name="format" select="'json'"/>
</p:xslt>
<p:sink/>
</p:declare-step>