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

Improved alternative 'resolve-entities.xsl' utility XSLT #1976

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8d9ffc9
Bump actions/checkout from 3.6.0 to 4.0.0
dependabot[bot] Sep 12, 2023
96d658b
Updated link for profile resolution
Arminta-Jenkins-NIST Sep 15, 2023
31e1664
Bump actions/checkout from 4.0.0 to 4.1.0
dependabot[bot] Sep 27, 2023
928ac27
Bump build/metaschema-xslt from `034e92b` to `bd4359a`
dependabot[bot] Sep 27, 2023
d831a3d
Fix expected content of resolving merge-keep_profile.xml
galtm Nov 20, 2022
651deef
Bug fix for selected children of unselected parent
galtm Dec 26, 2022
534b12d
Make schema paths react to directory restructuring
galtm Sep 28, 2023
1c0d6ae
Added hybrid cloud
JustKuzya Oct 12, 2023
9840b46
Integrate PR feedback and merge updated enum value.
aj-stein-nist Oct 13, 2023
dde71c3
Implementation Agnostic Testing (#1946)
nikitawootten-nist Oct 25, 2023
e309dd5
[skip ci] Add ADR-0008 for usnistgov/oscal-content#116.
aj-stein-nist Oct 12, 2023
fd2ff39
[skip ci] Add missing link to oscal-content per review feedback.
aj-stein-nist Oct 13, 2023
1d8a9a0
[skip ci] Update status, date before merge. Clarify content is still …
aj-stein-nist Nov 9, 2023
1d48aee
Bump actions/github-script from 6.4.1 to 7.0.1 (#1961)
dependabot[bot] Nov 21, 2023
70816d7
Bump actions/setup-node from 3.8.1 to 4.0.0 (#1954)
dependabot[bot] Nov 21, 2023
b13eeb2
Bump org.apache.maven.plugins:maven-dependency-plugin in /build (#1953)
dependabot[bot] Nov 21, 2023
90089bf
Bump actions/checkout from 4.1.0 to 4.1.1 (#1950)
dependabot[bot] Nov 21, 2023
b9e6a2d
Bump build/metaschema-xslt from `bd4359a` to `7d9fbfa` (#1955)
dependabot[bot] Nov 22, 2023
085af23
Add tutorials system lifecycle ADR (#1959)
nikitawootten-nist Nov 22, 2023
fe39318
Flatten codeowners (#1962)
nikitawootten-nist Nov 29, 2023
290bc84
Catalog constraints added in oscal_catalog_metaschema.xml - see issue…
iMichaela Nov 29, 2023
f72e27e
Updated version in the release a patch guidance (#1964)
iMichaela Dec 6, 2023
ee77ab6
Bump actions/setup-java from 3 to 4 (#1963)
dependabot[bot] Dec 6, 2023
c4a99cc
Remove with-parent-controls from implementation (#1843)
aj-stein-nist Dec 6, 2023
97a71c1
Update oscal metaschema source to version 1.1.2
Dec 6, 2023
45c1fc4
New XSLT emulates resolve-entities.xsl, except using 3.0 features, wi…
wendellpiez Jan 23, 2024
f69c55e
Improved initial comment on XSLT
wendellpiez Jan 30, 2024
1d857dd
Merge branch 'develop' into enhancement-metaschema-normalizer-fixup
iMichaela Feb 19, 2024
ff28491
Merge branch 'develop' into enhancement-metaschema-normalizer-fixup
iMichaela Feb 20, 2024
f55bf8d
Merge branch 'develop' into enhancement-metaschema-normalizer-fixup
iMichaela Mar 1, 2024
3f19e58
Merge branch 'develop' into enhancement-metaschema-normalizer-fixup
iMichaela Mar 12, 2024
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
78 changes: 78 additions & 0 deletions build/resolve-entities.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="resolve-entities3.xsl"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">

<x:scenario label="Everything copies:">
<x:scenario label="A bare metaschema">
<x:context>
<METASCHEMA/>
</x:context>
<x:expect label="copies" select="$x:context"/>
</x:scenario>
<x:scenario label="With random PIs">
<x:context>
<?xml-stylesheet href="some.css"?>
<METASCHEMA>
<title>A test</title>
<?random?>
</METASCHEMA>
</x:context>
<x:expect label="copies" select="$x:context"/>
</x:scenario>
<x:scenario label="A comment" pending="dev"/>
</x:scenario>

<x:scenario label="import/@href is modified:">
<x:scenario label="providing a suffix to the base name">
<x:context>
<METASCHEMA>
<import href="some.other.metaschema.xml"/>
</METASCHEMA>
</x:context>
<x:expect label="copies with @href modified">
<METASCHEMA>
<import href="some.other.metaschema_RESOLVED.xml"/>
</METASCHEMA>
</x:expect>
</x:scenario>
<x:scenario label="even when the suffix is not 'xml'">
<x:context>
<METASCHEMA>
<import href="some.other.metaschema"/>
</METASCHEMA>
</x:context>
<x:expect label="copies with @href modified">
<METASCHEMA>
<import href="some.other_RESOLVED.metaschema"/>
</METASCHEMA>
</x:expect>
</x:scenario>
<x:scenario label="or it is missing entirely">
<x:context>
<METASCHEMA>
<import href="some_metaschema"/>
</METASCHEMA>
</x:context>
<x:expect label="copies with @href modified">
<METASCHEMA>
<import href="some_metaschema_RESOLVED"/>
</METASCHEMA>
</x:expect>
</x:scenario>
<x:scenario label="providing a suffix to the base name">
<x:context>
<x:param name="splice">_NEW</x:param>
<METASCHEMA>
<import href="some.other.metaschema.xml"/>
</METASCHEMA>
</x:context>
<x:expect label="copies with @href modified">
<METASCHEMA>
<import href="some.other.metaschema_NEW.xml"/>
</METASCHEMA>
</x:expect>
</x:scenario>
</x:scenario>

</x:description>
46 changes: 46 additions & 0 deletions build/resolve-entities3.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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:math="http://www.w3.org/2005/xpath-functions/math"
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
exclude-result-prefixes="xs math"
version="3.0">

<!--
Purpose: Process XML files through a parsing/serialization that resolves internal parsed entities.
Also renames file references in METASCHEMA/import/@href
using $importHrefSuffix to suffix the base name
so for $importHrefSuffix='NEW'
import href="a_metaschema_module.xml" becomes href="a_metaschema_module_NEW.xml"
Otherwise this is an identity transform, so a diff over source and results should show only stated changes.
Parameter: $importHrefSuffix is 'RESOLVED' by default
XSpec: See the XSpec resolve-entities.xspec for functional testing, including the edge cases.
Compared to old resolve-entities.xsl: This XSLT provides the same outputs
for 'normal' inputs i.e. when import/@href ends in '.xml'.
For extraordinary inputs it does a little differently.
-->

<!-- since whitespace is retained from input, it provides indenting
- if (schema-based) strip-space is operative, switch @indent to 'yes'-->
<xsl:output omit-xml-declaration="no" indent="no" encoding="ASCII"/>

<xsl:param name="importHrefSuffix" select="'RESOLVED'"/>

<!-- copying everything through -->
<xsl:mode on-no-match="shallow-copy"/>

<xsl:template match="import/@href">
<xsl:param name="splice" select="'_' || $importHrefSuffix"/>

<xsl:variable name="basename" select="replace(.,'\.[^.]*$','')"/>
<xsl:attribute name="href" select="$basename || $splice || substring-after(.,$basename)"/>
</xsl:template>

</xsl:stylesheet>