Bug fix that was dropping the nodespec's attributes.
[sfa.git] / sfatables / processors / max_node_kbps.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
4     copies everything except for stuff that explicitly matches with
5     the templates defined below. In the case of such a match, the
6     matched node is treated differently.-->
7   <xsl:template match="@* | node()">
8     <xsl:copy>
9       <xsl:apply-templates select="@* | node()"/>
10     </xsl:copy>
11   </xsl:template>
12   <!-- End of magic sauce -->
13
14   <!-- Read in the value of the argument. -->
15   <xsl:variable name="max-node-kbps" select="//RSpec//target-context/argument[name='max-node-kbps']/value"/>
16
17   <!-- Modify NodeSpec for which kbps > max-link-kbps -->
18   <xsl:template match="NodeSpec/max_rate">
19       <xsl:choose>
20           <xsl:when test=". &gt; $max-node-kbps">
21               <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
22           </xsl:when>
23           <xsl:otherwise>
24               <xsl:copy-of select="."/>
25           </xsl:otherwise>
26       </xsl:choose>
27   </xsl:template>
28       
29   <!-- Fill in missing kbps values --> 
30   <xsl:template match="NodeSpec[not(max_rate)]">
31       <xsl:copy>
32           <xsl:copy-of select="."/>
33           <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
34       </xsl:copy>
35   </xsl:template>
36   
37   <xsl:template match="sfatables-input"/>
38 </xsl:stylesheet>