■(書式)boolean(引数)
・引数の種類によりブール値(true/false)に変換し、そのブール値を返す
・引数
数値・・・0又はNaNの場合はfalseに(例04,05)、それ以外はtrueに(例01,02,03,06)
文字列・・・空の場合はfalseに(例09)、それ以外はtrueに(例07,08)
ブール値・・・値はそのまま(例10,11)
node-set・・・ノードが存在しない場合はfalseに(例13,14)、それ以外はtrueに(例12)
[サンプルXML文書を表示](下のフレームに)
XMLソース
<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet type="text/xsl" href="boolean01.xsl"?>
<root>
<title>boolean()関数のテスト</title>
<data>
<test></test>
</data>
</root>
XSLソース
<?xml version="1.0" encoding="Shift_Jis"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="Shift_JIS"/>
<xsl:template match="/">
<center><H3><xsl:value-of select="root/title"/></H3></center>
<xsl:apply-templates select="root/data"/>
</xsl:template>
<xsl:template match="data">
01:boolean(123)・・・<xsl:value-of select="boolean(123)"/><br/>
02:boolean(-12.3)・・・<xsl:value-of select="boolean(-12.3)"/><br/>
03:boolean(123-6)・・・<xsl:value-of select="boolean(123-6)"/><br/>
04:boolean(123-123)・・・<xsl:value-of select="boolean(123-123)"/><br/>
05:boolean(0)・・・<xsl:value-of select="boolean(0)"/><br/>
06:boolean(0001)・・・<xsl:value-of select="boolean(0001)"/><br/>
07:boolean('abc')・・・<xsl:value-of select="boolean('abc')"/><br/>
08:boolean(' ')・・・<xsl:value-of select="boolean(' ')"/><br/>
09:boolean('')・・・<xsl:value-of select="boolean('')"/><br/>
10:boolean(true())・・・<xsl:value-of select="boolean(true())"/><br/>
11:boolean(false())・・・<xsl:value-of select="boolean(false())"/><br/>
12:boolean(test)・・・<xsl:value-of select="boolean(test)"/><br/>
13:boolean(test/text())・・・<xsl:value-of select="boolean(test/text())"/><br/>
14:boolean(testx)・・・<xsl:value-of select="boolean(testx)"/><br/>
</xsl:template>
</xsl:stylesheet>
end(04/8/13)