From 0d421cebc7aa0f30c3497d29b8a1e19af425082a Mon Sep 17 00:00:00 2001 From: Sapan Bhatia <sapanb@cs.princeton.edu> Date: Fri, 14 Aug 2009 02:36:15 +0000 Subject: [PATCH] XSL match for HRNs --- sfatables/matches/hrn.xml | 18 ------------------ sfatables/matches/hrn.xsl | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 sfatables/matches/hrn.xml create mode 100644 sfatables/matches/hrn.xsl diff --git a/sfatables/matches/hrn.xml b/sfatables/matches/hrn.xml deleted file mode 100644 index a4473c86..00000000 --- a/sfatables/matches/hrn.xml +++ /dev/null @@ -1,18 +0,0 @@ -<!-- -"sfa-input" specifies the subset of the requestor context that this match needs to see. It is specified as an xpath expression. -For this simple match, we just need to look at sfa-input. - -"rule" specifies an xpath/xquery expression that evaluates the match. In this case, we just check if the requestor's HRN is the same -as the one matched by this rule. - ---> - -<match xmlns="http://www.planet-lab.org/sfa/sfatables/match/2009/8"> - <sfa-input> - //request/user/hrn - </sfa-input> - - <rule> - (//request/user/hrn eq //current/usr/hrn) - </rule> -</match> diff --git a/sfatables/matches/hrn.xsl b/sfatables/matches/hrn.xsl new file mode 100644 index 00000000..3781b430 --- /dev/null +++ b/sfatables/matches/hrn.xsl @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template match="//rspec-match"> + <xsl:variable name="result"> + <xsl:for-each select="//rspec-match/context-input//user"> + <xsl:variable name="context-hrn" select="hrn"/> + <xsl:for-each select="//rspec-match/rule-input//user"> + <xsl:choose> + <xsl:when test="starts-with($context-hrn, hrn)"> + True + </xsl:when> + <xsl:otherwise> + False + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </xsl:for-each> + </xsl:variable> + <xsl:value-of select="$result"/> + </xsl:template> +</xsl:stylesheet> -- 2.47.0