<
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 adds a declaration to a class</
xd:
short>
<
xd:
detail>
<
ul>
<
li>
srcML element: <
code>
src:private, src:protected, src:public</
code></
li>
<
li>
advice type: <
code>
add</
code></
li>
<
li>
codeModifier type: <
code>
declaration</
code></
li>
</
ul>
<
p>
This template is used as by <
a href="
class_add_declaration.xsl.xd.html">
class_add_declaration.xsl</
a>
.
It is not intended to use directly from an aspect.</
p>
</
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>
Adds a declaration to an access modifier block
</
xd:
doc>
<
xsl:
template match="
src:private[ax:advice[@type='add' and position() = 1]/ax:codeModifier[@type='declaration']] | src:protected[ax:advice[@type='add' and position() = 1]/ax:codeModifier[@type='declaration']] | src:public[ax:advice[@type='add' and position() = 1]/ax:codeModifier[@type='declaration']]"
mode="
weaving">
<!---->
<
xsl:
variable name="
advice"
select="
ax:advice[1]" />
<!---->
<
xsl:
variable name="
accessModifierString">
<
xsl:
choose>
<
xsl:
when test="
@type='default'" />
<
xsl:
otherwise>
<
xsl:
value-of select="
concat(local-name(.), ':')" />
</
xsl:
otherwise>
</
xsl:
choose>
</
xsl:
variable>
<!---->
<
xsl:
variable name="
blockIndent"
select="
util:repeatString($defaultIndentation, count(ancestor::src:block))" />
<!---->
<
xsl:
copy>
<
xsl:
copy-of select="
@*" />
<!---->
<
xsl:
copy-of select="
ax:advice[position() != 1]" />
<
xsl:
choose>
<
xsl:
when test="
count(*[not(self::ax:advice)]) = 0">
<!---->
<!---->
<
xsl:
value-of select="
substring-before(text(), $accessModifierString)" />
<!---->
<
xsl:
value-of select="
concat($accessModifierString, ' ')" />
<!---->
<
xsl:
value-of select="
util:indentText(xw:getCodeModifierContent($advice/ax:codeModifier), $blockIndent)" />
<!---->
<
xsl:
value-of select="
substring-after(text(), $accessModifierString)" />
</
xsl:
when>
<
xsl:
otherwise>
<!---->
<!---->
<
xsl:
apply-templates mode="
weaving"
select="
node()[not(position() = last() and self::text()) and not(self::ax:advice)]" />
<!---->
<
xsl:
text>
</
xsl:
text>
<!---->
<
xsl:
value-of select="
util:indentText(xw:getCodeModifierContent($advice/ax:codeModifier), $blockIndent)" />
<!---->
<
xsl:
apply-templates select="
node()[position() = last() and self::text()]"
mode="
weaving" />
</
xsl:
otherwise>
</
xsl:
choose>
</
xsl:
copy>
</
xsl:
template>
</
xsl:
stylesheet>
v