<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:xw="http://www.pnp-software.com/XWeaver" xmlns:xd="http://www.pnp-software.com/XSLTdoc" xmlns:util="http://www.pnp-software.com/util" 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 block. </xd:short>
    
<xd:detail>
      
<ul>
        
<li>srcML element: <code>src:block</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:block" 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>Calls named template addAtEndOfBlock provided by XWeaver.</xd:doc>

  
<xsl:template match="src:block[ax:advice[@type='end' and position() = 1]/ax:codeModifier[@type='codeFragment']]" mode="weaving">
    
<xsl:copy>
      
<xsl:copy-of select="@*" />
      
<!-- The current advice has to be deleted. All others must be preserved.  -->
      
<xsl:copy-of select="ax:advice[position() != 1]" />
      
<xsl:call-template name="addAtEndOfBlock">
        
<xsl:with-param name="block" select="." />
        
<xsl:with-param name="advice" select="ax:advice[1]" />
      
</xsl:call-template>
    
</xsl:copy>
  
</xsl:template>
</xsl:stylesheet>






































v