Bonjour,
Je suis depuis quelque jour sur XSLT et je rame!
Voici mon problème :
je voudrais arriver à sa :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <?xml version="1.0" encoding="UTF-8"?> <CH> <SE_T>Titre <i>01</i></SE_T> <P>Para 01.1 <I>1</I></P> <P>Para 01.2 <I>2</I></P> <P>Para 01.3 <I>3</I></P> <SE_T>Titre <i>02</i></SE_T> <P>Para 02.1 <I>1</I></P> <CI>Cit <it>01</it></CI> <CI>Cit <it>01</it></CI> <P>Para 02.2 <I>1</I></P> </CH>
le mieux (entre autre), que j'ai réussi à avoir c'est plus ou mois ç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 <?xml version="1.0" encoding="UTF-8"?> <CH> <SE> <T>Titre <i>01</i></T> <P>Para 01.1 <I>1</I></P> <P>Para 01.2 <I>2</I></P> <P>Para 01.3 <I>3</I></P> </SE> <SE> <T>Titre <i>02</i></T> <P>Para 02.1 <I>1</I></P> <CI> <P>Cit <it>01</it></P> <P>Cit <it>01</it></P> </CI> <P>Para 02.2 <I>1</I></P> </SE> </CH>
Voici un des codes XSLT :
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 <?xml version="1.0" encoding="UTF-8"?> <SE><T>Titre <i>01</i></T> <P>Para 01.1 1</P> <P>Para 01.2 2</P> <P>Para 01.3 3</P> <P>Titre 02</P> <P>Para 02.1 1</P> <P>Cit 01</P> <P>Cit 01</P> <P>Para 02.2 1</P> </SE> <SE><T>Titre <i>02</i></T> <P>Para 01.1 1</P> <P>Para 01.2 2</P> <P>Para 01.3 3</P> <P>Titre 02</P> <P>Para 02.1 1</P> <P>Cit 01</P> <P>Cit 01</P> <P>Para 02.2 1</P> </SE> Cit 01 Cit 01
Merci si quelqu'un pouvais me donner une piste !!!!
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 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="SE_T"> <SE> <T> <xsl:for-each select="*[name()!='SE_T']|text()"> <xsl:copy-of select="." /> </xsl:for-each> </T> <xsl:for-each select="//SE_T/following-sibling::*"> <xsl:choose> <xsl:when test="*[name()='P']"> <P> <xsl:for-each select="*[name()!='P']|text()"> <xsl:copy-of select="." /> </xsl:for-each> </P> <xsl:for-each select="//following-sibling::*[name()!='P']|text()"> <xsl:copy-of select="."/> </xsl:for-each> </xsl:when> <xsl:when test="//following-sibling::*[name()='P']"> <P> <xsl:for-each select="*[name()!='P']|text()"> <xsl:value-of select="." /> </xsl:for-each> </P> </xsl:when> <xsl:when test="//following-sibling::*[name()='CI']"> <CI> <P> <xsl:for-each select="*[name()!='CI']|text()"> <xsl:value-of select="." /> </xsl:for-each> </P> </CI> </xsl:when> </xsl:choose> </xsl:for-each> </SE> </xsl:template> <xsl:template match="P"/> </xsl:stylesheet>
Help!!!
Partager