Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2986 connectés 

  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSD et XML pour fichiet TXT

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

XSD et XML pour fichiet TXT

n°1809335
Nat33
Posté le 07-11-2008 à 12:18:33  profilanswer
 

Bonjour,
 
J'aurais besoin d'aide pour créer le schema XML (ainsi que l'XSD associé) correspondant à un fichier txt plat (avec séparateur ;) un peu compliqué.  Dans le fichier, chaque enregistrement se découpe en 3 parties :
- 1 ligne entête dont le premier champ à la valeur 101
- Un nombre de lignes variable dont la valeur du premier champ est 201
- 1 ligne total dont le premier champ à la valeur 301
 
Voici à quoi il ressemble :
 
101;115207;800756839;F;01102008;05102008;
201;115207;481463;108AVG51;;;VP;524;LLOY;Loyer financier;488,98;95,84;584,82;EUR;19,60;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LMAIASS;Maintenance & Assistance;103,26;20,24;123,50;EUR;19,60;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LPNE;Pneumatiques;62,08;12,17;74,25;EUR;19,60;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LVER;Véhicule de remplacement;6,44;1,26;7,70;EUR;19,60;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LCAR;Gestion carburant;1,52;0,30;1,82;EUR;19,60;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LARSK;Assurance Autorisk;28,30;0,00;28,30;EUR;0,00;01102008;31102008;
201;115207;481463;108AVG51;;;VP;524;LSRSK;Service Autorisk;35,81;7,02;42,83;EUR;19,60;01102008;31102008;
301;115207;800756839;F;01102008;726,39;136,83;863,22;EUR;
101;334229;800757637;F;01102008;01112008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LLOY;Loyer financier;438,59;85,96;524,55;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LMAIASS;Maintenance & Assistance;67,41;13,21;80,62;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LPNE;Pneumatiques;48,10;9,43;57,53;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LVER;Véhicule de remplacement;13,03;2,55;15,58;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LCAR;Gestion carburant;0,83;0,16;0,99;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LARSK;Assurance Autorisk;28,30;0,00;28,30;EUR;0,00;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LSRSK;Service Autorisk;35,81;7,02;42,83;EUR;19,60;01102008;31102008;
201;334229;517270;401AXK51;ANNE SOPHIE SOLANET;;VP;149;LGES;Frais de gestion;6,10;1,20;7,30;EUR;19,60;01102008;31102008;
301;334229;800757637;F;01102008;638,17;119,53;757,70;EUR;
 
 
Merci de votre aide.

mood
Publicité
Posté le 07-11-2008 à 12:18:33  profilanswer
 

n°1814463
Nat33
Posté le 20-11-2008 à 14:57:19  profilanswer
 

Bonjour, pour ceux que ca interresserait, je suis parvenu à écrire les fichiers xml et xsd correspondant à ma demande :
 
Le fichier xml
<?xml version="1.0"?>
<file name="factures" separated="true" separator=";" maxrows="10000" commentchar="N" quotechar="&quot;" encoding="ISO-8859-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///D:/Xsd/ALDDesc.xsd">
     
    <row rowlength="-1" maxrows="-1" name="entete">
        <column name="nbrEntete" match="101" isnumeric="true"/>
        <column name="numclientEnt" match="" isnumeric="true"/>
        <column name="numDocumentEnt" match="" isnumeric="false"/>
        <column name="typeDocEnt" match="" isnumeric="false"/>
        <column name="dateFactureEnt" match="" isnumeric="true"/>
        <column name="echeanceFactureEnt" match="" isnumeric="true"/>
        <column name="resteABlancEnt" match="" isnumeric="false"/>
    </row>  
    <row rowlength="-1" maxrows="-1" name="ligne">
        <column name="nbrDetail" match="201" isnumeric="true"/>
        <column name="numClient" match="" isnumeric="true"/>
        <column name="numAvenant" match="" isnumeric="false"/>
        <column name="numimmatric" match="" isnumeric="false"/>
        <column name="nomConduct" match="" isnumeric="false"/>
        <column name="structure" match="" isnumeric="false"/>
        <column name="codeGenre" match="" isnumeric="false"/>
        <column name="refExtClient" match="" isnumeric="false"/>
        <column name="codeProduit" match="" isnumeric="false"/>
        <column name="libelleProduit" match="" isnumeric="false"/>
        <column name="montantHT" match="" isnumeric="false"/>
        <column name="montantTVA" match="" isnumeric="false"/>
        <column name="montantTTC" match="" isnumeric="false"/>
        <column name="codeDevise" match="" isnumeric="false"/>
        <column name="tauxTVA" match="" isnumeric="false"/>
        <column name="dateDebPresta" match="" isnumeric="true"/>
        <column name="dateFinPresta" match="" isnumeric="true"/>
        <column name="resteABlanc" match="" isnumeric="false"/>
    </row>
    <row rowlength="-1" maxrows="-1" name="pied">
        <column name="nbrPied" match="301" isnumeric="true"/>
        <column name="numclientPied" match="" isnumeric="true"/>
        <column name="numDocumentPied" match="" isnumeric="false"/>
        <column name="typeDocPied" match="" isnumeric="false"/>
        <column name="dateFacturePied" match="" isnumeric="true"/>
        <column name="montantHTPied" match="" isnumeric="false"/>
        <column name="montantTVAPied" match="" isnumeric="false"/>
        <column name="montantTTCPied" match="" isnumeric="false"/>
        <column name="codeDevisePied" match="" isnumeric="false"/>
        <column name="resteABlancPied" match="" isnumeric="false"/>
    </row>
</file>  
 
Et l'xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
 
 <xsd:element name="column">
  <xsd:complexType>
   <xsd:attribute name="name" type="xsd:string" use="required"/>
   <xsd:attribute name="match" type="xsd:string" use="optional"/>
   <xsd:attribute name="length" type="xsd:int" use="optional"/>
   <xsd:attribute name="isnumeric" type="xsd:boolean" use="optional"/>
   <xsd:attribute name="ignore" type="xsd:boolean" use="optional"/>
  </xsd:complexType>
 </xsd:element>
 
 
 <xsd:element name="row">
  <xsd:complexType>
   <xsd:choice maxOccurs="unbounded" minOccurs="1">
    <xsd:element ref="column"/>
    <xsd:element ref="row"/>
   </xsd:choice>
 
   <xsd:attribute name="rowlength" type="xsd:long" use="optional"/>
   <xsd:attribute name="maxrows" type="xsd:long" use="optional"/>
   <xsd:attribute name="name" type="xsd:string" use="required"/>
   <xsd:attribute name="ignore" type="xsd:boolean" use="optional"/>
  </xsd:complexType>
 </xsd:element>
 
 
 <xsd:element name="file">
  <xsd:complexType>
   <xsd:choice minOccurs="1" maxOccurs="unbounded">
    <xsd:element ref="row"/>
   </xsd:choice>
   <xsd:attribute name="name" type="xsd:string" use="required"/>
   <xsd:attribute name="separated" type="xsd:boolean" use="required"/>
   <xsd:attribute name="separator" type="xsd:string" use="optional"/>
   <xsd:attribute name="maxrows" type="xsd:long" use="optional"/>
   <xsd:attribute name="commentchar" type="xsd:string" use="optional"/>
   <xsd:attribute name="quotechar" type="xsd:string" use="optional"/>
   <xsd:attribute name="encoding" type="xsd:string" use="optional"/>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSD et XML pour fichiet TXT

 

Sujets relatifs
Charger un fichier XML en PHPdocuments XML
Parser une seule donnée d'un XMl[RESOLVED]Passer un argument en XML
programmation ds Alice avec le language Xml ou SML niveau debutantIHM générée depuis un XSD pour éditer un fichier XML
mon lien HTML dans du XML n'est pas interprété [résolu]PHP et XML + xpath : demande de précisions
gsoap2 utilisable avec un simple fichier XML 
Plus de sujets relatifs à : XSD et XML pour fichiet TXT


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)