a little nicer wrt pep8
[sfa.git] / sfatables / processors / legacy-restrict-to-nodes.xsl
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3     <!-- Magic sauce copied from a manual. This fragment basically copies everything except for
4     stuff that explicitly matches with the templates defined below. In the case of such a match,
5     the matched node is treated differently.-->
6     <xsl:template match="@* | node()">
7         <xsl:copy>
8             <xsl:apply-templates select="@* | node()"/>
9         </xsl:copy>
10     </xsl:template>
11
12     <xsl:variable name="whitelist_suffix" select="//RSpec//target-context/argument[name='whitelist-dns-suffix']/value"/>
13     <xsl:variable name="blacklist_suffix" select="//RSpec//target-context/argument[name='blacklist-dns-suffix']/value"/>
14
15     <!-- Drop nodes that are not in the whitelist. This is the legacy version that works on the current
16     rspec. The current rspec refers to dns names, not sfa names for nodes.-->
17     <xsl:template match="NodeSpec">
18             <xsl:choose>
19                 <xsl:when test="(not($whitelist_suffix) or contains(@name,$whitelist_suffix)) and (not($blacklist_suffix) or not(contains(@name,$blacklist_suffix)))">
20                     <xsl:copy-of select="."/>
21                 </xsl:when>
22                 <xsl:otherwise/>
23             </xsl:choose>
24     </xsl:template>
25
26 </xsl:stylesheet>