Bonsoir à tous
j'essaye d'afficher les element de mon fichier xml dans une page html en les mettant dans un tableau.
voici mon fichier xsd
le resultat aprés execution de la transformation avec la methode suivante:
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 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Base de Donnees</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="Table"> <Table style="border-collapse: collapse; border: 1pt solid white" cellspacing="1" bgcolor="000000"> <th bgcolor="green" colspan="4" width="500"> <xsl:value-of select="@NomTable"/> </th> <td bgcolor="green" width="250"> <xsl:apply-templates select="Colonne"/> </td> </Table> </xsl:template> <xsl:template match="Colonne"> <tr> <td bgcolor="cyan" width="200"> <xsl:value-of select="@nom"/> </td> <td bgcolor="blue" width="250"> <xsl:apply-templates select="DataType"/> </td> </tr> </xsl:template> <xsl:template match="DataType"> <xsl:value-of select="@type"/> <xsl:value-of select="@taille"/> <xsl:apply-templates select="Contrainte"/> </xsl:template> <xsl:template match="Concactrainte"> <td bgcolor="cyan" width="200"> <xsl:value-of select="@type"/> </td> <td bgcolor="cyan" width="200"> <xsl:value-of select="@nom"/> </td> <xsl:apply-templates /> </xsl:template> </xsl:stylesheet>
le resultat out.html ne contient que mes element (table,colonne et datatype)mais pas (contrainte) et je ne comprend pas pk.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15public static void XSLT(String file) throws IOException, TransformerException { File stylesheet = new File("....BD.xslt"); File srcFile = new File(file); File destFile = new File("...output.html"); //java.io.Writer destFile = new OutputStreamWriter(System.out, "ISO-8859-1"); TransformerFactory factory = TransformerFactory.newInstance(); Source xslt = new StreamSource(stylesheet); Transformer transformer = factory.newTransformer(xslt); Source request = new StreamSource(srcFile); Result response = new StreamResult(destFile); transformer.transform(request, response); }
et voici le dtd si ça peut aider qlqn
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 <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Base de Donnees</title> </head> <body> <Table style="border-collapse: collapse; border: 1pt solid white" cellspacing="1" bgcolor="000000"> <th bgcolor="green" colspan="4" width="500">Table1</th> <td bgcolor="green" width="250"> <tr> <td bgcolor="cyan" width="200">Colonne11</td> <td bgcolor="blue" width="250">chaineFixe20</td> </tr> <tr> <td bgcolor="cyan" width="200">Colonne12</td> <td bgcolor="blue" width="250">chaineVariable30</td> </tr> </td> </Table> <Table style="border-collapse: collapse; border: 1pt solid white" cellspacing="1" bgcolor="000000"> <th bgcolor="green" colspan="4" width="500">Table2</th> <td bgcolor="green" width="250"> <tr> <td bgcolor="cyan" width="200">Colonne21</td> <td bgcolor="blue" width="250">chaineFixe20</td> </tr> <tr> <td bgcolor="cyan" width="200">Colonne22</td> <td bgcolor="blue" width="250">chaineVariable30</td> </tr> </td> </Table> <Table style="border-collapse: collapse; border: 1pt solid white" cellspacing="1" bgcolor="000000"> <th bgcolor="green" colspan="4" width="500">Table3</th> <td bgcolor="green" width="250"> <tr> <td bgcolor="cyan" width="200">Colonne31</td> <td bgcolor="blue" width="250">chaineFixe20</td> </tr> <tr> <td bgcolor="cyan" width="200">Colonne32</td> <td bgcolor="blue" width="250">chaineVariable30</td> </tr> </td> </Table> </body> </html>
et la structure de mon fichier xml ressemble a ceci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT DataType (#PCDATA)> <!ELEMENT Contrainte (#PCDATA)> <!ELEMENT Colonne (DataType,Contrainte*)> <!ELEMENT Table (Colonne*)> <!ATTLIST Table NomTable CDATA #REQUIRED > <!ELEMENT BaseDonnee (Table+)> <!ATTLIST Contrainte type (non_nul|unique|auto_increment) #REQUIRED > <!ATTLIST Contrainte nom CDATA #REQUIRED > <!ATTLIST Colonne nom CDATA #REQUIRED > <!ATTLIST DataType type CDATA #REQUIRED taille CDATA #IMPLIED>
pourriez vous m'aider svp??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <Table NomTable = "Table1"> <Colonne nom = "Colonne11"> <DataType type = "chaineFixe" taille= "20"/> <Contrainte type="non_nul" nom="contrainte_non_nul"/> </Colonne> <Colonne nom = "Colonne12"> <DataType type = "chaineVariable" taille= "30"/> <Contrainte type="non_nul" nom="contrainte_non_nul"/> </Colonne> </Table>






Répondre avec citation
Partager