Skip to content

Restore proper mode handling for oscal-profile-test-helper.xsl#1804

Merged
aj-stein-nist merged 1 commit intousnistgov:developfrom
david-waltermire:remove-default-mode
Jun 27, 2023
Merged

Restore proper mode handling for oscal-profile-test-helper.xsl#1804
aj-stein-nist merged 1 commit intousnistgov:developfrom
david-waltermire:remove-default-mode

Conversation

@david-waltermire
Copy link
Contributor

@david-waltermire david-waltermire commented Jun 5, 2023

Committer Notes

This PR removes default-mode="scrubbing to avoid an apply-template loop when the stylesheet is applied to a document.

By setting default-mode="scrubbing" on the xsl:stylesheet element, all templates implicitly have the mode scrubbing.

When applying this stylesheet to a document, the following template matches:

<xsl:template match="/">
  <xsl:param name="source" select="." as="document-node()"/>
  <xsl:document>
    <xsl:apply-templates select="$source" mode="scrubbing"/>
  </xsl:document>
</xsl:template>

The statement <xsl:apply-templates select="$source" mode="scrubbing"/> then causes the same template to match instead of the intended template:

<xsl:template mode="scrubbing" match="* | text() | @*">
  <xsl:copy>
    <xsl:apply-templates mode="#current" select="@*"/>
    <xsl:apply-templates mode="#current"/>
  </xsl:copy>
</xsl:template>

Removing the default-mode="scrubbing restores the correct behavior of the earlier commit.

All Submissions:

By submitting a pull request, you are agreeing to provide this contribution under the CC0 1.0 Universal public domain dedication.

(For reviewers: The wiki has guidance on code review and overall issue review for completeness.)

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you included examples of how to use your new feature(s)?
  • Have you updated all OSCAL website and readme documentation affected by the changes you made? Changes to the OSCAL website can be made in the docs/content directory of your branch.

Copy link
Contributor

@wendellpiez wendellpiez left a comment

Choose a reason for hiding this comment

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

This bug maybe did not show up when run inside a test harness?

@aj-stein-nist
Copy link
Contributor

This bug maybe did not show up when run inside a test harness?

I guess we need to examine that but I presume the relevant XSpec tests that use this were only recently integrated?

@aj-stein-nist
Copy link
Contributor

aj-stein-nist commented Jun 27, 2023

I goofed on the boolean logic for gating the Docker container build for XSpec testing to only trigger on team PRs or pushes, so for now I will ignore the test failure since it will not trigger on push (it won't be a PR with github.even.pull_request object to filter anyway) and figure that out later. Spent too much time on this!

@aj-stein-nist aj-stein-nist merged commit 8cb66b2 into usnistgov:develop Jun 27, 2023
aj-stein-nist pushed a commit to aj-stein-nist/OSCAL-forked that referenced this pull request Jun 29, 2023
aj-stein-nist pushed a commit to aj-stein-nist/OSCAL-forked that referenced this pull request Jul 10, 2023
@aj-stein-nist aj-stein-nist added this to the v1.1.0 milestone Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants