![]() |
The application of XSL for XML transformations in e-business solutions | Table of contents | Indexes | Text analysis tools for XML documents using regular expressions &, XSL | ![]() |
|||
| XML, Model engineering, Model transformation, XSLT, XMI. | On levels of model transformation |
| Peltier, Mikaël |
| Mikaël Peltier |
| Ph.D. Student |
Cesson-Sévigné ![]() FTRD/DIH/HDM/DEI ![]() France ![]() | FTRD/DIH/HDM/DEI,
4, rue du Clos Courtel, BP 59 Cesson-Sévigné 35512 France Phone: (03) 02 99 12 38 37 email: mikael.peltier@cnet.francetelecom.fr |
| Biography |
| Mikaël Peltier - Mikaël Peltier works at France Telecom R&D; Rennes, while doing a Ph.D. at the University of Nantes on the subject of XML-based transformation languages and meta-modeling. |
| Ziserman, François |
| François Ziserman |
| Engineer |
Cesson-Sévigné ![]() FTRD/DIH/HDM/DEI ![]() France ![]() | FTRD/DIH/HDM/DEI,
4, rue du Clos Courtel, BP 59 Cesson-Sévigné 35512 France Phone: (03) 02 99 12 39 53 email: francois.ziserman@cnet.francetelecom.fr |
| Biography |
| Bézivin, Jean |
| Jean Bézivin |
| Professor |
France ![]() Nantes ![]() Université de Nantes, LRSG | Université de Nantes, LRSG,
2, rue de la Houssinière, B.P. 92208 Nantes 44322 France Phone: (03) 02 51 12 58 13 email: Jean.Bezivin@sciences.univ-nantes.fr |
| Biography |
| Abstract |
Introduction |
Model organization |
| MOF |
|
Architecture of translator between abstract and concrete level |
|
Formalism |
Entity [Restriction]? to Entity |
Attribute to Field |
| The second part represents transformations, which are applied on attributes and roles of the source entity. The pattern for those transformations is the following: |
attributes : attributes transformation roles : roles transformation |
nameOfAttribut = value |
| The value of an attribute can be of different types: |
| In addition to the attribute transformation, we also allow role transformation. As attribute transformation, role transformation is realized by a standard assignment, with the following syntax: |
nameOfRole = value |
| The value of a role can be of different types: |
fields = feature [ Attribute ] method = feature [ Operation ] |
| Now, that we presented our formalism, we are going to define a mapping between abstract and concrete level. |
Mapping between our formalism and XSLT |
Entity1 [ attOrRole operator value]? to Entity2 |
| The XSLT fragment that corresponds to the mapping of entities transformation is the following one: |
<xsl:template match="Entity1" > <xsl:if test="attOrRole operator value"> <xsl:element name="Entity2"> <!--attributes mapping --> <!--roles mapping --> <xsl:apply-templates select="./child::node()" mode="Entity1"/> </xsl:element> </xsl:if> </xsl:template> |
Attributes mapping |
<x y="..."/> or <x> <y>...</y> </x> |
a = "value" This code is transformed into a XSLT fragment, which is the following one: |
<xsl:attribute name="a"> <xsl:value-of select="'value'"/> </xsl:attribute> |
a = b This code is mapped into a XSLT fragment, which is the following one: |
<!--First part --> <xsl:variable name="cond"> <xsl:value-of select="@b"/> </xsl:variable> <xsl:if test="$cond!=''> <xsl:attribute name="a"> <xsl:value-of select="$cond"/> </xsl:attribute> </xsl:if> <!--Second part--> <xsl:if test="$cond=''> <xsl:element name="a"> <xsl:value-of select="./owner.b"/> </xsl:element> </xsl:if> |
First part of attribute mapping (a) First part of attribute mapping (c) Second part of attribute mapping (a) Second part of attribute mapping (c) |
a = ( b op 'value' ? c : d ) This code is mapped into a XSLT fragment, which is the following one: |
<xsl:attribute name="a"> <xsl:variable name="cond"> <xsl:value-of select="@b"/> </xsl:variable> <xsl:if test="$cond=''"> <xsl:variable name="cond"> <xsl:value-of select="./owner.b"/> </xsl:variable> </xsl:if> <xsl:if test="$cond='value'"> <!--mapping based on kind of c --> </xsl:if> <xsl:if test="$cond!='value'"> <!--mapping based on kind of d --> </xsl:if> </xsl:attribute> |
| A conditional is mapped by using xsl:if instruction. The mapping for "c" and "d" depend on his kind. Therefore, the mapping refers to one of three mapping for attributes that we presented above. |
Roles mapping |
| Now that we described the mapping for entities and attributes, we still have to explain the mapping of roles. The two cases for roles transformations are presented below. |
<xsl:variable name="cond"> <xsl:value-of select="@b"/> </xsl:variable> <xsl:if test="$cond!=''"> <xsl:attribute name="a"> <xsl:value-of select="$cond"/> </xsl:attribute> </xsl:if> <xsl:if test="$cond=''"> <xsl:apply-templates select="./owner.b"/ mode="single> </xsl:if> <xsl:template match="owner.b" mode="single"> <xsl:element name="a"> <xsl:apply-templates select="./child::node()"/> (1) </xsl:element> </xsl:templates> |
a = b.c The code above is mapped into a XSLT fragment presented below: |
<xsl:variable name="cond"> (2) <xsl:value-of select="@b"/> </xsl:variable> <xsl:if test="$cond!=''"> <!-- generate a template which is called strip-value --> </xsl:if> <xsl:template match="b.dest"> <!-- the code generated here depend if c is the last role --> </xsl:template> |
|
<xsl:template match="owner.b" mode="ownerEntity"> <xsl:element name="a"> <xsl:apply-templates select="./child::node()"/> </xsl:element> </xsl:templates> |
a = ( b = value ? c : d ) This code is mapped into a XSLT fragment, which is the following one: |
<xsl:attribute name="a"> <!-- variable value is assigned to value of b --> <xsl:if test="contains($value,'value')"> <!--mapping based on kind of c --> </xsl:if> <xsl:if test="not(contains($value,'value'))"> <!--mapping based on kind of d --> </xsl:if> </xsl:attribute> |
UML to Java as example |
| We transform a uml model to a java model, as an example of a toy illustrative transformation system. as transformation rules are expressed on meta-models, we depicted them below: |
|
|
Attribute to Field {
attributes :
name=name,
visibility=visibility,
share = (ownerScope=="classifier" ? "static" : "none"),
state= (changeability=="frozen" ? "final" : "none")
roles:
resultType = (type==Integer ? Int :
(type==String ? String :
(type==Class ? type)))
}
|
ResultType = (parameter.kind == "out" ? ( parameter.type == Integer ? Int : ( parameter.type == String ? String : ( parameter.type == Class ? parameter.type )))) |
Fields = feature [ Attribute ], Methods = feature [ Operation ] |
<UML:Class xmi.id="Shape" isAbstract="true" visibility="public" isRoot="true" isActive="false" name="Shape" isLeaf="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="name" visibility="public" changeability=" changeable" ownerScope="instance" type="String" name="name" targetScope="instance" multiplicity="1,1"/> </UML:Classifier.feature> <UML:GeneralizableElement.specialization> <UML:Generalization child="Circle " xmi.id="GCircleShape" visibility="public" parent="Shape " name="GCircleShape"/> </UML:GeneralizableElement.specialization> </UML:Class> <UML:Class generalization="GCircleShape " xmi.id="Circle" isAbstract="false" visibility="public" isRoot="false" isActive="false" name="Circle" isLeaf="true"> <UML:Classifier.feature> <UML:Attribute xmi.id="CR" visibility="public" changeability="changeable" ownerScope="instance" type="Integer" name="R" targetScope="instance" multiplicity="1,1" owner="Circle"/> <UML:Attribute xmi.id="CX" visibility="public" changeability="changeable" ownerScope="instance" type="Integer" name="X" targetScope="instance" multiplicity="1,1" owner="Circle"/> <UML:Attribute xmi.id="CY" visibility="public" changeability="changeable" ownerScope="instance" type="Integer" name="Y" targetScope="instance" multiplicity="1,1" owner="Circle"/> <UML:Operation isPolymorphic="true" visibility="public" ownerScope="instance" isQuery="false" name="pos" concurrency="guarded"owner="Circle "> <UML:BehavioralFeature.parameter> <UML:Parameter xmi.id="px" visibility="public" type="Integer " name="px" behavioralFeature="pos"> <UML:Parameter.kind xmi.value="in"/> </UML:Parameter> <UML:Parameter kind="in" xmi.id="py" visibility="public" type="Integer " name="py" behavioralFeature="pos"/> <UML:Parameter kind="out" xmi.id="result" visibility="public" type="Integer " name="result" behavioralFeature="pos"/> </UML:BehavioralFeature.parameter> </UML:Operation> </UML:Classifier.feature> </UML:Class> <UML:DataType xmi.id="String" isAbstract="false" visibility="public" isRoot="false" name="String" isLeaf="false"/> <UML:DataType xmi.id="Integer" isAbstract="false" visibility="public" isRoot="false" name="Integer" isLeaf="false"/> <UML:Generalization child="Polygon " parent="shape " xmi.id="GPolygonShape" visibility="public" name="GPolygonShape"/> |
| The XML fragment below corresponds to the transformation result of the UML model above. |
<JAVA:Class name="Shape" visibility="public" state="abstract" subclass="Circle "> <JAVA:fields> <JAVA:Field share="none" name="name" visibility="public" state="none" typeOf="String"/> </JAVA:fields> <JAVA:methods/> </JAVA:Class> <JAVA:Class name="Circle" visibility="public" state="none" superclass="Shape "> <JAVA:fields> <JAVA:Field share="none" name="R" visibility="public" state="none" typeOf="Int"/> <JAVA:Field share="none" name="X" visibility="public" state="none" typeOf="Int"/> <JAVA:Field share="none" name="Y" visibility="public" state="none" typeOf="Int"/> </JAVA:fields> <JAVA:methods> <JAVA:Method name="pos" visibility="public" state="final synchronized" share="none" ownerClass="Circle " resultType="Int"> <JAVA:parameters> <JAVA:Parameter name="px" owner="pos" typeOf="Int"/> <JAVA:Parameter name="py" owner="pos" typeOf="Int"/> </JAVA:parameters> </JAVA:Method> </JAVA:methods> </JAVA:Class> |
Conclusion |
| Acknowledgements |
| We want to thank Mariano Belaunde for many inspiring remarks on this work and for the time that he spent to apply our meta-models in the Universalis Environment. |
| Bibliography |
|
|
|
|
|
|
|
|
|
|
|
|
|
![]() |
The application of XSL for XML transformations in e-business solutions | Table of contents | Indexes | Text analysis tools for XML documents using regular expressions &, XSL | ![]() | |||