[XSLT] Redondance de balises
Bonjour,
Suite à la reprise d'un site pour une société, j'ai découvert que celui-ci avait été codé grâce aux xslt - xml...
Bon gré, mal gré, je suis en train d'apprendre le fonctionnement de ce duo, et je rencontre un léger problème de redondance...
En gros, le fichier html/php généré créé une redondance au niveau de la balise <para>
j'ai une structure html genre :
Code:
1 2 3 4
|
<p>
<para> le texte </para>
</p> |
la ou je ne devrais avoir qu'en théorie
Je sens que c'est tout bête, mais aidez-moi please ^_^
un exemple d'un fichier xml de base et sa feuille de style xslt :
Code:
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
| <?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
]>
<article>
<para>
<table align="center">
<tr>
<td>TEXTE+BALISES HTML</td>
</tr>
</table>
</para>
<title>TITRE 1</title>
<sect1>
<title>TITRE 2</title>
<title>SOUS-TITRE</title>
<formalpara>
<para>TEXTE+BALISES HTML</para>
<para>TEXTE+BALISES HTML</para>
</formalpara>
<formalpara>
<para>TEXTE+BALISES HTML</para>
<para>TEXTE+BALISES HTML</para>
</formalpara>
<formalpara>
<para>TEXTE+BALISES HTML</para>
<para>TEXTE+BALISES HTML</para>
</formalpara>
</sect1>
<sect1>
<formalpara>
<para>TEXTE+BALISES HTML</para>
<para>TEXTE+BALISES HTML</para>
</formalpara>
...........................ETC...................................
</sect1>
</article> |
Code:
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
| <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="html"
encoding="ISO-8859-1"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
indent="yes" />
<!-- CE PARAMETRE DEFINIT LE REPERTOIRE RACINE DES IMAGES -->
<xsl:param name="root" />
<!-- DERNIERE MODIFICATION -->
<xsl:param name="time" />
<!-- NOM DU FICHIER -->
<xsl:param name="article" />
<!-- EST-CE L'INDEX ? -->
<xsl:param name="index" />
<!-- ARTICLE SUIVANT -->
<xsl:param name="prev" />
<!-- ARTICLE PRECEDENT -->
<xsl:param name="next" />
<!-- DERNIER ARTICLE -->
<xsl:param name="last" />
<!-- RACINE DU SITE -->
<xsl:param name="siteRoot" />
<!-- LANGUE -->
<xsl:param name="lang" />
<!--Introduction du code html dans les articles-->
<xsl:template name="Html" match="a | applet | b | big | br | caption | cite |
code | col | colgroup | dd | div | dl | dt | em | font | form | frame |
frameset | head | h1 | h2 | h3 | h4 | h5 | h6 | hr | i | iframe | img
| link | li | map | noframes | ol | p | param | pre | s | small | span | strong | style | sub | sup | td | th | title | tr | tt | ul | var | table" >
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- RACINE DU DOCUMENT -->
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="article">
<xsl:for-each select="para">
<xsl:call-template name="paragraph"/>
</xsl:for-each>
<h1> <xsl:value-of disable-output-escaping="yes" select="title" /> </h1>
<xsl:for-each select="sect1">
<xsl:if test="title">
<h2>
<xsl:value-of select="title"/>
</h2>
</xsl:if>
<xsl:for-each select="formalpara">
<xsl:if test="title">
<h3>
<xsl:value-of select="title"/>
</h3>
</xsl:if>
<xsl:for-each select="para">
<p>
<xsl:call-template name="paragraph"/>
</p>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="title" name="titreLong">
<xsl:call-template name="Html"/>
</xsl:template>
<xsl:template match="article/sect1/formalpara/para" name="paragraph">
<xsl:call-template name="Html"/>
</xsl:template>
</xsl:stylesheet> |