XSLT要素-利用可能()関数
定義と使用法
要素-利用可能()関数は、XSLTプロセッサが指定した要素をサポートしているかどうかを示すブール値を返します。
関数は、体が配置されているテンプレートの要素をテストするために使用することができます。 これらの要素は次のとおりです。
- xsl:適用-輸入
- xsl:適用され、テンプレート
- xsl:属性
- XSL:コールテンプレート
- xsl:選択
- xsl:コメント
- xsl:コピー
- XSL:コピーの
- xsl:要素
- xsl:フォールバック
- XSL:ため、各
- xsl:場合
- xsl:メッセージ
- xsl:数
- xsl:処理命令
- xsl:テキスト
- XSL:価値の
- xsl:変数
文法
boolean element-available(string)
パラメータ
参数 | 描述 |
---|---|
string | 必需。规定要测试的元素。 |
例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>
完全なXSLT関数リファレンスオブジェクト