Parseur xmi [Résolu]

bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - 25 févr. 2014 à 12:09 - Dernière réponse : Ahlemrhayem 7 Messages postés mardi 22 juillet 2014Date d'inscription 10 août 2014 Dernière intervention
- 1 août 2014 à 18:52
Bonjour, svp j'ai un fichier xmi et je veux paser en java ? mais je ne sais pas comment?
Afficher la suite 

11 réponses

Répondre au sujet
cs_Julien39 6449 Messages postés mardi 8 mars 2005Date d'inscriptionModérateurStatut 15 mars 2018 Dernière intervention - 25 févr. 2014 à 15:02
+1
Utile
Salut,

Le XMI est un cas particulier de fichier XML, pour le parser, tu peux donc utiliser le parseur XML JDOM, voici un tutoriel http://codes-sources.commentcamarche.net/faq/10787-gestion-des-fichiers-xml-avec-jdom
Cette réponse vous a-t-elle aidé ?  
Commenter la réponse de cs_Julien39
bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - Modifié par jordane45 le 26/02/2014 à 11:29
0
Utile
1
Mon problème est que mon fichier XMI est exporté à partir d'un diagramme de classe avec argoUml donc ce n'est un fichier xmi simple voici un exemple de fichier xmi que je veux parser:

<?xml version = '1.0' encoding = 'UTF-8' ?>
<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Wed Feb 19 14:03:41 GMT+01:00 2014'>
  <XMI.header>    <XMI.documentation>
      <XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
      <XMI.exporterVersion>0.34(6) revised on $Date: 2010-01-11 22:20:14 +0100 (Mon, 11 Jan 2010) $ </XMI.exporterVersion>
    </XMI.documentation>
    <XMI.metamodel xmi.name="UML" xmi.version="1.4"/></XMI.header>
  <XMI.content>
    <UML:Model xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000865'
      name = 'untitledModel' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
      isAbstract = 'false'>
      <UML:Namespace.ownedElement>
        <UML:Class xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000866'
          name = 'PlayMediaScreen' visibility = 'public' isSpecification = 'false'
          isRoot = 'false' isLeaf = 'false' isAbstract = 'false' isActive = 'false'>
          <UML:Classifier.feature>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000867'
              name = 'back' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000868'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000869'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086A'
              name = 'start' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086B'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086C'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086D'
              name = 'stop' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086E'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000086F'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000870'
              name = 'PlayMediaScreen' visibility = 'public' isSpecification = 'false'
              ownerScope = 'instance' isQuery = 'false' concurrency = 'sequential' isRoot = 'false'
              isLeaf = 'false' isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000871'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000872'
              name = 'pauseplay' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000873'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000874'
              name = 'startplay' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000875'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000876'
              name = 'selectypeofmedia' visibility = 'public' isSpecification = 'false'
              ownerScope = 'instance' isQuery = 'false' concurrency = 'sequential' isRoot = 'false'
              isLeaf = 'false' isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000877'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
          </UML:Classifier.feature>
        </UML:Class>
        <UML:Class xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'
          name = 'AddMediaToAlbum' visibility = 'public' isSpecification = 'false'
          isRoot = 'false' isLeaf = 'false' isAbstract = 'false' isActive = 'false'>
          <UML:Classifier.feature>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000879'
              name = 'cancel' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087A'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087B'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087C'
              name = 'ok' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087D'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087E'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000087F'
              name = 'addmediaToAlbum' visibility = 'public' isSpecification = 'false'
              ownerScope = 'instance' isQuery = 'false' concurrency = 'sequential' isRoot = 'false'
              isLeaf = 'false' isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000880'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000881'
              name = 'getItemName' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000882'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000883'
              name = 'GetPath' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000884'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
          </UML:Classifier.feature>
        </UML:Class>
        <UML:Association xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000885'
          name = '' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' isAbstract = 'false'>
          <UML:Association.connection>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000886'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'aggregate' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000887'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'none' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000866'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
          </UML:Association.connection>
        </UML:Association>
        <UML:Association xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000888'
          name = '' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' isAbstract = 'false'>
          <UML:Association.connection>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000889'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'composite' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088A'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'none' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000866'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
          </UML:Association.connection>
        </UML:Association>
        <UML:Association xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088B'
          name = '' isSpecification = 'false' isRoot = 'false' isLeaf = 'false' isAbstract = 'false'>
          <UML:Association.connection>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088C'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'composite' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000866'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
            <UML:AssociationEnd xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088D'
              visibility = 'public' isSpecification = 'false' isNavigable = 'true' ordering = 'unordered'
              aggregation = 'none' targetScope = 'instance' changeability = 'changeable'>
              <UML:AssociationEnd.participant>
                <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'/>
              </UML:AssociationEnd.participant>
            </UML:AssociationEnd>
          </UML:Association.connection>
        </UML:Association>
        <UML:Class xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088E'
          name = 'PlayAudioScreen' visibility = 'public' isSpecification = 'false'
          isRoot = 'false' isLeaf = 'false' isAbstract = 'false' isActive = 'false'>
          <UML:GeneralizableElement.generalization>
            <UML:Generalization xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089E'/>
          </UML:GeneralizableElement.generalization>
          <UML:Classifier.feature>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088F'
              name = 'copy' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000890'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000891'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000892'
              name = 'startaudio' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000893'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000894'
              name = 'stopaudio' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000895'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
          </UML:Classifier.feature>
        </UML:Class>
        <UML:Class xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000896'
          name = 'PlayimageScreen' visibility = 'public' isSpecification = 'false'
          isRoot = 'false' isLeaf = 'false' isAbstract = 'false' isActive = 'false'>
          <UML:GeneralizableElement.generalization>
            <UML:Generalization xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089F'/>
          </UML:GeneralizableElement.generalization>
          <UML:Classifier.feature>
            <UML:Attribute xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000897'
              name = 'copy' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              changeability = 'changeable' targetScope = 'instance'>
              <UML:StructuralFeature.multiplicity>
                <UML:Multiplicity xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000898'>
                  <UML:Multiplicity.range>
                    <UML:MultiplicityRange xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000899'
                      lower = '1' upper = '1'/>
                  </UML:Multiplicity.range>
                </UML:Multiplicity>
              </UML:StructuralFeature.multiplicity>
            </UML:Attribute>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089A'
              name = 'startimage' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089B'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
            <UML:Operation xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089C'
              name = 'stopimage' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
              isQuery = 'false' concurrency = 'sequential' isRoot = 'false' isLeaf = 'false'
              isAbstract = 'false'>
              <UML:BehavioralFeature.parameter>
                <UML:Parameter xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089D'
                  name = 'return' isSpecification = 'false' kind = 'return'/>
              </UML:BehavioralFeature.parameter>
            </UML:Operation>
          </UML:Classifier.feature>
        </UML:Class>
        <UML:Generalization xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089E'
          isSpecification = 'false'>
          <UML:Generalization.child>
            <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000088E'/>
          </UML:Generalization.child>
          <UML:Generalization.parent>
            <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'/>
          </UML:Generalization.parent>
        </UML:Generalization>
        <UML:Generalization xmi.id = '-64--88-1-6--51e9520c:14426715470:-8000:000000000000089F'
          isSpecification = 'false'>
          <UML:Generalization.child>
            <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000896'/>
          </UML:Generalization.child>
          <UML:Generalization.parent>
            <UML:Class xmi.idref = '-64--88-1-6--51e9520c:14426715470:-8000:0000000000000878'/>
          </UML:Generalization.parent>
        </UML:Generalization>
      </UML:Namespace.ownedElement>
    </UML:Model>
  </XMI.content>
</XMI>
jordane45 20606 Messages postés mercredi 22 octobre 2003Date d'inscriptionModérateurStatut 24 avril 2018 Dernière intervention - 26 févr. 2014 à 11:29
Ajout des balises de code.

http://codes-sources.commentcamarche.net/faq/10686-le-nouveau-codes-sources-comment-ca-marche#balises-code

Merci d'y penser lors de tes prochains messages !
Commenter la réponse de bestlove00
cs_Julien39 6449 Messages postés mardi 8 mars 2005Date d'inscriptionModérateurStatut 15 mars 2018 Dernière intervention - Modifié par cs_Julien39 le 26/02/2014 à 13:53
0
Utile
Tu utilises JDom qui peut parser tous les fichiers XML même le tiens.
Tu as lu le tutoriel ?

Je ne le ferai pas pour toi...
Commenter la réponse de cs_Julien39
bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - 26 févr. 2014 à 14:13
0
Utile
oui j'ai déjà lu et j'ai essayée avec ce tutoriel mais mon fichier xmi est plus compliqué que celui et je n'arrive pas à une solution .l'affichage dans le console est toujours vide .Mon problème est comment je peux accéder aux éléments qui se trouve sous la balise <XMI.content> comme par exemple <UML:Model> pour afficher les noms des classes,attributs,opération et les associations?
Commenter la réponse de bestlove00
jordane45 20606 Messages postés mercredi 22 octobre 2003Date d'inscriptionModérateurStatut 24 avril 2018 Dernière intervention - 26 févr. 2014 à 14:18
0
Utile
Bonjour,

Déjà... si tu as essayé.. tu as donc du code.

Il serait alors bien de nous le montrer pour que l'on puisse se rendre compte si tu as fais des erreurs ou non ..

Et puis... en regardant rapidement sur le net on tombe sur ce genre de discussions... qui ressemble à ce que tu souhaites faire non ?
http://www.developpez.net/forums/d1282123/java/general-java/xml/parser-fichier-xmi/

Commenter la réponse de jordane45
bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - 26 févr. 2014 à 14:26
0
Utile
voilà mon code,

 



 
import java.io.*;

import org.jdom2.*;
import org.jdom2.input.*;
import org.jdom2.util.IteratorIterable;
import org.jdom2.filter.*;
import java.util.List;
import java.util.Iterator;
 
public class ParseXMI {
 
	static org.jdom2.Document document;
	static Element root;
	
		public static void main(String[] args) {
		System.out.println("Affichage de la liste:");
		SAXBuilder sxb = new SAXBuilder();
		File xmiFile = new File("product1.xmi");
		Document document;
		try {
			 document = sxb.build(xmiFile);
			 Element root = document.getRootElement();
			 System.out.println("RootNode" + root);
		
	   Namespace ns = Namespace.getNamespace("UML", "org.omg.xmi.namespace.UML");
	   System.out.println("NameSpace" + ns);
	  List row0 = root.getChildren("XMI.header");
	 
	   List row = root.getChildren("XMI.content");
	   System.out.println("le contenu est " +row);
		for (int i = 0; i < row.size(); i++) {
			  Element infoElenemt = (Element) row.get(i);
		        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");
		        	  int name = ((Element) column2).getChildText("name").length();
		        	  System.out.println("Class name = " + name);
		          }
		          
		        }
	      }
	   
	IteratorIterable<Element>xmiClass =  root.getDescendants(Filters.element("Class", ns));
	  
	    } catch (Exception e) {
	      System.out.println("Execption " + e.getMessage());
	    }
		  }}



l'affichage de cette classe est
Affichage de la liste:
RootNode[Element: <XMI/>]
NameSpace[Namespace: prefix "UML" is mapped to URI "org.omg.xmi.namespace.UML"]
le contenu est [[Element: <XMI.content/>]]
Commenter la réponse de bestlove00
bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - 27 févr. 2014 à 21:51
0
Utile
bonsoir j'ai besoin de vos aide svp j'ai essayé mais je trouve pas une solution pour mon probléme
Commenter la réponse de bestlove00
bestlove00 17 Messages postés mercredi 19 février 2014Date d'inscription 2 mars 2014 Dernière intervention - 2 mars 2014 à 20:19
0
Utile
1
bonsoir,sayé j'ai connais comment parser mon fichier xmi .
mon problème maintenant est que je veux afficher les données extraites à partir de ce fichier comme les noms des classes , les attributs, les méthodes et les relations d'un diagramme de classe dans un tableau avec swing ??? aidez moi svp et merci
Ahlemrhayem 7 Messages postés mardi 22 juillet 2014Date d'inscription 10 août 2014 Dernière intervention - 1 août 2014 à 18:52
Bonjour;
vous dites que vous avez trouvé la solution pour votre problème. pouvez vous me dire comment parser une fichier XMI en Java avec JDOM?
et aussi comment je peut extraire des connaissances a partir de cette fichier?
Merci bien :)
Commenter la réponse de bestlove00
cs_Julien39 6449 Messages postés mardi 8 mars 2005Date d'inscriptionModérateurStatut 15 mars 2018 Dernière intervention - 3 mars 2014 à 07:53
0
Utile
Salut,

Je t'ai déjà répondu sur ce point il y a quelques temps, je t'ai pas mal aidé il me semble !!!

* http://codes-sources.commentcamarche.net/forum/affich-10020635-diagramme-de-classes-dans-une-interface-swing
* http://codes-sources.commentcamarche.net/forum/affich-10020726-dessin-d-une-classe-dans-un-jpanel

Que veux tu de plus ? Qu'on le fasse à ta place ??
Commenter la réponse de cs_Julien39

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.