block_around_codeFragment.xsl

Weaving Rule that replaces the contents of a block (Everything inside curly braces) with a code fragment.
  • srcML element: src:block
  • advice type: around
  • codeModifier type: codeFragment

Example 1

int foo() {
  printf("Hello");
}

Code Modifier

<codeModifier type="codeFragment">
  <text>printf("Hello World")</text>
</codeModifier>

Modified Code

int foo() {
  printf("Hello World");
}

Example 2

Base Code

int main() {
  int i = 0;
  int c = 5;
}

Code Modifier

The variable ${ blockBody} prints the original body content and indents it with two spaces (defined by the two spaces after '${').

<codeModifier type="codeFragment">
  <text>try {</text>
  <text>${  blockBody}</text>
  <text>} catch ( ... ) {</text>
  <text>  <![CDATA[cout << "ERROR MESSAGE" << endl;]]></text>
  <text>}</text>
</codeModifier>

Modified Code

int main() {
  try {
    int i = 0;
    int c = 5;
  } catch (...) {
    cout << "ERROR MESSAGE" << endl;
  }
}

Examples in AspectX Sample Library

Examples in AspectX Test Suite

CVS Id:
Author:
ibirrer
Copyright:
2004, P&P Software GmbH

Match Templates Summary

Calls named template addAtEndOfBlock provided by XWeaver

Match Templates Detail

Calls named template addAtEndOfBlock provided by XWeaver