XSLT elemento disponibili () funzione
Definizione e utilizzo
elemento disponibili () restituisce un valore booleano che indica se il processore XSLT supporta gli elementi specificati.
La funzione può essere utilizzata solo per testare gli elementi del corpo del modello si trova. Questi elementi sono:
- xsl: apply-importazione
- xsl: apply-templates
- xsl: attributi
- xsl: call-template
- xsl: choose
- xsl: commento
- xsl: copy
- xsl: copia-di
- xsl: elemento
- xsl: fallback
- xsl: for-each
- xsl: if
- xsl: message
- xsl: il numero
- xsl: istruzione di elaborazione
- xsl: text
- xsl: value-of
- xsl: variable
grammatica
boolean element-available(string)
parametri
参数 | 描述 |
---|---|
string | 必需。规定要测试的元素。 |
esempio 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>
Vedere file XSL , visualizzare i risultati .
Completa Oggetti di riferimento XSLT funzione