Función del elemento disponible XSLT ()
Definición y Uso
elemento disponible () devuelve un valor booleano que indica si el procesador XSLT es compatible con los elementos especificados.
La función sólo puede ser utilizado para probar los elementos del cuerpo de la plantilla se encuentra. Estos elementos son los siguientes:
- xsl: apply-importaciones
- xsl: apply-templates
- XSL: atributos
- xsl: call-template
- xsl: choose
- xsl: comentario
- xsl: copia
- xsl: copy-of
- elemento xsl:
- xsl: fallback
- xsl: for-each
- xsl: if
- xsl: mensaje
- xsl: Número
- xsl: instrucción de procesamiento
- xsl: text
- xsl: value-of
- xsl: variable de
gramática
boolean element-available(string)
parámetros
参数 | 描述 |
---|---|
string | 必需。规定要测试的元素。 |
Ejemplo 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 is supported.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:comment is not supported.</p>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="element-available('xsl:delete')">
<p>xsl:delete is supported.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:delete is not supported.</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 is supported.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:comment is not supported.</p>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="element-available('xsl:delete')">
<p>xsl:delete is supported.</p>
</xsl:when>
<xsl:otherwise>
<p>xsl:delete is not supported.</p>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Ver archivo XSL , ver los resultados .
Los objetos de referencia de funciones completas XSLT