-
I'm implementing XSLT conversion of SP 800-53 from XML to another XML format. I'd like to combine all control statement parts to a single text element. Does someone know that has it been already done as part of the tools or should I just try to figure it out? I seems to be quite tricky and I tried to look for existing tools some tips, but could not find. Thanks in advance for any advice. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Just curious if you have considered json instead of xml? Then you can use
things like jq (or of course python or nodejs scripts)
As a one time xslt fan and heavy user…I have never missed it since switching
…On Wed, Oct 6, 2021 at 11:56 PM riknykn ***@***.***> wrote:
I'm implementing XSLT conversion of SP 800-53 from XML to another XML
format. I'd like to combine all control statement parts to a single text
element. Does someone know that has it been already done as part of the
tools or should I just try to figure it out? I seems to be quite tricky and
I tried to look for existing tools some tips, but could not find. Thanks in
advance for any advice.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1036>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQWTGFHWNPDVSXQG27PISNDUFVACFANCNFSM5FQQ4EUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
FYI @riknykn not exactly what you're looking for but the NIST OSCAL devs do publish HTML transforms that might giive you a good idea of what you need to do. Hat tip to @wendellpiez. FedRAMP/10x teams have a lot of complex XSLT transforms, like our CIS/CRM transform WIP code. Might not be 100% what you are looking for, just FYI/FYE. |
Beta Was this translation helpful? Give feedback.
-
NB the nice illustration by @GaryGapinski will produce output in no namespace. For OSCAL-namespaced output (even if not valid) add As for the general problem it's actually a good exercise for Day One of an XSLT course. Not difficult. But doing it gracefully requires some understanding, not just hacking. |
Beta Was this translation helpful? Give feedback.
-
Thank you all @ohsh6o, @GaryGapinski and @wendellpiez! This was just what I was looking for. |
Beta Was this translation helpful? Give feedback.
-
@riknykn you are welcome glad to help. In the spirit of "beginner-level XSLT help" here's an even more detailed rundown. By default, when not set to do otherwise, an XSLT processor copies the text of the entire input tree into the result. So if you have this XSLT you will get back a big data brick: <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> Note I am using version 3.0 here. I am assuming XSLT version 2.0+ in what follows but the same will be true even in XSLT 1.0 with some adjustments for syntax. Now this is not very useful since you say you only want statements. So there are two approaches to getting the statements only: remove everything else, or grab all the statements. Method 1 is usually preferable, but we are in a hurry so we pick Method 2:
This is great, but the statements are coming out by themselves. So maybe we add to each statement the label from its control:
And then since we are losing any trace of our
and to clean up whitespace (exploiting prior knowledge of the models) and indicate this is to produce plain text not markup (different serialization rules), at the top we can put:
So here is the entire thing again except in neater XSLT 3.0 text value template (TVT) syntax, and adding another template to handle the parts inside some of the statements:
The biggest difference between this and @GaryGapinski 's stylesheet is that his produces XML while this produces plain text. However, it is their similarities that you should find more instructive. Both XSLTs rely on template matching as well as XPath to get the work done. So while his templates contain tagging for the XML in the result, the templates here have only instructions to write characters (plain text) -- or continue the template traversal to find more data ( |
Beta Was this translation helpful? Give feedback.
FYI @riknykn not exactly what you're looking for but the NIST OSCAL devs do publish HTML transforms that might giive you a good idea of what you need to do. Hat tip to @wendellpiez.
https://github.com/usnistgov/oscal-tools/tree/c4ca4c87aed225ee4be1f89ae410193d796cc485/xslt/publish/generic-preview
FedRAMP/10x teams have a lot of complex XSLT transforms, like our CIS/CRM transform WIP code. Might not be 100% what you are looking for, just FYI/FYE.
https://github.com/18F/fedramp-automation/pull/199/files