forked from usnistgov/metaschema-xslt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMETASCHEMA-INSPECTOR-XSLT.xpl
129 lines (108 loc) · 4.68 KB
/
METASCHEMA-INSPECTOR-XSLT.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
<?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:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:metaschema="http://csrc.nist.gov/ns/metaschema/1.0" type="metaschema:METASCHEMA-INSPECTOR-XSLT"
name="METASCHEMA-INSPECTOR-XSLT">
<!-- Purpose: Produces an Inspector XSLT -->
<!-- Input: A valid and correct OSCAL Metaschema instance linked to its modules (also valid and correct) -->
<!-- Output: Port `OUT_inspector-xslt` exposes an XSLT -->
<!-- Option: passing 'xslt-test' as 'skip' suppresses the test run of the result (via try/catch) - quieter when this is known to be bad -->
<p:option name="xslt-test" select="'okay'"/>
<!-- set to 'skip' to skip the testing -->
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Ports -->
<p:input port="METASCHEMA" primary="true"/>
<p:input port="parameters" kind="parameter"/>
<p:serialization port="INT_0_echo-input" indent="true"/>
<p:output port="INT_0_echo-input" primary="false">
<p:pipe port="result" step="metaschema-in"/>
</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="OUT_inspector-xslt" indent="true" method="xml" encoding="us-ascii"
omit-xml-declaration="false"/>
<p:output port="OUT_inspector-xslt" primary="true">
<p:pipe port="result" step="produce-inspector"/>
</p:output>
<p:serialization port="OUT_xslt-prooftest" indent="true" method="xml" encoding="us-ascii"
omit-xml-declaration="false"/>
<p:output port="OUT_xslt-prooftest">
<p:pipe port="result" step="final"/>
</p:output>
<!--<p:variable name="proof-checking" select="false()"/>-->
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Import (subpipeline) -->
<p:import href="../compose/metaschema-compose.xpl"/>
<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Pipeline -->
<p:identity name="metaschema-in"/>
<metaschema:metaschema-compose name="compose"/>
<p:identity name="composed"/>
<p:xslt name="produce-inspector">
<p:input port="stylesheet">
<p:document href="InspectorXSLT/generator/generate-inspector-xslt.xsl"/>
<!--<p:document href="../common/no-op.xsl"/>-->
</p:input>
</p:xslt>
<!-- We hear XProc 3.0 is even better with try/catch -->
<p:choose>
<p:when test="$xslt-test='skip'">
<p:xslt>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet version="3.0"
exclude-result-prefixes="#all">
<xsl:template match="/">
<MAYBE>XSLT generated but not proof-tested ...</MAYBE>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
</p:xslt>
</p:when>
<p:otherwise>
<p:try name="try-inspector">
<p:group>
<p:xslt name="check-inspector">
<p:input port="source">
<p:inline>
<x/>
</p:inline>
</p:input>
<p:input port="stylesheet">
<p:pipe port="result" step="produce-inspector"/>
<!-- <p:document href="../common/xslt-smoketest.xsl"/>-->
</p:input>
</p:xslt>
<p:xslt>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet version="3.0" exclude-result-prefixes="#all">
<xsl:template match="/">
<OKAY>Generated XSLT runs successfully on 'x' input</OKAY>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
</p:xslt>
</p:group>
<p:catch name="xslt-fail-catch">
<p:identity>
<p:input port="source">
<p:inline>
<ERROR>Generated XSLT fails to compile and run</ERROR>
</p:inline>
</p:input>
</p:identity>
<!--<p:input port="source">
<p:pipe port="result" step="produce-inspector"/>
</p:input>-->
</p:catch>
</p:try>
</p:otherwise>
</p:choose>
<p:identity name="final"/>
</p:declare-step>