-
Notifications
You must be signed in to change notification settings - Fork 181
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
JSON->XML conversion adds nm:ERROR
when using json
instead of file
input
#1849
Comments
When duplicating this, I suggest we also try:
Reason: to confirm whether the input is being correctly processed, apart from the bogus error. Meanwhile @kylelaker as a temporary workaround while we repair this, would you be interested in a short XSLT that would scrub the false error message from your OSCAL, presumably leaving valid OSCAL (or invalid, as in the case of the example I gave)? Any pipeline that uses this could use it as a cleanup. |
@wendellpiez If that's something you're able to provide, I'd greatly appreciate it and it'd definitely be a viable workaround for us in the shorter term! |
@kylelaker - well in principle such a filter should be simple to make, except there is a detail here that complicates it - in brief, because the bad output has two elements (namely that nm:ERROR, and a The good news is that the bug is easily fixed, just as you suggest on Line https://github.com/usnistgov/OSCAL/blob/d942435d493578e06507f93cf1b27afd71d2fdf5/xml/convert/oscal_complete_json-to-xml-converter.xsl#L20 if it had <xsl:if test="matches($file,'\S') and not(unparsed-text-available($file))" expand-text="true"> Or if code intervention is not your thing, we could write a wrapper XSLT that would perform the correction on the result before writing it out (also as a stopgap). |
@kylelaker here is a funny idea - what happens if you provide a dummy JSON file reference to the I.e. Meantime this is a straightforward repair and mainly a matter of fitting in. |
Previously, if `file` was not specified (and `json` was), an error would be emitted about the file not being found. This was erroneous as only the JSON input should have been considered. This applies a small fix to remediate that, given by Wendell in usnistgov/OSCAL#1849. I am unsure whether this is the desired long-term fix but I figured opening a PR to memorialize the patch may be useful. Co-authored-by: Wendell Piez <[email protected]>
Okay so I manually modified the "complete" converted to apply the change you provided.
I've opened usnistgov/metaschema#394 with that patch. I see that there's other work happening to refactor that more generally so I totally understand if it's not merged. But memorializing it makes it a little easier to share exactly how to modify the file for our own needs. Thanks for your help! |
We will hold on this until after our pending release, review the proposed PR in the updated metaschema repor (metaschema-xslt), and we update submodule in OSCAL repo. We will revisit that potentially in a subsequent sprint depending on when things are ready. |
Suggesting this for even greater stress reduction: In the new
In addition to not firing wrongly, this makes a warning comment instead of an element at the top level, where it breaks parsers whenever the transformation succeeds in producing results (e.g. via the command line data feed). |
The code will shortly be in the new file Also: consider changing the |
Actually we didn't do this here - remains as a TODO. |
…nverter (#1849) * Replaced `metaschema` submodule with `metaschema-xslt` * The `metaschema-xslt` version also fixes #1849 * Removed all bespoke scripts and replaced them with Makefile targets * Changed CI infrastructure to use the new Makefile scripts * Removed Dockerfile and infrastructure as it is no longer needed * Changed model version to `1.1.0` Co-authored-by: Wendell Piez <[email protected]> Co-authored-by: Dmitry Cousin <[email protected]> Co-authored-by: Chris Compton <[email protected]> Co-authored-by: A.J. Stein <[email protected]>
…nverter (#1849) * Replaced `metaschema` submodule with `metaschema-xslt` * The `metaschema-xslt` version also fixes #1849 * Removed all bespoke scripts and replaced them with Makefile targets * Changed CI infrastructure to use the new Makefile scripts * Removed Dockerfile and infrastructure as it is no longer needed * Changed model version to `1.1.0` Co-authored-by: Wendell Piez <[email protected]> Co-authored-by: Dmitry Cousin <[email protected]> Co-authored-by: Chris Compton <[email protected]> Co-authored-by: A.J. Stein <[email protected]>
Describe the bug
When following the steps described at "Alternate Invocations" for performing a JSON->XML conversion using the
json
runtime parameter results in an invalid OSCAL XML file. There is an additionalnm:ERROR
node at the root. This does not occur if using thefile
runtime parameter.For example:
This can be reproduced using the
xslt3
CLI from NPM as well as programming language libraries.Who is the bug affecting
Any users who wish to use the XSLT3 files to perform document conversions without having to create an intermediate file with the JSON content.
What is affected by this bug
Tooling & API
How do we replicate this issue
json
runtime parameter, using for example-xsl:oscal_complete_json-to-xml-converter.xsl -t -it:from-json json='{ "catalog": {} }' -o:catalog.xml
as argumentscatalog.xml
)nm:ERROR
node as the second line in the file.Expected behavior (i.e. solution)
The
<nm:ERROR xmlns:nm="http://csrc.nist.gov/ns/metaschema">No file found at </nm:ERROR>
value should not be emitted in the output.Other comments
I am not an expert in XSLT3; however, I am guessing the issue is based on the fact that there is not a condition to handle whether
$json
has been supplied in this block that emits the error:https://github.com/usnistgov/OSCAL/blob/d942435d493578e06507f93cf1b27afd71d2fdf5/xml/convert/oscal_complete_json-to-xml-converter.xsl#L20-L22
This error occurs for all models; however, the complete schema and catalog model are used as a consistent example for simplicity.
Revisions
No response
The text was updated successfully, but these errors were encountered: