Contents > E: Project File Format Definitions

E: Project File Format Definitions

This appendix contains the definitions of the project file formats for the metamodel definition file, the XMI transformation file, and the metrics definition files. Being XML files, the definition is presented in the form of a DTD (document type definition).

Metamodel definition file format

<!ELEMENT sdmetricsmetamodel ( modelelement+ ) >
<!ATTLIST sdmetricsmetamodel
	 version CDATA #REQUIRED>

<!ELEMENT modelelement (#PCDATA|attribute)*>
<!ATTLIST modelelement
	 name CDATA #REQUIRED
	 parent CDATA "sdmetricsbase">

<!ELEMENT attribute (#PCDATA)>
<!ATTLIST attribute
	 name CDATA #REQUIRED
	 type (ref|extref|data) "data"
	 multiplicity (one|many) "one">
XMI transformation file format

<!ELEMENT xmitransformations ( xmitransformation+ ) >
<!ATTLIST xmitransformations
	 version CDATA #REQUIRED
	 requirexmiid (true|false) "true">

<!ELEMENT xmitransformation (trigger*) >
<!ATTLIST xmitransformation
	 modelelement CDATA #REQUIRED
	 xmipattern CDATA #REQUIRED
	 recurse (true|false) "false"
	 requirexmiid (true|false) #IMPLIED
	 allowxmiidref (true|false) #IMPLIED
	 condition CDATA #IMPLIED>

<!ELEMENT trigger EMPTY>
<!ATTLIST trigger
	 name CDATA #REQUIRED
	 type (attrval|cattrval|gcattrval|ctext|reflist|constant|ignore|xmi2assoc) #REQUIRED
	 attr CDATA #IMPLIED
	 src CDATA #IMPLIED
	 linkbackattr CDATA #IMPLIED>
Metric definition file format
<!ELEMENT sdmetrics (metric|set|matrix|rule|wordlist|reference|term|
                     metricprocedure|setprocedure|ruleprocedure)+ >
<!ATTLIST sdmetrics
	 version CDATA #REQUIRED
	 ruleexemption CDATA #IMPLIED
	 exemptiontag CDATA #IMPLIED
	 exemptionvalue CDATA #IMPLIED>

<!ELEMENT metric (description?,(projection|setoperation|compoundmetric|
	attributevalue|nesting|signature|connectedcomponents|count|compare|
	subelements|filtervalue|substring))>
<!ATTLIST metric
	name CDATA #REQUIRED
	domain CDATA #REQUIRED
	inheritable (true|false) "false"
	category CDATA #IMPLIED
	internal (true|false) "false">

<!ELEMENT set (description?,(projection|compoundset|subelements|compare))>
<!ATTLIST set
	name CDATA #REQUIRED
	domain CDATA #REQUIRED
	inheritable (true|false) "false"
	multiset (true|false) "false">


<!ELEMENT matrix (description?,(projection|setoperation|compoundset))>
<!ATTLIST matrix
	name CDATA #REQUIRED
	from_row_type CDATA #REQUIRED
	to_col_type CDATA #REQUIRED>

<!ELEMENT rule (description?,(violation|cycle|projection|compoundset|
	valueset|compare))>
<!ATTLIST rule
	name CDATA #REQUIRED
	domain CDATA #REQUIRED
	inheritable (true|false) "false"
	category CDATA #IMPLIED
	severity CDATA #IMPLIED
	applies_to CDATA #IMPLIED
	disabled (true|false) "false">

<!ELEMENT wordlist (entry*)>
<!ATTLIST wordlist
	name CDATA #REQUIRED
	ignorecase (true|false) "false">

<!ELEMENT entry EMPTY>
<!ATTLIST entry
	word CDATA #REQUIRED>

<!ELEMENT description (#PCDATA)>

<!ENTITY % scopes "same|other|higher|lower|sameorhigher|sameorlower|samebranch|
	notsamebranch|containedin|notcontainedin|idem|notidem" >

<!ENTITY % filteratts
	'target CDATA #IMPLIED
	targetcondition CDATA #IMPLIED
	element CDATA #IMPLIED
	eltype CDATA #IMPLIED
	scope (%scopes;) #IMPLIED
	condition CDATA #IMPLIED'
>

<!ENTITY % sumatts
 'sum CDATA #IMPLIED
	stat (sum|min|max) "sum"'
>

<!ENTITY % ruleatts
 'precondition CDATA #IMPLIED
	mincnt CDATA #IMPLIED
	value CDATA #IMPLIED'
>

<!ELEMENT projection EMPTY>
<!ATTLIST projection
	relation CDATA #IMPLIED
	relset CDATA #IMPLIED
	%sumatts;
	set CDATA #IMPLIED
	valueset CDATA #IMPLIED
	exclude_self (true|false) "false"
	recurse (true|false) "false"
	nesting (true|false) "false"
	%ruleatts;
	%filteratts;>

<!ELEMENT compoundmetric EMPTY>
<!ATTLIST compoundmetric
	term CDATA #IMPLIED
	condition CDATA #IMPLIED
	alt CDATA #IMPLIED
	fallback CDATA #IMPLIED>

<!ELEMENT attributevalue EMPTY>
<!ATTLIST attributevalue
	attr CDATA #REQUIRED
	element CDATA #IMPLIED>

<!ELEMENT signature EMPTY>
<!ATTLIST signature
	set CDATA #REQUIRED
	name CDATA #IMPLIED
	prologue CDATA #IMPLIED
	value CDATA #IMPLIED
	separator CDATA #IMPLIED
	epilogue CDATA #IMPLIED
	%filteratts;>

<!ELEMENT connectedcomponents EMPTY>
<!ATTLIST connectedcomponents
	set CDATA #REQUIRED
	nodes CDATA #REQUIRED>

<!ELEMENT valuesetcount EMPTY>
<!ATTLIST valuesetcount
	set CDATA #REQUIRED>

<!ELEMENT count EMPTY>
<!ATTLIST count
	term CDATA #REQUIRED
	set CDATA #REQUIRED
	relset CDATA #REQUIRED
	%filteratts;>

<!ELEMENT compare EMPTY>
<!ATTLIST compare
	term CDATA #IMPLIED
	set CDATA #IMPLIED
	with CDATA #IMPLIED
	comp CDATA #IMPLIED
	return_element (true|false) "false"
	exclude_self (true|false) "true"
	%ruleatts;
	%filteratts;>

<!ELEMENT setoperation EMPTY>
<!ATTLIST setoperation
	set CDATA #REQUIRED
	%sumatts;
	%filteratts;>

<!ELEMENT nesting EMPTY>
<!ATTLIST nesting
	relation CDATA #REQUIRED>

<!ELEMENT subelements EMPTY>
<!ATTLIST subelements
	set CDATA #IMPLIED
	exclude_self (true|false) "true"
	valueset CDATA #IMPLIED
	%filteratts;
	%sumatts;>

<!ELEMENT filtervalue EMPTY>
<!ATTLIST filtervalue
	relation CDATA #IMPLIED
	relset CDATA #IMPLIED
	value CDATA #IMPLIED
	%filteratts;>

<!ELEMENT substring EMPTY>
<!ATTLIST substring
	source CDATA #REQUIRED
	separator CDATA #REQUIRED
	position CDATA #IMPLIED
	endseparator CDATA #IMPLIED
	limit CDATA #IMPLIED
	result CDATA #IMPLIED>

<!ELEMENT compoundset EMPTY>
<!ATTLIST compoundset
	set CDATA #REQUIRED
	cum CDATA #IMPLIED
	valueset CDATA #IMPLIED
	exclude_self (true|false) "false"
	%ruleatts;
	%filteratts;>

<!ELEMENT violation EMPTY>
<!ATTLIST violation
	condition CDATA #REQUIRED
	value CDATA #IMPLIED>

<!ELEMENT valueset EMPTY>
<!ATTLIST valueset
	set CDATA #REQUIRED
	precondition CDATA #IMPLIED
	mincnt CDATA #IMPLIED>

<!ELEMENT cycle EMPTY>
<!ATTLIST cycle
	nodes CDATA #REQUIRED
	minnodes CDATA #IMPLIED>

<!ELEMENT reference (#PCDATA|description)*>
<!ATTLIST reference
	tag CDATA #REQUIRED>

<!ELEMENT term (#PCDATA|description)*>
<!ATTLIST term
	name CDATA #REQUIRED>
	
<!ELEMENT metricprocedure EMPTY>
<!ATTLIST metricprocedure
        name CDATA #REQUIRED
        class CDATA #REQUIRED>
		
<!ELEMENT setprocedure EMPTY>
<!ATTLIST setprocedure
        name CDATA #REQUIRED
        class CDATA #REQUIRED>

<!ELEMENT ruleprocedure EMPTY>
<!ATTLIST ruleprocedure
        name CDATA #REQUIRED
        class CDATA #REQUIRED>
Grammar of expressions in metric definitions

The grammar for expressions in metric and set definitions is presented here using an extended Backus-Naur Formalism (EBNF). Note that the production rule FCT_LITERAL for function names recognized by the expression parser only lists the default functions provided by SDMetrics.


Expression            = UptoExpression.

UptoExpression        = OrExpression {"upto" OrExpression | "topmost" OrExpression}.

OrExpression          = AndExpression {"|" AndExpression | "or" AndExpression}.

AndExpression         = EqualExpression {"&" EqualExpression |
                                         "and" EqualExpression}.

EqualExpression       = RelationalExpression
                        ["!=" RelationalExpression | 
                          "=" RelationalExpression].

RelationalExpression  = AdditiveExpression [ "<" AdditiveExpression | 
                        ">" AdditiveExpression | "<=" AdditiveExpression | 
                        ">=" AdditiveExpression |"lt" AdditiveExpression |
                        "le" AdditiveExpression | "gt" AdditiveExpression |
                        "ge" AdditiveExpression | "->" AdditiveExpression |
                        "in" AdditiveExpression | 
                        "startswith" AdditiveExpression | 
                        "endswith" AdditiveExpression | 
                        "onlist" AdditiveExpression].

AdditiveExpression    = MultiplicativeExpression {
                        "+" MultiplicativeExpression |
                        "-" MultiplicativeExpression}.

MultiplicativeExpression 
                      = PowerExpression {
                        "*" PowerExpression | "/" PowerExpression }

PowerExpression       = DotExpression {"^" DotExpression |
                        "->" DotExpression |"in" DotExpression }.

DotExpression         = UnaryExpression {"." UnaryExpression}.

UnaryExpression       = "+" UnaryExpression | "-" UnaryExpression |
                        "!" UnaryExpression | "not" UnaryExpression |
                        FCT_LITERAL ExpressionList | "(" Expression ")".

ExpressionList        = "(" Expression {"," Expression} ")".

Constant              = STRING_LITERAL | IDENTIFIER | INTEGER_LITERAL 
                        | FLOATING_POINT_LITERAL.

FCT_LITERAL           = "ln" | "exp" | "sqrt" | "abs" |
                        "ceil" | "floor" | "round" | 
                        "startswithcapital" | "startswithlowercase" |
                        "islowercase" | "tolowercase" | 
                        "length" | "size" | "flatsize" |
                        "isunique" | "typeof" | "instanceof" | 
                        "qualifiedname".

INTEGER_LITERAL       = DECIMAL_LITERAL.

DECIMAL_LITERAL       = DIGIT {DIGIT}. 

FLOATING_POINT_LITERAL= ({DIGIT} "." DIGIT {DIGIT} [EXPONENT])
                        | DIGIT {DIGIT} [EXPONENT].

EXPONENT              = ("e"|"E") ["+"|"-"] DIGIT {DIGIT}.

STRING_LITERAL        = "'" {LETTER|DIGIT} "'".

IDENTIFIER            = LETTER {LETTER|DIGIT}. 

LETTER                =  "_" | "A".."Z" | "a".."z".

DIGIT                 = "0" | "1" | "2" | "3" | "4" | "5" | 
                        "6" | "7" | "8" | "9".