<xsl:stylesheet xmlns:src="http://www.sdml.info/srcML/src" xmlns:cpp="http://www.sdml.info/srcML/cpp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xd="http://www.pnp-software.com/XSLTdoc" xmlns:ax="http://control.ee.ethz.ch/XWeaver/AspectX" version="2.0">
                
  
                   <xd:doc type="stylesheet">
    
<xd:short>Weaving Rule that weaves a code fragment at the end of a function. </xd:short>
    
<xd:detail>
    
<p>The only thing this rule does is copying the advices to the <code>src:block</code> 
    element. The actual weaving is handled by 
<a href="block_end_codeFragment.xsl.xd.html">block_end_codeFragment.xsl</a></p>
      
<ul> 
        
<li>srcML element:     <code>src:function</code></li>
        
<li>advice type:       <code>end</code></li>
        
<li>codeModifier type: <code>codeFragment</code></li>
      
</ul>
      
<h2>Example</h2>
      
<div class="source">
<pre>int foo() {
  printf("Hello");
}
</pre>
      
</div>
      
<h3>Code Modifier</h3>
      
<xd:xml>
<codeModifier type="codeFragment">
  
<text>printf("Hello World")</text>
</codeModifier>
      
</xd:xml>
      
<h3>Modified Code</h3>
      
<div class="source">
<pre>int foo() {
  printf("Hello");
  
<span class="highlightedCode">printf("Hello World");</span>
}
</pre>
      
</div>
        
<xd:weaverRuleLinks pointcutType="src:function" adviceType="end" codeModifierType="codeFragment" />
    
</xd:detail>
    
<xd:cvsId>$Id$</xd:cvsId>
    
<xd:author>ibirrer</xd:author>
    
<xd:copyright>2004, P&amp;P Software GmbH</xd:copyright>
  
</xd:doc>

  
  
<!-- Preserve Whitespaces -->
  
<xsl:preserve-space elements="*" />
  
                   <xd:doc>
    Apply tempates with mode 
<code>weaving_function_end_codeFragment</code> 
    to all (excludig advice elements) 
<code>src:function</code> child elements.
  
</xd:doc>

  
<xsl:template match="src:function[ax:advice[@type='end' and position() = 1]/ax:codeModifier[@type='codeFragment']]" mode="weaving">
    
<xsl:copy>
      
<xsl:copy-of select="@*" />
      
<!-- Copy advices not handled by this rule -->
      
<xsl:copy-of select="ax:advice[not(@type='end' and ax:codeModifier/@type='codeFragment')]" />
      
<!-- Apply all child elements with the mode weaving_function_end_codeFragment -->
      
<xsl:apply-templates select="node()[not(self::ax:advice)]" mode="weaving_function_end_codeFragment">
        
<xsl:with-param name="advices" select="ax:advice[@type='end' and ax:codeModifier/@type='codeFragment']" />
      
</xsl:apply-templates>
    
</xsl:copy>
  
</xsl:template>
  
  
                   <xd:doc>
    Template for the function block.
    
<xd:param name="advices" type="node-set">Advices which should be copied to the src:block element.</xd:param>
  
</xd:doc>

  
<xsl:template match="src:block" mode="weaving_function_end_codeFragment">
    
<xsl:param name="advices" />
    
<xsl:copy>
      
<xsl:copy-of select="@*" />
      
<xsl:copy-of select="$advices" />
      
<xsl:copy-of select="child::node()" />
    
</xsl:copy>
  
</xsl:template>
  
  
                   <xd:doc>
    Default copy template.
    
<xd:param name="advices" type="node-set">Advices which should be copied to the src:block element.</xd:param>
  
</xd:doc>

  
<xsl:template match="*" mode="weaving_function_end_codeFragment">
    
<xsl:param name="advices" />
    
<xsl:copy>
      
<xsl:copy-of select="@*" />
      
<xsl:apply-templates mode="weaving_function_end_codeFragment">
        
<xsl:with-param name="advices" select="$advices" />
      
</xsl:apply-templates>
    
</xsl:copy>
  
</xsl:template>
</xsl:stylesheet>






































v