<
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>
Replaces an expression by a code fragment.</
xd:
short>
<
xd:
detail>
<
ul>
<
li>
srcML element: <
code>
src:expr</
code></
li>
<
li>
advice type: <
code>
replace</
code></
li>
<
li>
codeModifier type: <
code>
codeFragment</
code></
li>
</
ul>
<
xd:
weaverRuleLinks pointcutType="
src:expr"
adviceType="
replace"
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>
<
xd:
doc>
Replaces a expression with a code fragment.
If the expression element contains other advices, these must be handled first. This is
achieved by moving the replace advice to the end of the pending advices.
</
xd:
doc>
<
xsl:
template match="
src:expr[ax:advice[@type='replace' and position() = 1]/ax:codeModifier[@type='codeFragment']]"
mode="
weaving">
<!---->
<
xsl:
if test="
count(ax:advice[@type='replace']) > 1">
<
xsl:
message terminate="
yes">
[ERROR] expr_replace_codeFragment.xsl, only one replace advice is allowed per element!
<
xsl:
value-of select="
string-join(ax:advice[@type='replace']/@name,',')" /></
xsl:
message>
</
xsl:
if>
<
xsl:
choose>
<
xsl:
when test="
count(ax:advice) > 1">
<!---->
<
xsl:
copy>
<
xsl:
copy-of select="
@*" />
<
xsl:
copy-of select="
ax:advice[position() != 1]" />
<
xsl:
copy-of select="
ax:advice[1]" />
<
xsl:
apply-templates mode="
weaving" />
</
xsl:
copy>
</
xsl:
when>
<
xsl:
otherwise>
<!---->
<!---->
<
xsl:
variable name="
indent"
select="
util:repeatString($defaultIndentation, count(ancestor::src:block) + 1 - count(parent::src:block))" />
<!---->
<
ax:
inserted><
xsl:
value-of select="
util:indentText(xw:getCodeModifierContent(ax:advice[1]/ax:codeModifier), $indent, false())" /></
ax:
inserted>
</
xsl:
otherwise>
</
xsl:
choose>
</
xsl:
template>
</
xsl:
stylesheet>
v