From: Sapan Bhatia <sapanb@cs.princeton.edu> Date: Mon, 26 Oct 2009 19:00:18 +0000 (+0000) Subject: Adding a restrict to rspec file for our legacy rspec X-Git-Tag: sfa-0.9-6~111 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8094983aa1b66a4b9441ff2ae73bc10a5e238bf8;p=sfa.git Adding a restrict to rspec file for our legacy rspec --- diff --git a/sfatables/processors/legacy-restrict-to-nodes.xsl b/sfatables/processors/legacy-restrict-to-nodes.xsl new file mode 100644 index 00000000..a0e80573 --- /dev/null +++ b/sfatables/processors/legacy-restrict-to-nodes.xsl @@ -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>