4d8f64800f87c5dbf55e47bbacfc0e0cd9c01cd9
[sfa.git] / sfatables / processors / 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_prefix" select="//RSpec//target-context/argument[name='whitelist']/value"/>
13     <xsl:variable name="blacklist_prefix" select="//RSpec//target-context/argument[name='blacklist']/value"/>
14
15     <!-- Drop nodes that are not in the whitelist -->
16     <xsl:template match="node">
17         <xsl:value-of select="$blacklist_prefix"/>
18             <xsl:choose>
19                 <xsl:when test="starts-with(@name,$whitelist_prefix) and not($blacklist_prefix and starts-with(@name,$blacklist_prefix))">
20                     <xsl:copy-of select="."/>
21                 </xsl:when>
22                 <xsl:otherwise/>
23             </xsl:choose>
24     </xsl:template>
25
26 </xsl:stylesheet>