@634

XSLT - テキストの生成 (xsl:text)

Advertisement

書式

<xsl:text>
    テキスト文字列
<xsl:/text>

<xsl:text>
    名前
<xsl:/text>
「名前」 というテキストが作成される。

サンプルコード

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

<document>
    <book id="10">
        <title>AAA</title>
        <price>4000</price>
    </book>
    <book id="20">
        <title>BBB</title>
        <price>1000</price>
    </book>
    <book id="30">
        <title>CCC</title>
        <price>2000</price>
    </book>
    <book id="40">
        <title>DDD</title>
        <price>1500</price>
    </book>
    <book id="50">
        <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="document">
    <html>
    <head>
    <title>XSLT</title>
    </head>
    <body>
	<xsl:apply-templates select="book"/>
    </body>
    </html>
</xsl:template>

<xsl:template match="book">
    <xsl:text>タイトル:</xsl:text>
    <xsl:value-of select="title"/><br/>
    <xsl:text>値段:</xsl:text>
    <xsl:value-of select="price"/><br/><br/>
</xsl:template>

</xsl:stylesheet>
生成されるコード
<html>
<head>
<title>XSLT</title>
</head>
<body>
タイトル:AAA<br />
値段:4000<br />
<br />
タイトル:BBB<br />
値段:1000<br />
<br />
タイトル:CCC<br />
値段:2000<br />
<br />
タイトル:DDD<br />
値段:1500<br />
<br />
タイトル:EEE<br />
値段:500<br />
<br />
</body>
</html>

Advertisement

ショートカット

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

サイト検索


Y!ログール