a little nicer wrt pep8
[sfa.git] / sfatables / processors / restrict_to_flowspec.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="wswitch" select="//RSpec//target-context/argument[name='whitelist-switch']/value"/>
13     <xsl:variable name="wtpsrc" select="//RSpec//target-context/argument[name='whitelist-tpsrc']/value"/>
14     <xsl:variable name="wtpdst" select="//RSpec//target-context/argument[name='whitelist-tpdst']/value"/>
15     <xsl:variable name="wipsrc" select="//RSpec//target-context/argument[name='whitelist-ipsrc']/value"/>
16     <xsl:variable name="wipdst" select="//RSpec//target-context/argument[name='whitelist-ipdst']/value"/>
17
18     <!-- Drop nodes that are not in the whitelist -->
19     <xsl:template match="//switchEntry">
20             <xsl:choose>
21                 <xsl:when test="(nodeId==$wswitch) and 
22                     (interfaceEntry/flowSpaceEntry/tp_src==$wtpsrc) and
23                     (interfaceEntry/flowSpaceEntry/tp_dst==$wtpdst)">
24                     <xsl:copy-of select="."/>
25                 </xsl:when>
26                 <xsl:otherwise/>
27             </xsl:choose>
28     </xsl:template>
29
30 </xsl:stylesheet>