Debian Codegraph @

xsl/xccdf_1.1_remove_dangling_sub.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4 Copyright 2012 Red Hat Inc., Durham, North Carolina.
5 All Rights Reserved.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21 Authors:
22 Šimon Lukašík
23 -->
24
25 <xsl:stylesheet
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:xccdf_11="http://checklists.nist.gov/xccdf/1.1"
28 version="1.0">
29 <xsl:output method="xml" indent="yes"/>
30
31 <xsl:key name="values" match="//xccdf_11:Value" use="@id"/>
32
33 <xsl:template match="@*|node()">
34 <xsl:copy>
35 <xsl:apply-templates select="@*|node()"/>
36 </xsl:copy>
37 </xsl:template>
38
39 <xsl:template match="xccdf_11:sub">
40 <xsl:variable name="idref" select="@idref"/>
41 <xsl:choose>
42 <xsl:when test="key('values', $idref)">
43 <xsl:element name="{local-name()}" namespace="{namespace-uri()}">
44 <xsl:apply-templates select="@*"/>
45 <xsl:apply-templates/>
46 </xsl:element>
47 </xsl:when>
48 <xsl:otherwise>
49 <xsl:text>UNDEFINED_SUB</xsl:text>
50 </xsl:otherwise>
51 </xsl:choose>
52 </xsl:template>
53 </xsl:stylesheet>
54