axc.xsl
Includes
AspectX Compiler
This XSL stylesheet compiles a program written in
AspectX into an XSL stylesheet.
The resulting stylesheet is able to add advice elements to
srcML base
code. See templates documentation (especially the root template) for a more detailed description.
CVS Id:
axc.xsl 138 2005-07-27 09:14:07Z ibirrer
Author:
ibirrer
Copyright:
2005, P&P Software GmbH
Match Templates Summary
If an unsupported element is encountered, the program aborts and outputs an errror message
Empty template to exclude description and text elements from the XPath creation for pointcuts
ax:pointcut[not(parent::ax:restriction) and ( not(@constraint) or string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) = 0 )] (mode: pointcutXPath) - source
element: ax:pointcut
parent: none
constraint: none or empty
ax:pointcut[not(parent::ax:restriction) and @constraint and string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) != 0] (mode: pointcutXPath) - source
element: ax:pointcut
parent: none
constraint: yes (not empty)
ax:pointcut[parent::ax:restriction and ( not(@constraint) or string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) = 0 )] (mode: pointcutXPath) - source
element: ax:pointcut
parent: yes
constraint: none or empty
ax:pointcut[parent::ax:restriction and @constraint and string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) != 0] (mode: pointcutXPath) - source
element: ax:pointcut
parent: yes
constraint: yes (not empty)
A reference to a pointcut is resolved to the corresponding
pointcut
A reference to a pointcut is resolved to the corresponding
pointcut
Removing description elements completely
Replaces variables used in codeModifiers (format: ${VariableName})with the <xsl:value-of .../> equivalent.
Resolve includes
Add apspect attribute to named pointcut elements and pointcutRef elements
Match Templates Detail
Main Root template
Resolves any includes and hands the resulting file to the templates with mode
compiler.
Resolving includes is done by templates with mode resolveIncludes.
Builds the general structure of the locator stylesheet.
Procedure:
- 1. Find all anonymous pointcut and pointcutRef elements used for advices. These are all pointcut and pointcutRef elements definded as a direct child of an advice. Descendants of these are not inlcuded, neither are named pointcuts.
- 2. Group the elements found by the type attribute. This means that a group consists of pointcut or pointcutRef elements which have the same value for the type attribute. Then iterate through the groups (Each group is processed once).
- 2.1 Build an unnamed template for each group. The match attribute value is set to the common type attribute value of the group.
- 2.2 Iterate through all distinct pointcutRef (a pointcutRef element is equal with another if their ref attribute value is equal) elements and all pointcut elements in the group.
- 2.2.1 Build an if statement for each group
- 2.2.2 Generate the XPath expression from the pointcut (Using the first pointcut in the group).
This uses templates with mode
pointcutXPath. PoinctutRef elements are translated to their corresponding pointcut element in a template with modepointcutXPath. - 2.2.3 Find all advices which use any of the pointcuts or pointcutRef's in the group and copy them. (These are the advices which are direct parents of a pointcut or pointcutRef)
src:class,
is processed for each src:class element in the srcML base code. Because all src:class elements are processed
by this template the template logic needs to decide if an advice should be added to a specific src:class element. This is achieved
by generating several xsl:if clauses inside the template. Each xsl:if tests if a pointcut matches the srcML element currently
processed. Note that xsl:choose
would not work for this purpose as it would only allow one pointcut to match one srcML element but of course there can be several pointcuts that match one
srcML element (=pointcut type). Generating the test attribute of the xsl:if clause is done by several templates with the mode pointcutXPath (See also
stylesheets in compilerRules/restrictions).
If an unsupported element is encountered, the program aborts and outputs an errror message
Empty template to exclude description and text elements from the XPath creation for pointcuts
ax:pointcut[not(parent::ax:restriction) and ( not(@constraint) or string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) = 0 )] (mode: pointcutXPath) - source
element: ax:pointcut
parent: none
constraint: none or empty
ax:pointcut[not(parent::ax:restriction) and @constraint and string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) != 0] (mode: pointcutXPath) - source
element: ax:pointcut
parent: none
constraint: yes (not empty)
ax:pointcut[parent::ax:restriction and ( not(@constraint) or string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) = 0 )] (mode: pointcutXPath) - source
element: ax:pointcut
parent: yes
constraint: none or empty
ax:pointcut[parent::ax:restriction and @constraint and string-length(replace(@constraint, '^[ \t]+|[ \t]+$', '')) != 0] (mode: pointcutXPath) - source
element: ax:pointcut
parent: yes
constraint: yes (not empty)
A reference to a pointcut is resolved to the corresponding
pointcut
This pointcut is then again applied to the templates
taking a pointcut to generate the XPath expression.
A reference to a pointcut is resolved to the corresponding
pointcut
This pointcut is then again applied to the templates
taking a pointcut to generate the XPath expression.
In this case the parent element is a restriction and therefore
the type of the pointcut needs to be output.
Removing description elements completely
Replaces variables used in codeModifiers (format: ${VariableName})with the <xsl:value-of .../> equivalent.
This template uses regular expression of XSLT 2.0. Using
<![[CDATA[
sections makes it possible to generate new xsl elements.
If a dollarVariable is written in the form ${ var}, the space between the opening curly brace and the
closing curly brace is added to variable as indentation. This is especially useful for the dollar variables
$functionBody in an 'around' advice.
Removing xsl elements
children of xsl elements are processed further.
Resolve includes
Replaces include elements by all contents (pointcuts, advices) of the aspect it refers to.
Add apspect attribute to named pointcut elements and pointcutRef elements
If an aspect attribute already exists
it is not replaces.