IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Format d'échange (XML, JSON...) Java Discussion :

Découpage du fichier XML en 3 niveaux


Sujet :

Format d'échange (XML, JSON...) Java

  1. #1
    Membre à l'essai
    Inscrit en
    Juin 2012
    Messages
    16
    Détails du profil
    Informations forums :
    Inscription : Juin 2012
    Messages : 16
    Points : 17
    Points
    17
    Par défaut Découpage du fichier XML en 3 niveaux
    Bonjour,
    j'ai fait le découpage de mon fichier XML d'une interface (IHM basé sur l'XML) en 3 couches (application,dialogue,présentation) avec:

    Application qui décrit la sémantique: concerne le niveau fonctionnel (les méthodes)
    Dialogue qui décrit la syntaxe: concerne le niveau dialogue et communication entre le sémantic et le lexical (les évenement; exple:clique boutton, ...)
    Présentation qui décrit le niveau lexical: concerne le niveau présentation et affichage des objets de l interface (les bouton, textField,...)

    je dois ecrire un algorithme qui a comme entrée un fichier xml initial (neutre) et qui va à chaque niveau enrichir le fichier xml (enrichir par les info)
    Voila un exemple de XML que j'ai fait avec le fait avec Glade
    Code XML : 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
    <?xml version="1.0"?>
    <interface>
    <requires lib="gtk+" version="2.16"/>
    <!-- interface-naming-policy project-wide -->
    <object class="GtkWindow" id="window1">
    <property name="title" translatable="yes">Systeme de Commande de Pizza</property>
    <child>
    <object class="GtkVBox" id="vbox1">
    <property name="visible">True</property>
    <property name="orientation">vertical</property>
    <child>
    <object class="GtkVBox" id="vbox2">
    <property name="visible">True</property>
    <property name="orientation">vertical</property>
    <child>
    <object class="GtkVBox" id="vbox3">
    <property name="visible">True</property>
    <property name="orientation">vertical</property>
    <child>
    <object class="GtkRadioButton" id="radiobutton1">
    <property name="label" translatable="yes">Neptune</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">False</property>
    <property name="active">True</property>
    <property name="draw_indicator">True</property>
    <signal name="group_changed" handler="on_radiobutton1_group_changed"/>
    </object>
    <packing>
    <property name="position">0</property>
    </packing>
    </child>
    <child>
    <object class="GtkRadioButton" id="radiobutton2">
    <property name="label" translatable="yes">Viande hachee</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">False</property>
    <property name="draw_indicator">True</property>
    <signal name="group_changed" handler="on_radiobutton2_group_changed"/>
    </object>
    <packing>
    <property name="position">1</property>
    </packing>
    </child>
    <child>
    <object class="GtkRadioButton" id="radiobutton3">
    <property name="label" translatable="yes">Fruit de mer</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">False</property>
    <property name="draw_indicator">True</property>
    <signal name="group_changed" handler="on_radiobutton3_group_changed"/>
    </object>
    <packing>
    <property name="position">2</property>
    </packing>
    </child>
    </object>
    <packing>
    <property name="padding">11</property>
    <property name="position">0</property>
    </packing>
    </child>
    <child>
    <object class="GtkHButtonBox" id="hbuttonbox2">
    <property name="visible">True</property>
    <child>
    <object class="GtkButton" id="button1">
    <property name="label" translatable="yes">Ajouter Pizza</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">True</property>
    <signal name="clicked" handler="on_button1_clicked" object="Nouvelle pizza"/>
    </object>
    <packing>
    <property name="expand">False</property>
    <property name="fill">False</property>
    <property name="position">0</property>
    </packing>
    </child>
    </object>
    <packing>
    <property name="position">1</property>
    </packing>
    </child>
    </object>
    <packing>
    <property name="position">0</property>
    </packing>
    </child>
    </object>
    </child>
    </object>
    <object class="GtkAction" id="action1">
    <property name="label">ajout</property>
    <property name="stock_id">gtk-add</property>
    <property name="icon_name">ajout</property>
    <signal name="activate" handler="gtk_widget_show" object="Nouvelle pizza "/>
    </object>
    <object class="GtkRadioAction" id="radioaction1">
    <property name="draw_as_radio">True</property>
    </object>
    </interface>

    Est ce que vous pouvez m'aider à définir ma structure de donnée pour l algorithme
    normalment, on parle de racine, noeudFils , feuille, mais j'ai pas su comment insérer les informations

  2. #2
    Modérateur
    Avatar de kolodz
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2008
    Messages
    2 211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 211
    Points : 8 316
    Points
    8 316
    Billets dans le blog
    52
    Par défaut
    Est ce que vous pouvez m'aider à définir ma structure de donnée pour l algorithme
    Oui, on peut. Mais va falloir nous poser des questions ! (Sur ce que tu n'arrive pas à faire)

    Si tu n'as comprends pas les termes : racine, nœud fils ou feuille.
    Je te conseille de voir un cours puis un tutoriel sur les concepts utilisés par le langage XML.

    Logiquement, ton programme va lire ton fichier XML et en crée un nouveau avec un peu plus d'information.

    Sais-tu lire un fichier XML par un programme Java ?
    Quels sont les informations que tu dois ajouter ou modifier ?

    Cordialement,
    Patrick Kolodziejczyk.
    Si une réponse vous a été utile pensez à
    Si vous avez eu la réponse à votre question, marquez votre discussion
    Pensez aux FAQs et aux tutoriels et cours.

  3. #3
    Membre à l'essai
    Inscrit en
    Juin 2012
    Messages
    16
    Détails du profil
    Informations forums :
    Inscription : Juin 2012
    Messages : 16
    Points : 17
    Points
    17
    Par défaut
    oui je comprends ces termes
    mais le problème que je dois écrire un algorithme qui permet d'enrichir un fichier xml initial (n'importe quel fichier xml , j'ai choisi par exple ce genre de fichier) , de l'enrichier par les 3 couches (application,dialgue,présentation) du modèle Seeheim (comme le modèle MVC)
    je vs donne un exemple de fichier initial (avec le réseau de pétri)
    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
    - <pnml xmlns="http://www.informatik.hu-berlin.de/top/pnml/ptNetb">
    - <net>
    - <place>
    - <name>
      <text>ApplicationClosed</text> 
      </name>
    - <initialMarking>
      <text>0</text> 
      </initialMarking>
      </place>
    - <place>
    - <name>
      <text>SessionOpened</text> 
      </name>
    - <initialMarking>
      <text>0</text> 
      </initialMarking>
      </place>
    - <place>
    - <name>
      <text>GivePlentyWater</text> 
      </name>
    - <initialMarking>
      <text>1</text> 
      </initialMarking>
      </place>
    - <place>
    - <name>
      <text>WaterGiven</text> 
      </name>
    - <initialMarking>
      <text>0</text> 
      </initialMarking>
      </place>
    - <place>
    - <name>
      <text>UrineLevy</text> 
      </name>
    - <initialMarking>
      <text>0</text> 
      </initialMarking>
      </place>
    - <place>
    - <name>
      <text>UrineLevied</text> 
      </name>
    - <initialMarking>
      <text>0</text> 
      </initialMarking>
      </place>
    - <transition>
    - <name>
      <text>OpenSession</text> 
      </name>
      </transition>
    - <transition>
    - <name>
      <text>CriticalIntervention</text> 
      </name>
      </transition>
    - <transition>
    - <name>
      <text>GivingWater</text> 
      </name>
      </transition>
    - <transition>
    - <name>
      <text>PrepareUrineLevy</text> 
      </name>
      </transition>
    - <transition>
    - <name>
      <text>LevyingUrine</text> 
      </name>
      </transition>
    - <transition>
    - <name>
      <text>TaskFinished</text> 
      </name>
      </transition>
      <arc id="ApplicationClosedToOpenSession" source="ApplicationClosed" target="OpenSession" /> 
      <arc id="OpenSessionToSessionOpened" source="OpenSession" target="SessionOpened" /> 
      <arc id="SessionOpenedToCriticalIntervention" source="SessionOpened" target="CriticalIntervention" /> 
      <arc id="CriticalInterventionToGivePlentyWater" source="CriticalIntervention" target="GivePlentyWater" /> 
      <arc id="GivePlentyWaterToGivingWater" source="GivePlentyWater" target="GivingWater" /> 
      <arc id="GivingWaterToWaterGiven" source="GivingWater" target="WaterGiven" /> 
      <arc id="WaterGivenToPrepareUrineLevy" source="WaterGiven" target="PrepareUrineLevy" /> 
      <arc id="PrepareUrineLevyToUrineLevy" source="PrepareUrineLevy" target="UrineLevy" /> 
      <arc id="UrineLevyToLevyingUrine" source="UrineLevy" target="LevyingUrine" /> 
      <arc id="LevyingUrineToUrineLevied" source="LevyingUrine" target="UrineLevied" /> 
      <arc id="UrineLeviedToTaskFinished" source="UrineLevied" target="TaskFinished" /> 
      <arc id="TaskFinishedToApplicationClosed" source="TaskFinished" target="ApplicationClosed" /> 
      </net>
      </pnml>
    Le fichier cible (final) doit décrire une interface graphique avec les informations du fichier initial : càd le fichier final contient les 3 couches suivantes:
    application qui décrit la sémantique: concerne le niveau fonctionnel (les méthodes)
    dialogue qui décrit la syntaxe: concerne le niveau dialogue et communication entre le sémantic et le lexical (les évenement; exple:clique boutton, ...)
    présentation qui décrit le niveau lexical: concerne le niveau présentation et affichage des objets de l interface (les bouton, textField,...)

    1) tout d'abord,si vous pouvez m'aider pour savoir (à peut prés) comment va etre la structure de mon fichier xml final, pour que je puisse comprendre mieux

    2)Comment insérer chaque partie (la partie application,dialgue,présentation) ds le fichier (le but est d'enrichier le fichier XML initial)


    pour la lecture du fichier , j'ai trouvé qu'il faut travailler avec le JDom
    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
     
    import java.io.*;
    import java.util.List;
    import org.jdom2.Document;
    import org.jdom2.Element;
    import org.jdom2.input.SAXBuilder;
     
    public class JDom{
       static Document document;
       static Element racine;
     
       public static void main(String[] args){
          //On crée une instance de SAXBuilder
          SAXBuilder sxb = new SAXBuilder();
          try{
             //On crée un nouveau document JDOM avec en argument le fichier XML
             //Le parsing est terminé ;)
             document = sxb.build(new File("Nurse.xml"));
          }catch(Exception e){}
     
          //On initialise un nouvel élément racine avec l'élément racine du document.
          racine = document.getRootElement();     
       }
    pour la récupération des données du xml initial :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    List<Element> elements = document.getRootElement().getChildren("elements");
    Merci pour votre aide

Discussions similaires

  1. Découpage fichier XML
    Par Foyus dans le forum Shell et commandes GNU
    Réponses: 16
    Dernier message: 06/01/2015, 17h43
  2. Réponses: 5
    Dernier message: 04/07/2011, 20h55
  3. [SAX] Découpage fichier xml
    Par akhen3100 dans le forum Format d'échange (XML, JSON...)
    Réponses: 0
    Dernier message: 06/03/2009, 09h59
  4. [JDOM] Nombre de niveaux d'un fichier XML
    Par mina86 dans le forum Format d'échange (XML, JSON...)
    Réponses: 3
    Dernier message: 12/06/2008, 13h01
  5. [JDOM] Fichier XML à plusieurs niveaux
    Par sidneyvba dans le forum Format d'échange (XML, JSON...)
    Réponses: 1
    Dernier message: 06/11/2007, 15h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo