Bonjour à tous !

petite question... j'ai un fichier qui est un "fragment" xsl-fo du genre :

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
 
<fo:block font-family='Arial' font-size='11px' padding-bottom='10px' text-align='justify' break-after='page' id='s1_p11_fr'>
 
	<fo:marker marker-class-name='page-title'>Préliminaires</fo:marker>
	<fo:marker marker-class-name='section-page'>1.11</fo:marker>
	<fo:marker marker-class-name='section-page-indice'>.a</fo:marker>
	<fo:marker marker-class-name='nextIndex'>b</fo:marker>
	<fo:marker marker-class-name='next'>
		<fo:external-graphic src='[ASSETS_PATH]arrow.png' width='26px' height='13px' content-width='scale-to-fit' content-height='scale-to-fit' />
	</fo:marker>
 
	<fo:block-container padding-top='10px'>
		<fo:block font-family='Arial Black' font-weight='bold' padding-bottom='2px'>1. GENERALITÉS</fo:block>
		<fo:block-container margin-left='6px'>
			<fo:block padding-top='2px'>Le présent catalogue "<fo:inline font-family='Arial Black' font-weight='bold'>FONTES DE VOIRIE</fo:inline>" a été conçu spécialement pour l'ingénieur, l'architecte, l'entrepreneur. Il se veut un instrument simple et pratique pour orienter son utilisateur sur le choix le plus judicieux et le mieux adapté à chaque cas spécifique.</fo:block>
			<fo:block padding-top='2px'>Il annule et remplace toutes les éditions précédentes.</fo:block>
			<fo:block padding-top='2px'>Toutes les dimensions sont indiquées en millimètres. Les poids le sont à titre indicatifs.</fo:block>						
		</fo:block-container>
	</fo:block-container>
 
	<fo:block-container padding-top='30px'>
		<fo:block font-family='Arial Black' font-weight='bold' padding-bottom='2px'>2. NORMALISATION ET UTILISATION</fo:block>
		<fo:block-container margin-left='6px'>
			<fo:block padding-top='2px'>Les éléments correspondent pour la plupart aux exigences de la norme européenne <fo:inline font-family='Arial Black' font-weight='bold'>X</fo:inline> ainsi qu’à la norme suisse <fo:inline font-family='Arial Black' font-weight='bold'>Y</fo:inline></fo:block>
			<fo:block padding-top='2px'>Les produits de notre entreprise sont généralement soumis aux normes ou aux recommandations de l'association VSS, ainsi qu'à toutes celles de la SNV (Société suisse de normalisation) et de la SIA (Société suisse des ingénieurs et architectes).</fo:block>
		</fo:block-container>
	</fo:block-container>
</fo:block>
 
<fo:block font-family='Arial' font-size='11px' text-align='justify' break-after='page'>
	<fo:marker marker-class-name='page-title'>Préliminaires</fo:marker>
	<fo:marker marker-class-name='section-page'>1.11</fo:marker>
	<fo:marker marker-class-name='section-page-indice'>.b</fo:marker>
	<fo:marker marker-class-name='nextIndex'>c</fo:marker>
	<fo:marker marker-class-name='next'>
		<fo:external-graphic src='[ASSETS_PATH]arrow.png' width='26px' height='13px' content-width='scale-to-fit' content-height='scale-to-fit' />
	</fo:marker>
 
	<fo:block-container padding-top='10px'>
		<fo:block font-family='Arial Black' font-weight='bold' padding-bottom='2px'>3. GUIDES D'UTILISATION</fo:block>
		<fo:block-container margin-left='6px'>
			<fo:block padding-top='2px'>L'ingénieur, l'architecte, l'entrepreneur ou toute autre personne chargée du choix ou de l'installation utilisera les documents suivants pour déterminer quel produit convient le mieux au cas particulier qui lui est posé :</fo:block>
				<fo:list-block provisional-distance-between-starts="10px" space-before.optimum="3px">
					<fo:list-item padding-top='2px'>
						<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"><fo:block>Le tableau <fo:inline font-family='Arial Black' font-weight='bold'>Normes et Applications (<fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p31_fr'>1.31</fo:basic-link>)</fo:inline> lui permet de déterminer en fonction de sa zone d'utilisation, à quelles sollicitations doit répondre le produit devant être utilisé.</fo:block></fo:list-item-body>
					</fo:list-item>
					<fo:list-item padding-top='2px'>
						<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"><fo:block>Les normes <fo:inline font-family='Arial Black' font-weight='bold'>X</fo:inline> et <fo:inline font-family='Arial Black' font-weight='bold'>Y</fo:inline> lui fournissent la notion de <fo:inline font-family='Arial Black' font-weight='bold'>groupes</fo:inline> et de <fo:inline font-family='Arial Black' font-weight='bold'>classes</fo:inline> minimales en fonction des lieux d’installation des dispositifs. Un <fo:inline font-family='Arial Black' font-weight='bold'>schéma et une description</fo:inline> de ceux-ci les explicitent (<fo:inline font-family='Arial Black' font-weight='bold'><fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p41_fr'>1.41</fo:basic-link></fo:inline>)</fo:block></fo:list-item-body>
					</fo:list-item>
					<fo:list-item padding-top='2px'>
						<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"><fo:block>Le <fo:inline font-family='Arial Black' font-weight='bold'>Répertoire synoptique (<fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p111_1_a'>1.111 - 1.114</fo:basic-link>)</fo:inline> le guide, à partir des principaux critères qui lui sont connus ou qu'il entend faire respecter, pour choisir le genre d'article correspondant à ses besoins et la référence à rechercher.</fo:block></fo:list-item-body>
					</fo:list-item>
					<fo:list-item padding-top='2px'>
						<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"><fo:block>Le <fo:inline font-family='Arial Black' font-weight='bold'>Répertoire numérique par référence (<fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p131_a'>1.131</fo:basic-link>)</fo:inline> et le <fo:inline font-family='Arial Black' font-weight='bold'>Répertoire numérique par page (<fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p132_a'>1.132</fo:basic-link>)</fo:inline> lui donnent la clef d'accès aux fiches techniques sur lesquelles il trouve, pour `chaque modèle, les caractéristiques dimensionnelles, techniques et d'utilisation.</fo:block></fo:list-item-body>
					</fo:list-item>
					<fo:list-item padding-top='2px'>
						<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"><fo:block>Des <fo:inline font-family='Arial Black' font-weight='bold'>Tables de conversion (<fo:basic-link color='[LINK_COLOR]' internal-destination='s1_p151_a'>1.151 - 1.155</fo:basic-link>)</fo:inline> sommaires font partie intégrante du présent catalogue. Une version plus élaborée est disponible avec la version internet de notre catalogue.</fo:block></fo:list-item-body>
					</fo:list-item>
				</fo:list-block>
		</fo:block-container>
	</fo:block-container>
</fo:block>
J'aimerai le parser pour en sortir une version HTML. Je récupère donc le contenu de ce fichier, j'y ajoute la balise de départ fo:root avec le namespace xsl:fo. Je passe ensuite le tout à un DOMDocument via loadXML et je lui adjoint le xsl suivant :

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
 
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 
		 xmlns:fo='http://www.w3.org/1999/XSL/Format' 
		 version="1.0">
<xsl:output encoding="ISO-8859-1"/>
 
 
<xsl:template match="fo:root">
	<xsl:apply-templates />
</xsl:template>
 
<xsl:template match="fo:block-container">
	<xsl:variable name="paddingbottom">
		<xsl:if test="./@padding-bottom != ''">padding-bottom:<xsl:value-of select="./@padding-bottom" />;</xsl:if>
	</xsl:variable>
	<xsl:variable name="paddingtop">
		<xsl:if test="./@padding-top != ''">padding-top:<xsl:value-of select="./@padding-top" />;</xsl:if>
	</xsl:variable>
	<div class='container' style="{$paddingbottom}{$paddingtop}">
		<xsl:apply-templates />
	</div>
</xsl:template>	
 
<xsl:template match="fo:block">
	<xsl:variable name="size">
		<xsl:if test="./@font-size != ''">font-size:<xsl:value-of select="./@font-size" />;</xsl:if>
	</xsl:variable>
	<xsl:variable name="family">
		<xsl:if test="./@font-family != ''">font-family:<xsl:value-of select="./@font-family" />;</xsl:if>
	</xsl:variable>
	<xsl:variable name="paddingbottom">
		<xsl:if test="./@padding-bottom != ''">padding-bottom:<xsl:value-of select="./@padding-bottom" />;</xsl:if>
	</xsl:variable>
	<div class="block" style="{$size}{$family}{$paddingbottom}">
		<xsl:apply-templates />
	</div>
</xsl:template>
 
<xsl:template match="fo:list-block">
	<ul class="list-block">
		<xsl:apply-templates />
	</ul>
</xsl:template>
 
<xsl:template match="fo:list-item">
	<li><xsl:value-of select="./fo:list-item-body/fo:block/." /></li>
</xsl:template>
 
</xsl:stylesheet>
J'ai bien en sortie un html plus ou moins valide (il faut encore que je travaille le xsl) mais j'ai un petit souci... Les fo:block de premiers niveau sont transformés en div mais incluent le namespace xsl:fo, exemple :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
<div xmlns:fo="http://www.w3.org/1999/XSL/Format" class="block" style="font-size:11px;font-family:Arial;padding-bottom:10px;">
Je ne comprends pas trop pourquoi... existe-t-il un moyen de supprimer ce namespace ?


Question subsidiaire : dans mon fragment, vous pouvez voir que j'ai plusieurs fois des marqueurs tels que "page-title". Ils étaient à la base utilisés conjointement avec l'attribut "page-break" afin de récupérer le même titre de page pour plusieurs pages différentes. Maintenant que je suis en mode HTML, je vais afficher tout le contenu sur une seule page, donc plus besoin des marqueurs supplémentaires, seul les marqueurs de début du fragments sont nécessaire.

Est-il possible de ne parser que le premier marqueur "page-title" et ignorer les autres ? J'ai tenté avec ceci (et quelques variantes) mais je n'y arrive décidément pas...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
<xsl:template match="fo:marker">
	<xsl:value-of select="count(./@marker-class-name='page-title'(position())=1" />
	<xsl:if test="./@marker-class-name = 'page-title'">
	<h1><xsl:value-of select="." /></h1>
	</xsl:if>
</xsl:template>
Un petit peu d'aide serait la bienvenue.


D'avance merci pour vos suggestions :-)


Cordialement


[edit]Oups... je viens de me rendre compte que je n'ai pas posté dans le bon forum, ça aurait été mieux dans xml/xsl/soap... Toutes mes excuses... si un modo passe par là pourrait-il rediriger le post svp[/edit]