<
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 beginning 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_begin_codeFragment.xsl.xd.html">
block_begin_codeFragment.xsl</
a></
p>
<
ul>
<
li>
srcML element: <
code>
src:function</
code></
li>
<
li>
advice type: <
code>
begin</
code></
li>
<
li>
codeModifier type: <
code>
codeFragment</
code></
li>
</
ul>
<
h2>
Example</
h2>
<
h3>
Base Code</
h3>
<
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() {
<
span class="
highlightedCode">
printf("Hello World");</
span>
printf("Hello");
}</
pre>
</
div>
<
xd:
weaverRuleLinks pointcutType="
src:function"
adviceType="
begin"
codeModifierType="
codeFragment" />
</
xd:
detail>
<
xd:
cvsId>
$Id$</
xd:
cvsId>
<
xd:
author>
ibirrer</
xd:
author>
<
xd:
copyright>
2004, P&P Software GmbH</
xd:
copyright>
</
xd:
doc>
<!---->
<
xsl:
preserve-space elements="
*" />
<
xd:
doc>
Apply tempates with mode <
code>
weaving_function_begin_codeFragment</
code>
to all (excludig advice elements) <
code>
src:function</
code>
child elements.
</
xd:
doc>
<
xsl:
template match="
src:function[ax:advice[@type='begin' and position() = 1]/ax:codeModifier[@type='codeFragment']]"
mode="
weaving">
<
xsl:
copy>
<
xsl:
copy-of select="
@*" />
<!---->
<
xsl:
copy-of select="
ax:advice[not(@type='begin' and ax:codeModifier/@type='codeFragment')]" />
<!---->
<
xsl:
apply-templates select="
node()[not(self::ax:advice)]"
mode="
weaving_function_begin_codeFragment">
<
xsl:
with-param name="
advices"
select="
ax:advice[@type='begin' 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_begin_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_begin_codeFragment">
<
xsl:
param name="
advices" />
<
xsl:
copy>
<
xsl:
copy-of select="
@*" />
<
xsl:
apply-templates mode="
weaving_function_begin_codeFragment">
<
xsl:
with-param name="
advices"
select="
$advices" />
</
xsl:
apply-templates>
</
xsl:
copy>
</
xsl:
template>
</
xsl:
stylesheet>
v