<xvcd:sort>の練習3 年齢の降順で並べ替える
1つ前のサンプルを昇順→降順に変更しただけのサンプル。
【result view】
【xfy_sample0025.xml】
<?xml version="1.0"?>
<?com.xfy vocabulary-connection href="xfy_sample0025.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="011" sex="不明" age="28" post="">田中薫</m3:person>
</m3:list>
</m3:document>
【xfy_sample0025.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>
<table border="1">
<tr><th>番号</th><th>性別</th><th>年齢</th><th>ポスト</th><th>氏名</th></tr>
<xvcd:apply-templates select="m3:list/m3:person">
<xvcd:sort select="@age" data-type="numbert" order="descending" />
</xvcd:apply-templates>
</table>
</body>
</html>
</xvcd:template>
<xvcd:template match="m3:list/m3:person">
<tr>
<td><xvcd:value-of select="@num"/></td>
<td><xvcd:value-of select="@sex"/></td>
<td><xvcd:value-of select="@age"/></td>
<td><xvcd:value-of select="@post"/></td>
<td><xvcd:value-of select="text()"/></td>
</tr>
</xvcd:template>
</xvcd:xvcd>