forked from usnistgov/metaschema-xslt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnist-metaschema-MAKE-JSON-TO-XML-CONVERTER.xsl
63 lines (50 loc) · 3.68 KB
/
nist-metaschema-MAKE-JSON-TO-XML-CONVERTER.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:nm="http://csrc.nist.gov/ns/metaschema"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel"
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel"
exclude-result-prefixes="#all"
version="3.0">
<!-- Purpose: Produce an XSLT transformation capable of converting a JSON format defined in a metaschema, into an XML JSON format capturing an equivalent data set -->
<!-- Dependencies: This is a 'shell' XSLT and calls several steps in sequence, each implemented as an XSLT -->
<!-- Dependencies: Additionally, it directly calls resources in the converter-gen subdirectory as follows: converter-gen/markdown-to-supermodel-xml-converter.xsl, converter-gen/supermodel-to-xml.xsl (see lines 132, 136) -->
<!-- Input: A top-level metaschema; this XSLT also composes metaschema input so composition is not necessary -->
<!-- Output: A standalone XSLT suitable for use or deployment, accepting JSON valid to the metaschema-defined constraints -->
<!-- Note: see the result XSLT for information regarding its runtime interface -->
<!-- Note: This XSLT uses the transform() function to execute a series of transformations (referenced out of line) over its input -->
<xsl:output method="xml" indent="yes"/>
<!-- Turning $trace to 'on' will
- emit runtime messages with each transformation, and
- retain nm:ERROR and nm:WARNING messages in results. -->
<xsl:param name="trace" as="xs:string">off</xsl:param>
<xsl:variable name="louder" select="$trace = 'on'"/>
<xsl:variable name="xslt-base" select="document('')/base-uri()"/>
<xsl:import href="../common/nist-metaschema-metaprocess.xsl"/>
<!-- The $transformation-sequence declares transformations to be applied in order. -->
<xsl:variable name="produce-json-converter" expand-text="true">
<!-- first compose the metaschema -->
<xsl:variable as="xs:string" name="composer-dir">../compose</xsl:variable>
<nm:transform version="3.0">{ $composer-dir }/metaschema-collect.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-build-refs.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-trim-extra-modules.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-prune-unused-definitions.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-resolve-use-names.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-resolve-sibling-names.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/metaschema-digest.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/annotate-composition.xsl</nm:transform>
<!-- next produce definition map -->
<nm:transform version="3.0">{ $composer-dir }/make-model-map.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/unfold-model-map.xsl</nm:transform>
<nm:transform version="3.0">{ $composer-dir }/reduce-map.xsl</nm:transform>
<nm:transform version="3.0">json-to-xml/produce-json-converter.xsl</nm:transform>
<nm:transform version="3.0">json-to-xml/package-json-converter.xsl</nm:transform>
</xsl:variable>
<xsl:variable name="metaschema-source" select="/"/>
<xsl:template match="/">
<xsl:comment expand-text="true"> XSLT generated by { replace($xslt-base,'.*/','') }, { current-dateTime() } </xsl:comment>
<xsl:call-template name="nm:process-pipeline">
<xsl:with-param name="sequence" select="$produce-json-converter"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>