a little nicer wrt pep8
[sfa.git] / sfatables / processors / max_link_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-link-kbps" select="//RSpec//target-context/argument[name='max-link-kbps']/value"/>
16
17   <!-- Modify LinkSpecs for which kbps > max-link-kbps -->
18   <xsl:template match="vlink/kbps">
19     <xsl:choose>
20       <xsl:when test=". &gt; $max-link-kbps">
21         <kbps><xsl:value-of select="$max-link-kbps"/></kbps>
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="vlink[not(kbps)]">
31     <xsl:copy>
32       <xsl:copy-of select="@* | *"/>
33       <kbps><xsl:value-of select="$max-link-kbps"/></kbps>
34     </xsl:copy>
35   </xsl:template>
36   
37   <xsl:template match="sfatables-input"/>
38 </xsl:stylesheet>
39