Article View: fr.comp.text.xml
Article #19Re: validation xhtml
From: Alain Ketterlin
Date: Fri, 18 Jan 2002 08:14
Date: Fri, 18 Jan 2002 08:14
85 lines
3569 bytes
3569 bytes
yvon.thoraval@free.fr (Yvon Thoraval) writes:
[...]
> la sortie xhtml donne :
>
> <img src="nnn" ... > il n'y a donc pas de /> � la fin
C'est du HTML, pas du XHTML. Cela doit se regler dans le <xsl:output>.
> comment puis-je y rem�dier en mettant :
>
> <xsl:template match="img">
> <img />
Non non, parce que ton element serait ferme avant d'y placer les
attributs. (Rassure-nous, tu met bien </img> apres tous les tests ?)
> <xsl:if test="@id">
> <xsl:attribute name="id">
> <xsl:value-of select="@id" />
> </xsl:attribute>
> </xsl:if>
> <xsl:if test="@name">
> <xsl:attribute name="name">
> <xsl:value-of select="@name" />
> </xsl:attribute>
> </xsl:if>
> <xsl:attribute name="src">
> <xsl:value-of select="@src" />
> </xsl:attribute>
> .
> .
> .
> </xsl:template>
> � la place de ce qui pr�c�de ???
>
> de plus je n'ai pas pr�vu d'attribut alt et je voudrait le g�n�rer �
> partir de l'url qui est de la forme :
>
> monDossier/monImage.gif (ou jpg)
<xsl:attribute name="alt"><xsl:value-of select="@src"/></xsl:attribute>
devrait deja donner quelque chose.
> y a t'il un moyen d'obtenir, de filtrer avec xsl monImage, c'est � dire
> ce qu'il y a entre / et . ???
Tu veux garder juste monImage, c'est cela ? Alors :
<xsl:value-of
select="substring-before(substring-after(@src,'/'),'.')"/>
Mais ca ne marchera pas avec a/b/i.gif (donnera b/i). Dans ce cas :
<xsl:template name="last-path">
<xsl:param name="path">
<xsl:choose>
<xsl:when test="contains($path,'/')">
<xsl:call-template name="last-path">
<xsl:with-param name="path" select="substring-after($path,'/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path,.)">
<xsl:value-of select="substring-before($path,'.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Les deux dernieres cas sont peut-etre redondants (le dernier est la
quand il n'y a pas de . dans @src, parce qu'a mon avis
substring-before est mal concue).
Ca s'utilise comme cela :
<xsl:attribute name="alt">
<xsl:call-template name="last-path">
<xsl:with-param name="path" select="@src"/>
</xsl:call-template>
</xsl:attribute>
-- Alain.
Technical Details
Message-ID:
<wy1ygogjnr.fsf@polya.u-strasbg.fr>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!fr.usenet-edu.net!usenet-edu.net!ciril.fr!news.u-strasbg.fr!not-for-mailReferences:
<1f66e95.i3ubuzc8da3qN%yvon.thoraval@free.fr>Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: 100048,130b535cba777553 X-Google-Attributes: gid100048,public X-Google-Thread: 114f60,130b535cba777553 X-Google-Attributes: gid114f60,public X-Google-ArrivalTime: 2002-01-18 00:00:37 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!fr.usenet-edu.net!usenet-edu.net!ciril.fr!news.u-strasbg.fr!not-for-mail From: Alain Ketterlin <alain@dpt-info.u-strasbg.fr> Newsgroups: fr.comp.text.xml,fr.comp.infosystemes.www.auteurs Subject: Re: validation xhtml Followup-To: fr.comp.text.xml Date: 18 Jan 2002 09:14:48 +0100 Organization: CRC - Universite Louis Pasteur Strasbourg France Lines: 85 Message-ID: <wy1ygogjnr.fsf@polya.u-strasbg.fr> References: <1f66e95.i3ubuzc8da3qN%yvon.thoraval@free.fr> NNTP-Posting-Host: polya.u-strasbg.fr X-Trace: news.u-strasbg.fr 1011345807 15815 130.79.44.199 (18 Jan 2002 09:23:27 GMT) X-Complaints-To: usenet@u-strasbg.fr NNTP-Posting-Date: 18 Jan 2002 09:23:27 GMT X-Newsreader: Gnus v5.6.45/XEmacs 21.1 - "Capitol Reef"