Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

produce-xml-converter.xsl: XSpec tests and minor XSLT improvements #87

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,671 changes: 16,671 additions & 0 deletions src/converter-gen/testing/definition-maps/assessment-plan-reduce-map-output.xml

Large diffs are not rendered by default.

7,009 changes: 7,009 additions & 0 deletions src/converter-gen/testing/definition-maps/profile-reduce-map-output.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<XSLT:stylesheet xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel"
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:XSLT="http://www.w3.org/1999/XSL/Transform" version="3.0"
exclude-result-prefixes="#all"
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/1.0"><XSLT:strip-space elements=""/><!-- METASCHEMA conversion stylesheet supports XML -> METASCHEMA/SUPERMODEL conversion -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<!-- METASCHEMA: in namespace "http://csrc.nist.gov/ns/oscal/1.0"-->
<XSLT:variable as="xs:string" name="metaschema-namespace"
>http://csrc.nist.gov/ns/oscal/1.0</XSLT:variable>
</XSLT:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:mt="http://csrc.nist.gov/ns/oscal/metaschema/xspec/testing"
xmlns:sm="http://csrc.nist.gov/ns/oscal/metaschema/1.0/supermodel"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:XSLT="http://www.w3.org/1999/XSL/Transform"
stylesheet="../../json-to-xml/produce-json-converter.xsl"
xslt-version="3.0">

<!-- This XSpec file tests that certain code located in
produce-xml-converter.xsl either
a) Gets reached in a different manner from
produce-json-converter.xsl, such as by name instead of
by match or using a different mode, or
b) Does not get reached (i.e., is overridden) when
the top-level stylesheet is produce-json-converter.xsl.
-->

<x:variable name="source-namespace" select="'http://csrc.nist.gov/ns/oscal/1.0'"/>
<x:variable name="source-prefix" select="'oscal-profile'"/>

<x:helper stylesheet="test-helper-xml-to-json.xsl"/>

<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<!-- produce-json-converter.xsl reaches these templates by name
instead of by match -->
<x:scenario label="Tests for name=make-template template" pending="TODO">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO notations in this file are because I jotted down needs for future work. I anticipate that the work would be a separate pull request.

<!-- TODO: Among other things, check for applying templates in mode=make-key-flag,
which is empty in XML converter but not empty in JSON converter. -->
</x:scenario>

<x:scenario label="Tests for name=make-full-context-match template" pending="TODO">
</x:scenario>

<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<!-- produce-json-converter.xsl reaches these templates by
mode=make-json-pull instead of mode=make-xml-pull -->
<x:scenario label="Tests for match=* mode=make-json-pull template" pending="TODO">
</x:scenario>

<x:scenario label="Tests for match=choice mode=make-json-pull template" pending="TODO">
</x:scenario>

<x:scenario label="Tests for match=constraint mode=make-json-pull template" pending="TODO">
</x:scenario>

<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<!-- produce-json-converter.xsl overrides the templates in
produce-xml-converter.xsl -->
<x:scenario label="Tests for match=* mode=make-match template" pending="TODO">
</x:scenario>

<x:scenario label="Tests for match=* mode=make-pull template">
<!-- The purpose of make-pull mode is route to either make-xml-pull
or make-json-pull mode, depending on whether the top-level stylesheet
is produce-xml-converter.xsl or produce-json-converter.xsl.
Check that we reached the JSON stub template in the helper XSLT. -->
<x:context mode="make-pull">
<mt:any-element xmlns="">stub</mt:any-element>
</x:context>
<x:expect label="Reached make-json-pull mode for the context element">
<!--Reached make-json-pull mode-->
</x:expect>
</x:scenario>

<x:scenario label="Tests for match=field[empty(@gi)][@as-type='markup-multiline'] mode=make-template template" pending="TODO">
</x:scenario>

<x:scenario label="Tests for name=comment-template template">
<x:context>
<mt:any-element xmlns="">stub</mt:any-element>
</x:context>
<x:call template="comment-template"/>
<!-- TODO: When I do more with make-xml-match mode, decide if I want to stop using a stub -->
<x:expect label="XML comment with some text from make-xml-match mode (stubbed for testing)">
<!-- XML match="Reached make-xml-match mode for any-element" -->
</x:expect>
</x:scenario>

<x:scenario label="Tests for name=for-this-converter template" pending="TODO">
</x:scenario>
</x:description>
Loading
Loading