J´ai plusieurs fichiers XML structurés de cette maniere:
Premier fichier d´exemple:
Second fichier d´exemple:
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 <?xml version="1.0" encoding="UTF-8"?> <Bar xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="1" keys="/Bar/nom;/Bar/Adresse/ligneUn"> <meta><id>Bar-20090326_131129_744</id> <category>Bar</category> <author>dcuser</author> <last_modified>20090326_131129_748</last_modified> <summary>Blue Lagoon Bar ; Fairmont Heliopolis, Urban St.</summary> </meta> <nom key="1">Blue Lagoon Bar</nom> <Adresse class="1"> <nomUniteUrbaine>Heliopolis</nomUniteUrbaine> <ligneUn key="1">Fairmont Heliopolis, Urban St.</ligneUn> <ligneDeux/> <etatOuProvince/> <pays>Egypte</pays> <codePostal/> <nomDestinationEnglobante/> </Adresse> <HeuresOuvertureParJour class="1" cnt="1"> <jourDeLaSemaine>tous</jourDeLaSemaine> <heureOuverture>9</heureOuverture> <heureFermeture>19</heureFermeture> <debutPauseMidi/> <finPauseMidi/> </HeuresOuvertureParJour> <nombrePlaces/> <Contact class="1"> <personneContact/> <telephone-1>226 77730</telephone-1> <telephone-2>226 77740</telephone-2> <fax/> <courriel-1/> <courriel-2/> <URL/> </Contact> <ServiceBoissons class="1" cnt="1"> <boissonsServies/> <boissonsAlcoolisees>Non</boissonsAlcoolisees> <boissonsNonAlcoolisees>Non</boissonsNonAlcoolisees> <TarifDeBase class="1"> <montant/> <monnaie/> <modeTarification/> <typeTarification/> <descriptionTextuelle>ok 1</descriptionTextuelle> </TarifDeBase> <FourchetteTarifaire class="1"> <tarifMaxmal/> <tarifMinimal/> <monnaie/> <modeTarification/> <typeTarification/> <descriptionTextuelle>ok FT1</descriptionTextuelle> </FourchetteTarifaire> <descriptionTextuelle>ok hs1</descriptionTextuelle> </ServiceBoissons> <descriptionTextuelle>The restaurant offers Oriental cuisine including Mix Grill platters not to mention their range of alcoholic beverages.</descriptionTextuelle> <langues>arabe</langues> <moyensPaiementAcceptes>argentComptant</moyensPaiementAcceptes> <climatisation>yes</climatisation> <reservationRequise>yes</reservationRequise> <Images class="1"> <imageFile1 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description1/> <imageFile2 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description2/> <imageFile3 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description3/> </Images> </Bar>
Et je dois utiliser un seul fichier XSL pour les mettre en forme (parce que j´en ai 60 des fichiers comme ça).
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 <?xml version="1.0" encoding="UTF-8"?> <ActiviteSportive xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="1" keys="/ActiviteSportive/nom;/ActiviteSportive/aSitePrincipalText"> <meta><id>ActiviteSportive-20090323_163811_513</id> <category>ActiviteSportive</category> <author>dcuser</author> <last_modified>20090324_170740_955</last_modified> <summary>Equitation ; rwettwet</summary> </meta> <nom key="1">Equitation</nom> <typeSport>ski</typeSport> <TarifDeBase class="1"> <montant/> <monnaie/> <modeTarification/> <typeTarification/> <descriptionTextuelle/> </TarifDeBase> <besoinDePermis>no</besoinDePermis> <Contact class="1"> <personneContact>retrt</personneContact> <telephone-1/> <telephone-2/> <telephone-3/> <telephone-4/> <fax-1/> <fax-2/> <courriel-1/> <courriel-2/> <courriel-3/> </Contact> <aSitePrincipal>SitePublic-20090318_200805_591.xml</aSitePrincipal> <aSitesSecondaires-1/> <aSitesSecondaires-2/> <aSitesSecondaires-3/> <aSitePrincipalText key="1">rwettwet</aSitePrincipalText> <descriptionTextuelle/> <Images class="1"> <imageFile1 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description1/> <imageFile2 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description2/> <imageFile3 xsi:type="xsd:anyURI" mediatype="" oldPath="" newPath="" imageUrl="" imageThumbUrl=""/> <description3/> </Images> </ActiviteSportive>
Jusque ici j´utilisais des balises dans mon XSL tel que //nom //type pour accéder à chacun des éléments car chaque fichier commence par une balise différente (en l´occurrence Bar et ActiviteSportive).
Le problème c´est que dans le cas d´une balise tel que <descriptionTextuelle> elle peut se retrouver plusieurs fois dans le fichier. Par exemple dans <TarifDeBase> ou <FourchetteTarifaire>. Du coup lorsque je prends une descriptionTextuelle pour la mettre en forme alors qu´elle est en dehors de tout avec //descriptionTextuelle , le XSL me prend la première qu´il trouve (forcément).
Est-ce que je peux me passer des // pour récupérer mes informations dans ce cas la? Si oui, comment?
Est-ce que je peux faire une grande structure conditionnelle (if) pour prendre en compte : Si Bar ou ActiviteSportive alors va chercher l´info la bas?
Voila tout,
Merci d´avance
MadMarc52
Partager