Signed-off-by: Jeffrey Blank <blank(a)eclipse.ncsc.mil>
---
RHEL6/Makefile | 4 +-
RHEL6/transforms/shorthand2xccdf.xslt | 108 +++++------------------------
RHEL6/transforms/xccdf-addnamespaces.xslt | 49 +++++++++++++
3 files changed, 69 insertions(+), 92 deletions(-)
create mode 100644 RHEL6/transforms/xccdf-addnamespaces.xslt
diff --git a/RHEL6/Makefile b/RHEL6/Makefile
index d34b127..9515051 100644
--- a/RHEL6/Makefile
+++ b/RHEL6/Makefile
@@ -14,10 +14,10 @@ shorthand-guide:
xmllint --format --output $(OUT)/rhel6-shorthand.xml $(OUT)/rhel6-shorthand.xml
shorthand2xccdf: shorthand-guide
- xsltproc -o $(OUT)/unlinked-unresolved-noprofiles-rhel6-shorthand.xml
$(TRANS)/shorthand2xccdf.xslt $(OUT)/rhel6-shorthand.xml
- xsltproc -o $(OUT)/unlinked-unresolved-noprofiles-rhel6-xccdf.xml
$(TRANS)/add_xccdf_namespace.xslt
$(OUT)/unlinked-unresolved-noprofiles-rhel6-shorthand.xml
+ xsltproc -o $(OUT)/unlinked-unresolved-noprofiles-rhel6-xccdf.xml
$(TRANS)/shorthand2xccdf.xslt $(OUT)/rhel6-shorthand.xml
xsltproc -stringparam profile "allprofiles" -o
$(OUT)/unlinked-unresolved-rhel6-xccdf.xml \
$(TRANS)/xccdf-addprofiles.xslt $(OUT)/unlinked-unresolved-noprofiles-rhel6-xccdf.xml
+ xsltproc -o $(OUT)/unlinked-unresolved-rhel6-xccdf.xml $(TRANS)/xccdf-addnamespaces.xslt
$(OUT)/unlinked-unresolved-rhel6-xccdf.xml
oscap xccdf resolve -o $(OUT)/unlinked-rhel6-xccdf.xml
$(OUT)/unlinked-unresolved-rhel6-xccdf.xml
# xsltproc -stringparam profile "stig-rhel6-server" -o
$(OUT)/unlinked-rhel6-xccdf.xml \
# $(TRANS)/xccdf-addrefs.xslt $(OUT)/unlinked-rhel6-xccdf.xml
diff --git a/RHEL6/transforms/shorthand2xccdf.xslt
b/RHEL6/transforms/shorthand2xccdf.xslt
index 39f6741..2b47121 100644
--- a/RHEL6/transforms/shorthand2xccdf.xslt
+++ b/RHEL6/transforms/shorthand2xccdf.xslt
@@ -1,24 +1,20 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-xmlns:xccdf="http://checklists.nist.gov/xccdf/1.1"
-xmlns:xhtml="http://www.w3.org/1999/xhtml"
-xmlns:dc="http://purl.org/dc/elements/1.1/"
-xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
-exclude-result-prefixes="xccdf xhtml dc">
+
xmlns:xccdf="http://checklists.nist.gov/xccdf/1.1"
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
+
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
+ exclude-result-prefixes="xccdf xhtml dc">
<xsl:include href="constants.xslt"/>
<xsl:variable
name="ovalfile">unlinked-rhel6-oval.xml</xsl:variable>
-
<xsl:variable name="defaultseverity" select="'low'" />
-
- <!-- Content:template -->
- <xsl:template match="Benchmark">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" />
- </xsl:copy>
- </xsl:template>
+ <!-- This transform takes a "shorthand" variant of XCCDF
+ and expands its elements into proper XCCDF elements,
+ except (notably) it does not assign namespaces. This is handled
+ in another transform. -->
<!-- insert current date -->
<xsl:template match="Benchmark/status/@date">
@@ -63,6 +59,10 @@ exclude-result-prefixes="xccdf xhtml dc">
</xsl:copy>
</xsl:template>
+ <!-- XHTML, such as tt, is not allowed in titles -->
+ <xsl:template match="title/tt">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:template>
<!-- expand reference to ident types -->
<xsl:template match="Rule/ident">
@@ -223,13 +223,6 @@ exclude-result-prefixes="xccdf xhtml dc">
</reference>
</xsl:template>
- <xsl:template match="@*|node()">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" />
- </xsl:copy>
- </xsl:template>
-
-
<!-- convenience macros for XCCDF prose -->
<xsl:template match="sysctl-desc-macro">
@@ -445,76 +438,11 @@ If the system is configured to audit this activity, it will return a
line.
</xsl:if>
</xsl:template>
-
- <!-- CORRECTING TERRIBLE ABUSE OF NAMESPACES BELOW -->
- <!-- (expanding xhtml tags back into the xhtml namespace) -->
- <xsl:template match="br">
- <xhtml:br />
- </xsl:template>
-
- <xsl:template match="ul">
- <xhtml:ul>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:ul>
- </xsl:template>
-
- <xsl:template match="li">
- <xhtml:li>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:li>
- </xsl:template>
-
- <xsl:template match="tt">
- <xhtml:code>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:code>
- </xsl:template>
-
-
- <!-- remove use of tt in titles; xhtml in titles is not allowed -->
- <xsl:template match="title/tt">
- <xsl:apply-templates select="@*|node()" />
- </xsl:template>
-
- <xsl:template match="code">
- <xhtml:code>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:code>
- </xsl:template>
-
- <xsl:template match="strong">
- <xhtml:strong>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:strong>
- </xsl:template>
-
- <xsl:template match="b">
- <xhtml:b>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:b>
- </xsl:template>
-
- <xsl:template match="em">
- <xhtml:em>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:em>
- </xsl:template>
-
- <xsl:template match="i">
- <xhtml:i>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:i>
- </xsl:template>
-
- <xsl:template match="ol">
- <xhtml:ol>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:ol>
+ <!-- identity transform: pass anything else through -->
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:copy>
</xsl:template>
- <xsl:template match="pre">
- <xhtml:pre>
- <xsl:apply-templates select="@*|node()" />
- </xhtml:pre>
- </xsl:template>
</xsl:stylesheet>
diff --git a/RHEL6/transforms/xccdf-addnamespaces.xslt
b/RHEL6/transforms/xccdf-addnamespaces.xslt
new file mode 100644
index 0000000..b27dbb8
--- /dev/null
+++ b/RHEL6/transforms/xccdf-addnamespaces.xslt
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+
xmlns:xccdf="http://checklists.nist.gov/xccdf/1.1"
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ exclude-result-prefixes="xccdf dc xhtml">
+
+ <!-- This transform places elements into the correct namespaces,
+ so that content authors never have to bother with them.
+ XHTML elements are explicitly identified and the xhtml
+ namespace is added. Any element with an empty namespace
+ is assigned to the xccdf namespace. -->
+
+ <!-- table and list-related xhtml -->
+ <xsl:template match="table | tr | th | td | ul | li | ol">
+ <xsl:element name="{local-name()}"
namespace="http://www.w3.org/1999/xhtml">
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- general formatting xhtml -->
+ <xsl:template match="code | strong | b | em | i | pre | br | hr">
+ <xsl:element name="{local-name()}"
namespace="http://www.w3.org/1999/xhtml">
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- convert tt to code, which seems better-supported -->
+ <xsl:template match="tt">
+ <xhtml:code>
+ <xsl:apply-templates select="@*|node()"/>
+ </xhtml:code>
+ </xsl:template>
+
+ <!-- if no namespace is indicated, put into xccdf namespace-->
+ <xsl:template match="*[namespace-uri()='']"
priority="-1">
+ <xsl:element name="{local-name()}"
namespace="http://checklists.nist.gov/xccdf/1.1">
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- pass everything else through -->
+ <xsl:template match="@*|node()" priority="-2">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
--
1.7.1