Bonjour,
j'ai exporté cet fichier a partir d'un diagramme de classe. le probléme c'est lorsque je parse cet fichier sous le nom (untitled.xmi) ça marche pas est c'est indiqué comme erreur mais lorsque je change l'extension vers (.XML) le code parait sans erreur mais en exécution la méthode qui permet d'extraire des informations de a partir ce fichier ne marche pas (pas d'affichage).
voici le fichier XMI:
voici le code de la fonction: merci de m'aider c'est très urgent .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 <?xml version = "1.0" encoding = "UTF-8"?> <XMI xmi.version = "1.1" xmlns:UML="href://org.omg/UML/1.3"> <XMI.header> <XMI.documentation> <XMI.owner></XMI.owner> <XMI.contact></XMI.contact> <XMI.exporter>StarUML.XMI-Addin</XMI.exporter> <XMI.exporterVersion>1.0</XMI.exporterVersion> <XMI.notice></XMI.notice> </XMI.documentation> <XMI.metamodel xmi.name = "UML" xmi.version = "1.3"/> </XMI.header> <XMI.content> <UML:Model xmi.id="UMLProject.1"> <UML:Namespace.ownedElement> <UML:Model xmi.id="UMLModel.2" name="Use Case Model" visibility="public" isSpecification="false" namespace="UMLProject.1" isRoot="false" isLeaf="false" isAbstract="false"> <UML:Namespace.ownedElement> <UML:Stereotype xmi.id="X.59" name="useCaseModel" extendedElement="UMLModel.2"/> </UML:Namespace.ownedElement> </UML:Model> <UML:Model xmi.id="UMLModel.3" name="Analysis Model" visibility="public" isSpecification="false" namespace="UMLProject.1" isRoot="false" isLeaf="false" isAbstract="false"> <UML:Namespace.ownedElement> <UML:Stereotype xmi.id="X.60" name="analysisModel" extendedElement="UMLModel.3"/> </UML:Namespace.ownedElement> </UML:Model> <UML:Model xmi.id="UMLModel.4" name="Design Model" visibility="public" isSpecification="false" namespace="UMLProject.1" isRoot="false" isLeaf="false" isAbstract="false"> <UML:Namespace.ownedElement> <UML:Class xmi.id="UMLClass.5" name="vehicule" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.20 UMLAssociationEnd.31" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.6" name="marque" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.5"/> <UML:Attribute xmi.id="UMLAttribute.7" name="modele" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.5"/> <UML:Attribute xmi.id="UMLAttribute.8" name="couleur" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.5"/> </UML:Classifier.feature> </UML:Class> <UML:Class xmi.id="UMLClass.9" name="capteur" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.16 UMLAssociationEnd.19" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.10" name="id_capteur" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.9"/> </UML:Classifier.feature> </UML:Class> <UML:Class xmi.id="UMLClass.11" name="mesure" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.17 UMLAssociationEnd.30 UMLAssociationEnd.33" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.12" name="type" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.11"/> <UML:Attribute xmi.id="UMLAttribute.13" name="instant" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.11"/> <UML:Attribute xmi.id="UMLAttribute.14" name="intervalle" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.11"/> </UML:Classifier.feature> </UML:Class> <UML:Association xmi.id="UMLAssociation.15" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.16" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.15" type="UMLClass.9"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.17" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.15" type="UMLClass.11"/> </UML:Association.connection> </UML:Association> <UML:Association xmi.id="UMLAssociation.18" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.19" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.18" type="UMLClass.9"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.20" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.18" type="UMLClass.5"/> </UML:Association.connection> </UML:Association> <UML:Class xmi.id="UMLClass.21" name="alerte" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.37 UMLAssociationEnd.42 UMLAssociationEnd.48" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.22" name="instant" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.21"/> <UML:Attribute xmi.id="UMLAttribute.23" name="intervalle" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.21"/> <UML:Attribute xmi.id="UMLAttribute.24" name="type" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.21"/> </UML:Classifier.feature> </UML:Class> <UML:Class xmi.id="UMLClass.25" name="SAGT" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.34 UMLAssociationEnd.36" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.26" name="identifiant" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.25"/> <UML:Operation xmi.id="UMLOperation.27" name="analysermesure" visibility="public" isSpecification="false" ownerScope="instance" isQuery="false" concurrency="sequential" isRoot="false" isLeaf="false" isAbstract="false" specification="" owner="UMLClass.25"/> <UML:Operation xmi.id="UMLOperation.28" name="produirealerte" visibility="public" isSpecification="false" ownerScope="instance" isQuery="false" concurrency="sequential" isRoot="false" isLeaf="false" isAbstract="false" specification="" owner="UMLClass.25"/> </UML:Classifier.feature> </UML:Class> <UML:Association xmi.id="UMLAssociation.29" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.30" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.29" type="UMLClass.11"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.31" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.29" type="UMLClass.5"/> </UML:Association.connection> </UML:Association> <UML:Association xmi.id="UMLAssociation.32" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.33" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.32" type="UMLClass.11"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.34" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.32" type="UMLClass.25"/> </UML:Association.connection> </UML:Association> <UML:Association xmi.id="UMLAssociation.35" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.36" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.35" type="UMLClass.25"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.37" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.35" type="UMLClass.21"/> </UML:Association.connection> </UML:Association> <UML:Class xmi.id="UMLClass.38" name="PMV" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" participant="UMLAssociationEnd.43" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.39" name="identifiant" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.38"/> <UML:Attribute xmi.id="UMLAttribute.40" name="emplacement" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.38"/> </UML:Classifier.feature> </UML:Class> <UML:Association xmi.id="UMLAssociation.41" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.42" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.41" type="UMLClass.21"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.43" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.41" type="UMLClass.38"/> </UML:Association.connection> </UML:Association> <UML:Class xmi.id="UMLClass.44" name="evenement" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" specialization="UMLGeneralization.55 UMLGeneralization.56" participant="UMLAssociationEnd.49" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.45" name="instant" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.44"/> <UML:Attribute xmi.id="UMLAttribute.46" name="intervalle" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.44"/> </UML:Classifier.feature> </UML:Class> <UML:Association xmi.id="UMLAssociation.47" name="" visibility="public" isSpecification="false" namespace="UMLModel.4"> <UML:Association.connection> <UML:AssociationEnd xmi.id="UMLAssociationEnd.48" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.47" type="UMLClass.21"/> <UML:AssociationEnd xmi.id="UMLAssociationEnd.49" name="" visibility="public" isSpecification="false" isNavigable="true" ordering="unordered" aggregation="none" targetScope="instance" changeability="changeable" association="UMLAssociation.47" type="UMLClass.44"/> </UML:Association.connection> </UML:Association> <UML:Class xmi.id="UMLClass.50" name="TDM" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" generalization="UMLGeneralization.55" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.51" name="matricule_vehicule" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.50"/> </UML:Classifier.feature> </UML:Class> <UML:Class xmi.id="UMLClass.52" name="incident" visibility="public" isSpecification="false" namespace="UMLModel.4" isRoot="false" isLeaf="false" isAbstract="false" generalization="UMLGeneralization.56" isActive="false"> <UML:Classifier.feature> <UML:Attribute xmi.id="UMLAttribute.53" name="type" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.52"/> <UML:Attribute xmi.id="UMLAttribute.54" name="gravite" visibility="public" isSpecification="false" ownerScope="instance" changeability="changeable" targetScope="instance" type="" owner="UMLClass.52"/> </UML:Classifier.feature> </UML:Class> <UML:Generalization xmi.id="UMLGeneralization.55" name="" visibility="public" isSpecification="false" namespace="UMLModel.4" discriminator="" child="UMLClass.50" parent="UMLClass.44"/> <UML:Generalization xmi.id="UMLGeneralization.56" name="" visibility="public" isSpecification="false" namespace="UMLModel.4" discriminator="" child="UMLClass.52" parent="UMLClass.44"/> <UML:Stereotype xmi.id="X.61" name="designModel" extendedElement="UMLModel.4"/> <UML:Stereotype xmi.id="X.62" name="observed-element" extendedElement="UMLClass.5"/> <UML:Stereotype xmi.id="X.66" name="observer" extendedElement="UMLClass.9"/> <UML:Stereotype xmi.id="X.68" name="measure" extendedElement="UMLClass.11"/> <UML:Stereotype xmi.id="X.72" name="alert" extendedElement="UMLClass.21"/> <UML:Stereotype xmi.id="X.76" name="controler" extendedElement="UMLClass.25"/> <UML:Stereotype xmi.id="X.78" name="actuator" extendedElement="UMLClass.38"/> <UML:Stereotype xmi.id="X.81" name="event" extendedElement="UMLClass.44"/> </UML:Namespace.ownedElement> </UML:Model> <UML:Model xmi.id="UMLModel.57" name="Implementation Model" visibility="public" isSpecification="false" namespace="UMLProject.1" isRoot="false" isLeaf="false" isAbstract="false"> <UML:Namespace.ownedElement> <UML:Stereotype xmi.id="X.87" name="implementationModel" extendedElement="UMLModel.57"/> </UML:Namespace.ownedElement> </UML:Model> <UML:Model xmi.id="UMLModel.58" name="Deployment Model" visibility="public" isSpecification="false" namespace="UMLProject.1" isRoot="false" isLeaf="false" isAbstract="false"> <UML:Namespace.ownedElement> <UML:Stereotype xmi.id="X.88" name="deploymentModel" extendedElement="UMLModel.58"/> </UML:Namespace.ownedElement> </UML:Model> </UML:Namespace.ownedElement> </UML:Model> <UML:TaggedValue xmi.id="X.63" tag="ordering" value="unordered" modelElement="UMLAttribute.6"/> <UML:TaggedValue xmi.id="X.64" tag="ordering" value="unordered" modelElement="UMLAttribute.7"/> <UML:TaggedValue xmi.id="X.65" tag="ordering" value="unordered" modelElement="UMLAttribute.8"/> <UML:TaggedValue xmi.id="X.67" tag="ordering" value="unordered" modelElement="UMLAttribute.10"/> <UML:TaggedValue xmi.id="X.69" tag="ordering" value="unordered" modelElement="UMLAttribute.12"/> <UML:TaggedValue xmi.id="X.70" tag="ordering" value="unordered" modelElement="UMLAttribute.13"/> <UML:TaggedValue xmi.id="X.71" tag="ordering" value="unordered" modelElement="UMLAttribute.14"/> <UML:TaggedValue xmi.id="X.73" tag="ordering" value="unordered" modelElement="UMLAttribute.22"/> <UML:TaggedValue xmi.id="X.74" tag="ordering" value="unordered" modelElement="UMLAttribute.23"/> <UML:TaggedValue xmi.id="X.75" tag="ordering" value="unordered" modelElement="UMLAttribute.24"/> <UML:TaggedValue xmi.id="X.77" tag="ordering" value="unordered" modelElement="UMLAttribute.26"/> <UML:TaggedValue xmi.id="X.79" tag="ordering" value="unordered" modelElement="UMLAttribute.39"/> <UML:TaggedValue xmi.id="X.80" tag="ordering" value="unordered" modelElement="UMLAttribute.40"/> <UML:TaggedValue xmi.id="X.82" tag="ordering" value="unordered" modelElement="UMLAttribute.45"/> <UML:TaggedValue xmi.id="X.83" tag="ordering" value="unordered" modelElement="UMLAttribute.46"/> <UML:TaggedValue xmi.id="X.84" tag="ordering" value="unordered" modelElement="UMLAttribute.51"/> <UML:TaggedValue xmi.id="X.85" tag="ordering" value="unordered" modelElement="UMLAttribute.53"/> <UML:TaggedValue xmi.id="X.86" tag="ordering" value="unordered" modelElement="UMLAttribute.54"/> </XMI.content> </XMI>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 public class Affichage { public static void main(String[] args) { try { affichage(); } catch(ClassNotFoundException e) { e.printStackTrace(); } } public static void affichage() throws ClassNotFoundException { /* Création du parseur */SAXBuilder builder = new SAXBuilder(); File fichierxmi = new File("Untitled.xmi"); Document document; try { /* Parsing du fichier */ document = builder.build(fichierxmi); Namespace ns = Namespace.getNamespace("UML", "org.omg.xmi.namespace.UML"); /* Racine du document XML : dans notre cas <diagramme> */ Element rootNode = document.getRootElement(); List<Element> row = rootNode.getChildren("XMI.content"); List<String> temps = new ArrayList<String>(); List<String> autres = new ArrayList<String>(); parserFichier(row,temps,autres); window(temps,autres); } catch (JDOMException e) { e.printStackTrace(System.out); } catch (IOException e) { e.printStackTrace(System.out); } } public static void addOnce(List<String> list, String text) { if ( !list.contains(text) ) list.add(text); } public static void collect(List<String> list, Element elmt, boolean addText) { if ( addText ) { addOnce(list, elmt.getName()+ " nom=" +elmt.getText()); } else{ addOnce(list, elmt.getName()); } } public static void parserFichier( List<Element> row,List<String> temps, List<String> autres) throws ClassNotFoundException{ for ( Element infoElenemt : row){ List column = infoElenemt.getChildren("UML.Model"); for (int j = 0; j < column.size(); j++) { Element infoElement1 = (Element) column.get(j); List column1 = infoElenemt.getChildren("UML:Namespace.ownedElement"); for (int h = 0; h<column1.size(); h++){ Element infoElement2 = (Element) column1.get(h); List column2 = infoElement2.getChildren("UML:Class"); if("instant".equals(infoElement2.getName())||("intervalle".equals(infoElement2.getName()))||("event".equals(infoElement2.getName()))){ collect( temps, infoElement2, column2.isEmpty() ); for (int F = 0; h<column2.size(); F++){ Element infoElement3=(Element) column2.get(F); collect(temps,infoElement3,column1.equals(null)); } } } } } }
Partager