Bonjour a Tous
J' essaye de mettre au point une feuille XSL de modification d' un fichier XHTML.
Le but est de completer certains attributs qui peuvent etre manquant.
En l' occurence: les "title" sur les <a> et aussi reformater les url en url "Absolues" (avec http://)
Je me heurte a un comportement complement étrange juste en déplacant un <xsl:attribute> avant ou apres un <xsl:if>
avant: tout est OK ma fonction en PHP est appelée
apres: aucun appel fait, c est comme si le <xsl:attribute> était ignoré.
MARCHE:
<xsl:when test="name()='a'">
<xsl:copy>
<xsl:attribute name="href">
<xsl:value-of select="php:functionString('page_format_href_absolute',@href)"/>
</xsl:attribute>
<xsl:if test="not(normalize-space(@title))">
(....)
</xsl:if>
MARCHE PAS:
<xsl:when test="name()='a'">
<xsl:copy>
<xsl:if test="not(normalize-space(@title))">
(....)
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of select="php:functionString('page_format_href_absolute',@href)"/>
</xsl:attribute>
C' est comme si apres le <xsl:if>, l' atribut "href" était "read-only". Je dis ca pas car j' ai decouvert dans les archives du site que les variables était en fait des constantes (quelle déception!)
Voici ma regle en entier:
<xsl:template match="/|@*|node()">
<xsl:choose>
<xsl:when test="name()='a'">
<xsl:copy>
<xsl:attribute name="href">
<xsl:value-of select="php:functionString('page_format_href_absolute',@href)"/>
</xsl:attribute>
<xsl:if test="not(normalize-space(@title))">
<xsl:variable name="current_page_name" select="@href"/>
<xsl:variable name="header" select="document('xml/map.xml')/map/headers/header[@name=$current_page_name]"/>
<xsl:attribute name="title">
<xsl:choose>
<xsl:when test="normalize-space($header/alt)">
<xsl:value-of select="normalize-space($header/alt)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:when>
<xsl:when test="@id='link_count'">
<xsl:value-of select="count(//*[name()='a'])"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Merci beaucoup pour votre Lecture et votre aide
Cordialement
Marc Abiven
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Received on Thu Nov 17 02:11:05 2005