<xvcd:choose>、<xvcd:when>、<xvcd:otherwise>の練習3

属性のデータが空かどうかを調べて分岐している例。
<xvcd:when test="@post!=''">でpost属性が空でない場合の処理を行い、
<xvcd:otherwise>でそうでない場合(空の場合)の処理を行っている。

【result view】

【xfy_sample0022.xml】
<?xml version="1.0"?>
<?com.xfy vocabulary-connection href="tmp.xvcd" ?>
<m3:document xmlns:m3="http://www.makoto3.net/xfy">
	<m3:list>
		<m3:person num="001" sex="男" age="58" post="社長">山田太郎</m3:person>
		<m3:person num="002" sex="男" age="42" post="取締役">鈴木健一</m3:person>
		<m3:person num="003" sex="女" age="48" post="取締役">菊池桃子</m3:person>
		<m3:person num="004" sex="男" age="39" post="部長">吉田啓介</m3:person>
		<m3:person num="005" sex="女" age="38" post="部長">三好恵美子</m3:person>
		<m3:person num="006" sex="男" age="25" post="">神田紀夫</m3:person>
		<m3:person num="007" sex="男" age="30" post="">菊野浩二</m3:person>
		<m3:person num="008" sex="女" age="28" post="">美濃励子</m3:person>
		<m3:person num="009" sex="男" age="22" post="">岡野祐輔</m3:person>
		<m3:person num="010" sex="男" age="35" post="">和田真一</m3:person>
		<m3:person num="010" sex="" age="28" post="">田中薫</m3:person>
	</m3:list>
</m3:document>

【xfy_sample0022.xvcd】
<?xml version="1.0"?>

<xvcd:xvcd
	xmlns:xvcd="http://xmlns.xfy.com/xvcd"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:m3="http://www.makoto3.net/xfy"
	version="1.0">

<xvcd:vocabulary name="xfy_sample" match="m3:document" call-template="root"/>
	<xvcd:template name="root">
		<html>
			<head>
				<title>xfy example</title>
			</head>
			<body>
					<xvcd:apply-templates select="m3:list/m3:person"/>
			</body>
		</html>
	</xvcd:template>
	<xvcd:template match="m3:list/m3:person">
		<xvcd:choose>
			<xvcd:when test="@post!=''">
			<xvcd:value-of select="."/>さんは役職付きです。<br/>
			</xvcd:when>
			<xvcd:otherwise>
			<xvcd:value-of select="."/>さんは平社員です(残念!)。<br/>
			</xvcd:otherwise>
		</xvcd:choose>
	</xvcd:template>
</xvcd:xvcd>