Fonction XSLT element-available()Function
Référence complète des fonctions XSLT
Définition et utilisation
La fonction element-available() renvoie une valeur booléenne qui indique si le processeur XSLT prend en charge l'élément spécifié.
Cette fonction ne peut être utilisée que pour tester des éléments situés dans le corps du modèle. Ces éléments sont :
- xsl:apply-imports
- xsl:apply-templates
- xsl:attributes
- xsl:call-template
- xsl:choose
- xsl:comment
- xsl:copy
- xsl:copy-of
- xsl:element
- xsl:fallback
- xsl:for-each
- xsl:if
- xsl:message
- xsl:number
- xsl:processing instruction
- xsl:text
- xsl:value-of
- xsl:variable
Syntaxe
boolean element-available(string)
Parameters
| Paramètre | Description |
|---|---|
| string | Requis. Spécifie l'élément à tester. |
Exemple 1
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:choose>
<xsl:when test="element-available('xsl:comment')">
<p>xsl:comment est pris en charge.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:comment n'est pas pris en charge.</p>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="element-available('xsl:delete')">
<p>xsl:delete est pris en charge.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:delete n'est pas pris en charge.</p>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:choose>
<xsl:when test="element-available('xsl:comment')">
<p>xsl:comment est pris en charge.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:comment n'est pas pris en charge.</p>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="element-available('xsl:delete')">
<p>xsl:delete est pris en charge.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:delete n'est pas pris en charge.</p>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
,
Voir le résultat.
Référence complète des fonctions XSLT Autres extensions