Hàm XSLT có sẵn phần tử ()
❮ Tham chiếu chức năng XSLTĐịnh nghĩa và Cách sử dụng
Hàm element-available () trả về giá trị Boolean cho biết liệu phần tử được chỉ định có được hỗ trợ bởi bộ xử lý XSLT hay không.
Chức năng này chỉ có thể được sử dụng để kiểm tra các phần tử có thể xuất hiện trong phần thân mẫu. Các yếu tố này là:
- xsl: áp dụng-nhập khẩu
- xsl: áp dụng mẫu
- xsl: thuộc tính
- xsl: call-template
- xsl: chọn
- xsl: bình luận
- xsl: copy
- xsl: copy-of
- xsl: phần tử
- xsl: dự phòng
- xsl: cho-mỗi
- xsl: nếu
- xsl: tin nhắn
- xsl: số
- xsl: hướng dẫn xử lý
- xsl: text
- xsl: value-of
- xsl: biến
Cú pháp
boolean element-available(string)
Thông số
Parameter | Description |
---|---|
string | Required. Specifies the element to test |
ví dụ 1
<?xml version="1.0" encoding="UTF-8"?>
<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>
Xem tệp XSL và
Xem kết quả .
❮ Tham chiếu chức năng XSLT