@634

XSLT - 番号の生成(xsl:number)

Advertisement

書式

<xsl:number />

サンプルコード

sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>

<document>
    <book>
        <title>AAA</title>
        <price>4000</price>
    </book>
    <book>
        <title>BBB</title>
        <price>1000</price>
    </book>
    <book>
        <title>CCC</title>
        <price>2000</price>
    </book>
    <book>
        <title>DDD</title>
        <price>1500</price>
    </book>
    <book>
        <title>EEE</title>
        <price>500</price>
    </book>
</document>

style.xsl
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <table>
    <tr>
    <th>Number</th>
    <th>Title</th>
    <th>Price</th>
    </tr>
    <xsl:apply-templates />
    </table>
    </body>
    </html>
</xsl:template>

<xsl:template match="book">
    <tr>
        <td><xsl:number /></td>
        <td><xsl:value-of select="title" /></td>
        <td><xsl:value-of select="price" /></td>
    </tr>
</xsl:template>

</xsl:stylesheet> 

生成されるコード

Advertisement

ショートカット

634
634ブログ
このカテゴリのトップページに戻る
Incubator(Pukiwiki)
634ラボ
   UIコレクションギャラリー
   ZO-3ジェネレーター

サイト検索


Y!ログール

ビリヤード