Adding a restrict to rspec file for our legacy rspec
authorSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 26 Oct 2009 19:00:18 +0000 (19:00 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 26 Oct 2009 19:00:18 +0000 (19:00 +0000)
sfatables/processors/legacy-restrict-to-nodes.xsl [new file with mode: 0644]

diff --git a/sfatables/processors/legacy-restrict-to-nodes.xsl b/sfatables/processors/legacy-restrict-to-nodes.xsl
new file mode 100644 (file)
index 0000000..a0e8057
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <!-- Magic sauce copied from a manual. This fragment basically copies everything except for
+    stuff that explicitly matches with the templates defined below. In the case of such a match,
+    the matched node is treated differently.-->
+    <xsl:template match="@* | node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@* | node()"/>
+        </xsl:copy>
+    </xsl:template>
+
+    <xsl:variable name="whitelist_suffix" select="//rspec//target-context/argument[name='whitelist']/value"/>
+    <xsl:variable name="blacklist_suffix" select="//rspec//target-context/argument[name='blacklist']/value"/>
+
+    <!-- Drop nodes that are not in the whitelist. This is the legacy version that works on the current
+    rspec. The current rspec refers to dns names, not sfa names for nodes.-->
+    <xsl:template match="NodeSpec">
+            <xsl:choose>
+                <xsl:when test="ends-with(@name,$whitelist_suffix) and not($blacklist_suffix and ends-with(@name,$blacklist_suffix))">
+                    <xsl:copy-of select="."/>
+                </xsl:when>
+                <xsl:otherwise/>
+            </xsl:choose>
+    </xsl:template>
+
+</xsl:stylesheet>