OQL SERF Transformation Example:Inline Hrefelement
begin template hrefInline (Class parent, Attribute href, Attribute hrefValue)
//find the metaclass whose instances are refered by xlink:href
define hrefClass(href) as
element(select a.attrType
from Attribute a, MetaClass c
where a.attrName = href.attrName and a.classDefinedIn = c );
// get all the attributes of the hrefClass and add to the parent class
define query attr(cl) as:
for all x in attr(hrefClass):
add_attribute ($parent, x.attrName, x.attrType);
//define the extent of class cl
define query extent(cl) as:
// Update the attribute value
for all obj in extent($parent):
for all attr in attr(hrefClass):
obj.setValue($parent.attr, $parent.$href.attr);
// add all the Elements of hrefClass to parent
for all sub in elements(hrefClass):
addSubElement($parent, sub);
// Delete the href attribute from the parent class delete_attribute ($parent, $href);
delete_attribute($parent,$hrefValue);