supprimer une balise précèdent une autre

"Jean-Marc Desprez" <[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <[email protected]>
Bonjour à tous
J'ai un fichier xml qui correspond à ceci :
<!-- je dois supprimer ce block -->
<fo:block>
 <fo:leader line-height="10pt"/>
</fo:block>
<!-- qui est avant un block avec un leader ayant l'attribut line-height à
0pt -->
<fo:block>
 <fo:leader line-height="0pt"/>
</fo:block>

pour supprimer le block voulu, j'utilise ceci :
<xsl:template match="fo:block[following-sibling::fo:block[position()=1]/fo:
leader/@line-height='0pt']"/>

Déjà, je ne sais pas si j'emploi la bonne méthode (elle fonctionne mais il y
a peut être mieux)

J'aimerai ajouter deux "fonctionnalités"
1 - ne supprimer que si le block ne contient pas de texte
si je garde l'expression xpath actuelle, le template deviendrai
<xsl:template match="fo:block[following-sibling::fo:block[position()=1]/fo:
leader/@line-height='0pt'] and
fo:block[following-sibling::fo:block[position()=1]/fo:leader/text() = '' "/>

y a t'il un moyen de faire plus simplement ?


2 - supprimer tous les tag de type block consécutifs (pas seulement le n-1 )
qui précède le block@line-height="0pt"
Là je ne vois pas de solution, si j'utilise ce template
<xsl:template match="fo:block[
following-sibling::fo:block/fo:leader/@line-height='0pt']"/>
je vais avoir le problème suivant

<!-- ce block sera supprimé à tord -->
<fo:block>
 <fo:leader line-height="10pt"/>
</fo:block>
<!-- car il y a un autre tag entre deux -->
<table>
  <autreBalise/>
</table>
<!-- il faut supprimer ce block -->
<fo:block>
 <fo:leader line-height="10pt"/>
</fo:block>
<fo:block>
 <fo:leader line-height="0pt"/>
</fo:block>

Là je ne vois pas du tout de solution


Merci
Jean-Marc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.