support multiplicites and ordering kind for attributes

git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@2976 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Jürgen Doser 2005-08-23 15:03:15 +00:00
parent cc344ed2d3
commit 8ded57064a
3 changed files with 29 additions and 11 deletions

View File

@ -79,6 +79,14 @@ fun getOrdering atts =
| _ => raise IllFormed ("in getOrdering: found unexpected attribute value "^att)
end
fun getOrderingMaybe atts =
let val att = XmlTree.attvalue_of "ordering" atts
in
case att of SOME "unordered" => XMI_UML.Unordered
| SOME "ordered" => XMI_UML.Ordered
| _ => XMI_UML.Unordered
end
fun getAggregation atts =
let val att = getStringAtt "aggregation" atts in
case att of "none" => XMI_UML.NoAggregation
@ -106,6 +114,10 @@ fun getKind atts =
fun getRange atts = (getIntAtt "lower" atts, getIntAtt "upper" atts)
fun mkMultiplicity tree = map (getRange o XmlTree.attributes_of)
(((XmlTree.filter "UML:MultiplicityRange") o
(XmlTree.skip "UML:Multiplicity.range") o hd o
(XmlTree.skip "UML:Multiplicity")) tree)
fun mkAssociationEnd tree =
let fun f atts trees =
@ -114,12 +126,8 @@ fun mkAssociationEnd tree =
isNavigable = getBoolAtt "isNavigable" atts,
ordering = getOrdering atts,
aggregation = getAggregation atts,
multiplicity = (map (getRange o XmlTree.attributes_of)
(((XmlTree.filter "UML:MultiplicityRange") o
(XmlTree.skip "UML:Multiplicity.range") o hd o
(XmlTree.skip "UML:Multiplicity") o hd o
(XmlTree.follow "UML:AssociationEnd.multiplicity"))
trees)),
multiplicity = (mkMultiplicity o hd o (XmlTree.follow "UML:AssociationEnd.multiplicity"))
trees,
changeability = getChangeability atts,
visibility = getVisibility atts,
participant_id = (getXmiIdref o XmlTree.attributes_of o hd o
@ -368,8 +376,11 @@ fun mkAttribute tree =
name = getName atts,
visibility = getVisibility atts,
changeability = getChangeability atts,
ordering = getOrderingMaybe atts,
type_id = (getXmiIdref o XmlTree.attributes_of o hd o
(XmlTree.follow "UML:StructuralFeature.type")) trees }
(XmlTree.follow "UML:StructuralFeature.type")) trees,
multiplicity = (mkMultiplicity o hd o (XmlTree.follow "UML:StructuralFeature.multiplicity"))
trees}
in XmlTree.apply_on "UML:Attribute" f tree
handle XmlTree.IllFormed msg => raise IllFormed ("in mkAttribute: "^msg)
end

View File

@ -286,8 +286,15 @@ fun transform_operation t {xmiid,name,isQuery,parameter,visibility,
fun transform_attribute t ({xmiid,name,type_id,changeability,visibility}) =
(name,find_classifier_type t type_id)
fun transform_attribute t ({xmiid,name,type_id,changeability,visibility,
ordering,multiplicity}) =
let val cls_type = find_classifier_type t type_id
in
(name,if multiplicity = [(1,1)]
then cls_type
else if ordering = XMI_UML.Ordered then ocl_type.Sequence cls_type
else ocl_type.Set cls_type)
end
fun transform_aend t ({xmiid,name,ordering,multiplicity,participant_id,
isNavigable,aggregation,changeability,visibility})

View File

@ -283,8 +283,8 @@ type Attribute = { xmiid : string,
type_id : string, (* xmi.idref to type *)
(* initialValue : ..., *)
(* inherited from StructuralFeature: *)
(* multiplicity : (int * int) list, *)
(* ordering : OrderingKind *)
multiplicity : Multiplicity,
ordering : OrderingKind,
(* targetScope : ScopeKind *)
changeability : ChangeableKind,
(* inherited from Feature: *)